Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

flag parameters: anon_inode_getfd extension

This patch just extends the anon_inode_getfd interface to take an additional
parameter with a flag value. The flag value is passed on to
get_unused_fd_flags in anticipation for a use with the O_CLOEXEC flag.

No actual semantic changes here, the changed callers all pass 0 for now.

[akpm@linux-foundation.org: KVM fix]
Signed-off-by: Ulrich Drepper <drepper@redhat.com>
Acked-by: Davide Libenzi <davidel@xmailserver.org>
Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Ulrich Drepper and committed by
Linus Torvalds
7d9dbca3 c019bbc6

+13 -11
+5 -4
fs/anon_inodes.c
··· 58 58 * of the file 59 59 * 60 60 * @name: [in] name of the "class" of the new file 61 - * @fops [in] file operations for the new file 62 - * @priv [in] private data for the new file (will be file's private_data) 61 + * @fops: [in] file operations for the new file 62 + * @priv: [in] private data for the new file (will be file's private_data) 63 + * @flags: [in] flags 63 64 * 64 65 * Creates a new file by hooking it on a single inode. This is useful for files 65 66 * that do not need to have a full-fledged inode in order to operate correctly. ··· 69 68 * setup. Returns new descriptor or -error. 70 69 */ 71 70 int anon_inode_getfd(const char *name, const struct file_operations *fops, 72 - void *priv) 71 + void *priv, int flags) 73 72 { 74 73 struct qstr this; 75 74 struct dentry *dentry; ··· 79 78 if (IS_ERR(anon_inode_inode)) 80 79 return -ENODEV; 81 80 82 - error = get_unused_fd(); 81 + error = get_unused_fd_flags(flags); 83 82 if (error < 0) 84 83 return error; 85 84 fd = error;
+1 -1
fs/eventfd.c
··· 214 214 * When we call this, the initialization must be complete, since 215 215 * anon_inode_getfd() will install the fd. 216 216 */ 217 - fd = anon_inode_getfd("[eventfd]", &eventfd_fops, ctx); 217 + fd = anon_inode_getfd("[eventfd]", &eventfd_fops, ctx, 0); 218 218 if (fd < 0) 219 219 kfree(ctx); 220 220 return fd;
+1 -1
fs/eventpoll.c
··· 1068 1068 * Creates all the items needed to setup an eventpoll file. That is, 1069 1069 * a file structure and a free file descriptor. 1070 1070 */ 1071 - fd = anon_inode_getfd("[eventpoll]", &eventpoll_fops, ep); 1071 + fd = anon_inode_getfd("[eventpoll]", &eventpoll_fops, ep, 0); 1072 1072 if (fd < 0) 1073 1073 ep_free(ep); 1074 1074
+2 -1
fs/signalfd.c
··· 227 227 * When we call this, the initialization must be complete, since 228 228 * anon_inode_getfd() will install the fd. 229 229 */ 230 - ufd = anon_inode_getfd("[signalfd]", &signalfd_fops, ctx); 230 + ufd = anon_inode_getfd("[signalfd]", &signalfd_fops, ctx, 231 + 0); 231 232 if (ufd < 0) 232 233 kfree(ctx); 233 234 } else {
+1 -1
fs/timerfd.c
··· 198 198 ctx->clockid = clockid; 199 199 hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS); 200 200 201 - ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx); 201 + ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx, 0); 202 202 if (ufd < 0) 203 203 kfree(ctx); 204 204
+1 -1
include/linux/anon_inodes.h
··· 9 9 #define _LINUX_ANON_INODES_H 10 10 11 11 int anon_inode_getfd(const char *name, const struct file_operations *fops, 12 - void *priv); 12 + void *priv, int flags); 13 13 14 14 #endif /* _LINUX_ANON_INODES_H */ 15 15
+2 -2
virt/kvm/kvm_main.c
··· 902 902 */ 903 903 static int create_vcpu_fd(struct kvm_vcpu *vcpu) 904 904 { 905 - int fd = anon_inode_getfd("kvm-vcpu", &kvm_vcpu_fops, vcpu); 905 + int fd = anon_inode_getfd("kvm-vcpu", &kvm_vcpu_fops, vcpu, 0); 906 906 if (fd < 0) 907 907 kvm_put_kvm(vcpu->kvm); 908 908 return fd; ··· 1261 1261 kvm = kvm_create_vm(); 1262 1262 if (IS_ERR(kvm)) 1263 1263 return PTR_ERR(kvm); 1264 - fd = anon_inode_getfd("kvm-vm", &kvm_vm_fops, kvm); 1264 + fd = anon_inode_getfd("kvm-vm", &kvm_vm_fops, kvm, 0); 1265 1265 if (fd < 0) 1266 1266 kvm_put_kvm(kvm); 1267 1267