From 39b743c6199a317ffac67fcae1dd05be3142633a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 6 Jun 2010 20:08:56 -0400 Subject: switch stat_file() to passing a single struct rather than fsckloads of pointers Signed-off-by: Al Viro --- fs/hostfs/hostfs.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'fs/hostfs/hostfs.h') diff --git a/fs/hostfs/hostfs.h b/fs/hostfs/hostfs.h index 2f34f8f2134b..3a52edef9948 100644 --- a/fs/hostfs/hostfs.h +++ b/fs/hostfs/hostfs.h @@ -53,11 +53,21 @@ struct hostfs_iattr { struct timespec ia_ctime; }; -extern int stat_file(const char *path, unsigned long long *inode_out, - int *mode_out, int *nlink_out, int *uid_out, int *gid_out, - unsigned long long *size_out, struct timespec *atime_out, - struct timespec *mtime_out, struct timespec *ctime_out, - int *blksize_out, unsigned long long *blocks_out, int fd); +struct hostfs_stat { + unsigned long long ino; + unsigned int mode; + unsigned int nlink; + unsigned int uid; + unsigned int gid; + unsigned long long size; + struct timespec atime, mtime, ctime; + unsigned int blksize; + unsigned long long blocks; + unsigned int maj; + unsigned int min; +}; + +extern int stat_file(const char *path, struct hostfs_stat *p, int fd); extern int access_file(char *path, int r, int w, int x); extern int open_file(char *path, int r, int w, int append); extern int file_type(const char *path, int *maj, int *min); -- cgit v1.2.3 From 4754b825571a6f2f7655245e420e8e486c4458f6 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 6 Jun 2010 20:33:12 -0400 Subject: hostfs: get rid of file_type(), fold init_inode() Signed-off-by: Al Viro --- fs/hostfs/hostfs.h | 1 - 1 file changed, 1 deletion(-) (limited to 'fs/hostfs/hostfs.h') diff --git a/fs/hostfs/hostfs.h b/fs/hostfs/hostfs.h index 3a52edef9948..ea87e224ed97 100644 --- a/fs/hostfs/hostfs.h +++ b/fs/hostfs/hostfs.h @@ -70,7 +70,6 @@ struct hostfs_stat { extern int stat_file(const char *path, struct hostfs_stat *p, int fd); extern int access_file(char *path, int r, int w, int x); extern int open_file(char *path, int r, int w, int append); -extern int file_type(const char *path, int *maj, int *min); extern void *open_dir(char *path, int *err_out); extern char *read_dir(void *stream, unsigned long long *pos, unsigned long long *ino_out, int *len_out); -- cgit v1.2.3 From f8ad850f11e11d10e7de1a16ca53cb193afc9313 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 6 Jun 2010 23:49:18 -0400 Subject: try to get rid of races in hostfs open() In case of mode mismatch, do *not* blindly close the descriptor another openers might be using right now. Open the underlying file with currently sufficient mode, then * if current mode has grown so that it's sufficient for us now, just close our new fd * if current mode has grown and our fd is *not* enough to cover it, close and repeat. * otherwise, install our fd if the file hadn't been opened at all or dup2() our fd over the current one (and close our fd). Critical section is protected by mutex; yes, system-wide. All we do under it is a bunch of comparison and maybe an overwriting dup2() on host. Signed-off-by: Al Viro --- fs/hostfs/hostfs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'fs/hostfs/hostfs.h') diff --git a/fs/hostfs/hostfs.h b/fs/hostfs/hostfs.h index ea87e224ed97..6bbd75c5589b 100644 --- a/fs/hostfs/hostfs.h +++ b/fs/hostfs/hostfs.h @@ -74,6 +74,7 @@ extern void *open_dir(char *path, int *err_out); extern char *read_dir(void *stream, unsigned long long *pos, unsigned long long *ino_out, int *len_out); extern void close_file(void *stream); +extern int replace_file(int oldfd, int fd); extern void close_dir(void *stream); extern int read_file(int fd, unsigned long long *offset, char *buf, int len); extern int write_file(int fd, unsigned long long *offset, const char *buf, -- cgit v1.2.3