diff options
author | Richard Weinberger <richard@nod.at> | 2015-03-04 17:44:54 -0500 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2015-03-26 18:27:53 -0400 |
commit | b98b91029cf8a6defc6311d4018c44f3b05fbec7 (patch) | |
tree | 7100a22cd77997fef0f131440e0dd62d4e4a59a5 | |
parent | af6aa1b9cad7350d675fe3523ab062e0e4c829cb (diff) |
hostfs: No need to box and later unbox the file mode
There is really no point in having a function with 10
arguments.
Reported-by: Daniel Walter <d.walter@0x90.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
-rw-r--r-- | fs/hostfs/hostfs.h | 3 | ||||
-rw-r--r-- | fs/hostfs/hostfs_kern.c | 5 | ||||
-rw-r--r-- | fs/hostfs/hostfs_user.c | 17 |
3 files changed, 5 insertions, 20 deletions
diff --git a/fs/hostfs/hostfs.h b/fs/hostfs/hostfs.h index 4fcd40d6f308..493262e43443 100644 --- a/fs/hostfs/hostfs.h +++ b/fs/hostfs/hostfs.h | |||
@@ -77,8 +77,7 @@ extern int write_file(int fd, unsigned long long *offset, const char *buf, | |||
77 | int len); | 77 | int len); |
78 | extern int lseek_file(int fd, long long offset, int whence); | 78 | extern int lseek_file(int fd, long long offset, int whence); |
79 | extern int fsync_file(int fd, int datasync); | 79 | extern int fsync_file(int fd, int datasync); |
80 | extern int file_create(char *name, int ur, int uw, int ux, int gr, | 80 | extern int file_create(char *name, int mode); |
81 | int gw, int gx, int or, int ow, int ox); | ||
82 | extern int set_attr(const char *file, struct hostfs_iattr *attrs, int fd); | 81 | extern int set_attr(const char *file, struct hostfs_iattr *attrs, int fd); |
83 | extern int make_symlink(const char *from, const char *to); | 82 | extern int make_symlink(const char *from, const char *to); |
84 | extern int unlink_file(const char *file); | 83 | extern int unlink_file(const char *file); |
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index f82f98a517f7..e77da44a235c 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c | |||
@@ -582,10 +582,7 @@ static int hostfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, | |||
582 | if (name == NULL) | 582 | if (name == NULL) |
583 | goto out_put; | 583 | goto out_put; |
584 | 584 | ||
585 | fd = file_create(name, | 585 | fd = file_create(name, mode & S_IFMT); |
586 | mode & S_IRUSR, mode & S_IWUSR, mode & S_IXUSR, | ||
587 | mode & S_IRGRP, mode & S_IWGRP, mode & S_IXGRP, | ||
588 | mode & S_IROTH, mode & S_IWOTH, mode & S_IXOTH); | ||
589 | if (fd < 0) | 586 | if (fd < 0) |
590 | error = fd; | 587 | error = fd; |
591 | else | 588 | else |
diff --git a/fs/hostfs/hostfs_user.c b/fs/hostfs/hostfs_user.c index 9765dab95cbd..34ab81b21c93 100644 --- a/fs/hostfs/hostfs_user.c +++ b/fs/hostfs/hostfs_user.c | |||
@@ -175,21 +175,10 @@ void close_dir(void *stream) | |||
175 | closedir(stream); | 175 | closedir(stream); |
176 | } | 176 | } |
177 | 177 | ||
178 | int file_create(char *name, int ur, int uw, int ux, int gr, | 178 | int file_create(char *name, int mode) |
179 | int gw, int gx, int or, int ow, int ox) | ||
180 | { | 179 | { |
181 | int mode, fd; | 180 | int fd; |
182 | 181 | ||
183 | mode = 0; | ||
184 | mode |= ur ? S_IRUSR : 0; | ||
185 | mode |= uw ? S_IWUSR : 0; | ||
186 | mode |= ux ? S_IXUSR : 0; | ||
187 | mode |= gr ? S_IRGRP : 0; | ||
188 | mode |= gw ? S_IWGRP : 0; | ||
189 | mode |= gx ? S_IXGRP : 0; | ||
190 | mode |= or ? S_IROTH : 0; | ||
191 | mode |= ow ? S_IWOTH : 0; | ||
192 | mode |= ox ? S_IXOTH : 0; | ||
193 | fd = open64(name, O_CREAT | O_RDWR, mode); | 182 | fd = open64(name, O_CREAT | O_RDWR, mode); |
194 | if (fd < 0) | 183 | if (fd < 0) |
195 | return -errno; | 184 | return -errno; |