Commit b98b9102 authored by Richard Weinberger's avatar Richard Weinberger

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: default avatarDaniel Walter <d.walter@0x90.at>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent af6aa1b9
...@@ -77,8 +77,7 @@ extern int write_file(int fd, unsigned long long *offset, const char *buf, ...@@ -77,8 +77,7 @@ extern int write_file(int fd, unsigned long long *offset, const char *buf,
int len); int len);
extern int lseek_file(int fd, long long offset, int whence); extern int lseek_file(int fd, long long offset, int whence);
extern int fsync_file(int fd, int datasync); extern int fsync_file(int fd, int datasync);
extern int file_create(char *name, int ur, int uw, int ux, int gr, extern int file_create(char *name, int mode);
int gw, int gx, int or, int ow, int ox);
extern int set_attr(const char *file, struct hostfs_iattr *attrs, int fd); extern int set_attr(const char *file, struct hostfs_iattr *attrs, int fd);
extern int make_symlink(const char *from, const char *to); extern int make_symlink(const char *from, const char *to);
extern int unlink_file(const char *file); extern int unlink_file(const char *file);
......
...@@ -582,10 +582,7 @@ static int hostfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, ...@@ -582,10 +582,7 @@ static int hostfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
if (name == NULL) if (name == NULL)
goto out_put; goto out_put;
fd = file_create(name, fd = file_create(name, mode & S_IFMT);
mode & S_IRUSR, mode & S_IWUSR, mode & S_IXUSR,
mode & S_IRGRP, mode & S_IWGRP, mode & S_IXGRP,
mode & S_IROTH, mode & S_IWOTH, mode & S_IXOTH);
if (fd < 0) if (fd < 0)
error = fd; error = fd;
else else
......
...@@ -175,21 +175,10 @@ void close_dir(void *stream) ...@@ -175,21 +175,10 @@ void close_dir(void *stream)
closedir(stream); closedir(stream);
} }
int file_create(char *name, int ur, int uw, int ux, int gr, int file_create(char *name, int mode)
int gw, int gx, int or, int ow, int ox)
{ {
int mode, fd; int fd;
mode = 0;
mode |= ur ? S_IRUSR : 0;
mode |= uw ? S_IWUSR : 0;
mode |= ux ? S_IXUSR : 0;
mode |= gr ? S_IRGRP : 0;
mode |= gw ? S_IWGRP : 0;
mode |= gx ? S_IXGRP : 0;
mode |= or ? S_IROTH : 0;
mode |= ow ? S_IWOTH : 0;
mode |= ox ? S_IXOTH : 0;
fd = open64(name, O_CREAT | O_RDWR, mode); fd = open64(name, O_CREAT | O_RDWR, mode);
if (fd < 0) if (fd < 0)
return -errno; return -errno;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment