diff options
author | Jeff Layton <jlayton@redhat.com> | 2012-10-10 16:43:10 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-10-12 20:15:09 -0400 |
commit | 669abf4e5539c8aa48bf28c965be05c0a7b58a27 (patch) | |
tree | 5b8e9e17c4f03ddd719c9c2089d829e2a040854a /fs/open.c | |
parent | 873f1eedc1b983d772283279192c4ca2f60e8482 (diff) |
vfs: make path_openat take a struct filename pointer
...and fix up the callers. For do_file_open_root, just declare a
struct filename on the stack and fill out the .name field. For
do_filp_open, make it also take a struct filename pointer, and fix up its
callers to call it appropriately.
For filp_open, add a variant that takes a struct filename pointer and turn
filp_open into a wrapper around it.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/open.c')
-rw-r--r-- | fs/open.c | 25 |
1 files changed, 21 insertions, 4 deletions
@@ -859,6 +859,24 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o | |||
859 | } | 859 | } |
860 | 860 | ||
861 | /** | 861 | /** |
862 | * file_open_name - open file and return file pointer | ||
863 | * | ||
864 | * @name: struct filename containing path to open | ||
865 | * @flags: open flags as per the open(2) second argument | ||
866 | * @mode: mode for the new file if O_CREAT is set, else ignored | ||
867 | * | ||
868 | * This is the helper to open a file from kernelspace if you really | ||
869 | * have to. But in generally you should not do this, so please move | ||
870 | * along, nothing to see here.. | ||
871 | */ | ||
872 | struct file *file_open_name(struct filename *name, int flags, umode_t mode) | ||
873 | { | ||
874 | struct open_flags op; | ||
875 | int lookup = build_open_flags(flags, mode, &op); | ||
876 | return do_filp_open(AT_FDCWD, name, &op, lookup); | ||
877 | } | ||
878 | |||
879 | /** | ||
862 | * filp_open - open file and return file pointer | 880 | * filp_open - open file and return file pointer |
863 | * | 881 | * |
864 | * @filename: path to open | 882 | * @filename: path to open |
@@ -871,9 +889,8 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o | |||
871 | */ | 889 | */ |
872 | struct file *filp_open(const char *filename, int flags, umode_t mode) | 890 | struct file *filp_open(const char *filename, int flags, umode_t mode) |
873 | { | 891 | { |
874 | struct open_flags op; | 892 | struct filename name = {.name = filename}; |
875 | int lookup = build_open_flags(flags, mode, &op); | 893 | return file_open_name(&name, flags, mode); |
876 | return do_filp_open(AT_FDCWD, filename, &op, lookup); | ||
877 | } | 894 | } |
878 | EXPORT_SYMBOL(filp_open); | 895 | EXPORT_SYMBOL(filp_open); |
879 | 896 | ||
@@ -901,7 +918,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode) | |||
901 | if (!IS_ERR(tmp)) { | 918 | if (!IS_ERR(tmp)) { |
902 | fd = get_unused_fd_flags(flags); | 919 | fd = get_unused_fd_flags(flags); |
903 | if (fd >= 0) { | 920 | if (fd >= 0) { |
904 | struct file *f = do_filp_open(dfd, tmp->name, &op, lookup); | 921 | struct file *f = do_filp_open(dfd, tmp, &op, lookup); |
905 | if (IS_ERR(f)) { | 922 | if (IS_ERR(f)) { |
906 | put_unused_fd(fd); | 923 | put_unused_fd(fd); |
907 | fd = PTR_ERR(f); | 924 | fd = PTR_ERR(f); |