diff options
Diffstat (limited to 'fs/open.c')
| -rw-r--r-- | fs/open.c | 29 |
1 files changed, 23 insertions, 6 deletions
| @@ -478,7 +478,7 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode) | |||
| 478 | 478 | ||
| 479 | file = fget(fd); | 479 | file = fget(fd); |
| 480 | if (file) { | 480 | if (file) { |
| 481 | audit_inode(NULL, file->f_path.dentry); | 481 | audit_inode(NULL, file->f_path.dentry, 0); |
| 482 | err = chmod_common(&file->f_path, mode); | 482 | err = chmod_common(&file->f_path, mode); |
| 483 | fput(file); | 483 | fput(file); |
| 484 | } | 484 | } |
| @@ -588,7 +588,7 @@ SYSCALL_DEFINE3(fchown, unsigned int, fd, uid_t, user, gid_t, group) | |||
| 588 | error = mnt_want_write_file(f.file); | 588 | error = mnt_want_write_file(f.file); |
| 589 | if (error) | 589 | if (error) |
| 590 | goto out_fput; | 590 | goto out_fput; |
| 591 | audit_inode(NULL, f.file->f_path.dentry); | 591 | audit_inode(NULL, f.file->f_path.dentry, 0); |
| 592 | error = chown_common(&f.file->f_path, user, group); | 592 | error = chown_common(&f.file->f_path, user, group); |
| 593 | mnt_drop_write_file(f.file); | 593 | mnt_drop_write_file(f.file); |
| 594 | out_fput: | 594 | out_fput: |
| @@ -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 | ||
| @@ -895,7 +912,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode) | |||
| 895 | { | 912 | { |
| 896 | struct open_flags op; | 913 | struct open_flags op; |
| 897 | int lookup = build_open_flags(flags, mode, &op); | 914 | int lookup = build_open_flags(flags, mode, &op); |
| 898 | char *tmp = getname(filename); | 915 | struct filename *tmp = getname(filename); |
| 899 | int fd = PTR_ERR(tmp); | 916 | int fd = PTR_ERR(tmp); |
| 900 | 917 | ||
| 901 | if (!IS_ERR(tmp)) { | 918 | if (!IS_ERR(tmp)) { |
