diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-05-08 11:23:18 +0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 22:14:57 +0400 |
commit | f1adc05e77383017bc63ea9c48ba217da76682b8 (patch) | |
tree | e58290483a62ce846bb63d2b965952bd038707bb /fs/hostfs/hostfs_user.c | |
parent | 5822b7faca709c03a59c2929005bfe9caffe6592 (diff) | |
download | linux-f1adc05e77383017bc63ea9c48ba217da76682b8.tar.xz |
uml: hostfs style fixes
hostfs needed some style goodness.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/hostfs/hostfs_user.c')
-rw-r--r-- | fs/hostfs/hostfs_user.c | 141 |
1 files changed, 73 insertions, 68 deletions
diff --git a/fs/hostfs/hostfs_user.c b/fs/hostfs/hostfs_user.c index 0acf562a5f06..5625e2481dd3 100644 --- a/fs/hostfs/hostfs_user.c +++ b/fs/hostfs/hostfs_user.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) + * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */ @@ -27,9 +27,9 @@ int stat_file(const char *path, unsigned long long *inode_out, int *mode_out, if(fd >= 0) { if (fstat64(fd, &buf) < 0) - return(-errno); + return -errno; } else if(lstat64(path, &buf) < 0) { - return(-errno); + return -errno; } if(inode_out != NULL) *inode_out = buf.st_ino; @@ -52,7 +52,7 @@ int stat_file(const char *path, unsigned long long *inode_out, int *mode_out, } if(blksize_out != NULL) *blksize_out = buf.st_blksize; if(blocks_out != NULL) *blocks_out = buf.st_blocks; - return(0); + return 0; } int file_type(const char *path, int *maj, int *min) @@ -60,7 +60,7 @@ int file_type(const char *path, int *maj, int *min) struct stat64 buf; if(lstat64(path, &buf) < 0) - return(-errno); + return -errno; /*We cannot pass rdev as is because glibc and the kernel disagree *about its definition.*/ if(maj != NULL) @@ -68,13 +68,13 @@ int file_type(const char *path, int *maj, int *min) if(min != NULL) *min = minor(buf.st_rdev); - if(S_ISDIR(buf.st_mode)) return(OS_TYPE_DIR); - else if(S_ISLNK(buf.st_mode)) return(OS_TYPE_SYMLINK); - else if(S_ISCHR(buf.st_mode)) return(OS_TYPE_CHARDEV); - else if(S_ISBLK(buf.st_mode)) return(OS_TYPE_BLOCKDEV); - else if(S_ISFIFO(buf.st_mode))return(OS_TYPE_FIFO); - else if(S_ISSOCK(buf.st_mode))return(OS_TYPE_SOCK); - else return(OS_TYPE_FILE); + if(S_ISDIR(buf.st_mode)) return OS_TYPE_DIR; + else if(S_ISLNK(buf.st_mode)) return OS_TYPE_SYMLINK; + else if(S_ISCHR(buf.st_mode)) return OS_TYPE_CHARDEV; + else if(S_ISBLK(buf.st_mode)) return OS_TYPE_BLOCKDEV; + else if(S_ISFIFO(buf.st_mode))return OS_TYPE_FIFO; + else if(S_ISSOCK(buf.st_mode))return OS_TYPE_SOCK; + else return OS_TYPE_FILE; } int access_file(char *path, int r, int w, int x) @@ -84,8 +84,9 @@ int access_file(char *path, int r, int w, int x) if(r) mode = R_OK; if(w) mode |= W_OK; if(x) mode |= X_OK; - if(access(path, mode) != 0) return(-errno); - else return(0); + if(access(path, mode) != 0) + return -errno; + else return 0; } int open_file(char *path, int r, int w, int append) @@ -103,8 +104,9 @@ int open_file(char *path, int r, int w, int append) if(append) mode |= O_APPEND; fd = open64(path, mode); - if(fd < 0) return(-errno); - else return(fd); + if(fd < 0) + return -errno; + else return fd; } void *open_dir(char *path, int *err_out) @@ -113,8 +115,9 @@ void *open_dir(char *path, int *err_out) dir = opendir(path); *err_out = errno; - if(dir == NULL) return(NULL); - return(dir); + if(dir == NULL) + return NULL; + return dir; } char *read_dir(void *stream, unsigned long long *pos, @@ -125,11 +128,12 @@ char *read_dir(void *stream, unsigned long long *pos, seekdir(dir, *pos); ent = readdir(dir); - if(ent == NULL) return(NULL); + if(ent == NULL) + return NULL; *len_out = strlen(ent->d_name); *ino_out = ent->d_ino; *pos = telldir(dir); - return(ent->d_name); + return ent->d_name; } int read_file(int fd, unsigned long long *offset, char *buf, int len) @@ -137,9 +141,10 @@ int read_file(int fd, unsigned long long *offset, char *buf, int len) int n; n = pread64(fd, buf, len, *offset); - if(n < 0) return(-errno); + if(n < 0) + return -errno; *offset += n; - return(n); + return n; } int write_file(int fd, unsigned long long *offset, const char *buf, int len) @@ -147,9 +152,10 @@ int write_file(int fd, unsigned long long *offset, const char *buf, int len) int n; n = pwrite64(fd, buf, len, *offset); - if(n < 0) return(-errno); + if(n < 0) + return -errno; *offset += n; - return(n); + return n; } int lseek_file(int fd, long long offset, int whence) @@ -158,8 +164,8 @@ int lseek_file(int fd, long long offset, int whence) ret = lseek64(fd, offset, whence); if(ret < 0) - return(-errno); - return(0); + return -errno; + return 0; } int fsync_file(int fd, int datasync) @@ -202,8 +208,8 @@ int file_create(char *name, int ur, int uw, int ux, int gr, mode |= ox ? S_IXOTH : 0; fd = open64(name, O_CREAT | O_RDWR, mode); if(fd < 0) - return(-errno); - return(fd); + return -errno; + return fd; } int set_attr(const char *file, struct hostfs_iattr *attrs, int fd) @@ -217,31 +223,31 @@ int set_attr(const char *file, struct hostfs_iattr *attrs, int fd) if (fchmod(fd, attrs->ia_mode) != 0) return (-errno); } else if (chmod(file, attrs->ia_mode) != 0) { - return (-errno); + return -errno; } } if (attrs->ia_valid & HOSTFS_ATTR_UID) { if (fd >= 0) { if (fchown(fd, attrs->ia_uid, -1)) - return (-errno); + return -errno; } else if(chown(file, attrs->ia_uid, -1)) { - return (-errno); + return -errno; } } if (attrs->ia_valid & HOSTFS_ATTR_GID) { if (fd >= 0) { if (fchown(fd, -1, attrs->ia_gid)) - return (-errno); + return -errno; } else if (chown(file, -1, attrs->ia_gid)) { - return (-errno); + return -errno; } } if (attrs->ia_valid & HOSTFS_ATTR_SIZE) { if (fd >= 0) { if (ftruncate(fd, attrs->ia_size)) - return (-errno); + return -errno; } else if (truncate(file, attrs->ia_size)) { - return (-errno); + return -errno; } } @@ -271,9 +277,9 @@ int set_attr(const char *file, struct hostfs_iattr *attrs, int fd) if (fd >= 0) { if (futimes(fd, times) != 0) - return (-errno); + return -errno; } else if (utimes(file, times) != 0) { - return (-errno); + return -errno; } } @@ -282,9 +288,10 @@ int set_attr(const char *file, struct hostfs_iattr *attrs, int fd) err = stat_file(file, NULL, NULL, NULL, NULL, NULL, NULL, &attrs->ia_atime, &attrs->ia_mtime, NULL, NULL, NULL, fd); - if(err != 0) return(err); + if(err != 0) + return err; } - return(0); + return 0; } int make_symlink(const char *from, const char *to) @@ -292,8 +299,9 @@ int make_symlink(const char *from, const char *to) int err; err = symlink(to, from); - if(err) return(-errno); - return(0); + if(err) + return -errno; + return 0; } int unlink_file(const char *file) @@ -301,8 +309,9 @@ int unlink_file(const char *file) int err; err = unlink(file); - if(err) return(-errno); - return(0); + if(err) + return -errno; + return 0; } int do_mkdir(const char *file, int mode) @@ -310,8 +319,9 @@ int do_mkdir(const char *file, int mode) int err; err = mkdir(file, mode); - if(err) return(-errno); - return(0); + if(err) + return -errno; + return 0; } int do_rmdir(const char *file) @@ -319,8 +329,9 @@ int do_rmdir(const char *file) int err; err = rmdir(file); - if(err) return(-errno); - return(0); + if(err) + return -errno; + return 0; } int do_mknod(const char *file, int mode, unsigned int major, unsigned int minor) @@ -328,8 +339,9 @@ int do_mknod(const char *file, int mode, unsigned int major, unsigned int minor) int err; err = mknod(file, mode, makedev(major, minor)); - if(err) return(-errno); - return(0); + if(err) + return -errno; + return 0; } int link_file(const char *to, const char *from) @@ -337,8 +349,9 @@ int link_file(const char *to, const char *from) int err; err = link(to, from); - if(err) return(-errno); - return(0); + if(err) + return -errno; + return 0; } int do_readlink(char *file, char *buf, int size) @@ -347,10 +360,10 @@ int do_readlink(char *file, char *buf, int size) n = readlink(file, buf, size); if(n < 0) - return(-errno); + return -errno; if(n < size) buf[n] = '\0'; - return(n); + return n; } int rename_file(char *from, char *to) @@ -358,8 +371,9 @@ int rename_file(char *from, char *to) int err; err = rename(from, to); - if(err < 0) return(-errno); - return(0); + if(err < 0) + return -errno; + return 0; } int do_statfs(char *root, long *bsize_out, long long *blocks_out, @@ -372,7 +386,9 @@ int do_statfs(char *root, long *bsize_out, long long *blocks_out, int err; err = statfs64(root, &buf); - if(err < 0) return(-errno); + if(err < 0) + return -errno; + *bsize_out = buf.f_bsize; *blocks_out = buf.f_blocks; *bfree_out = buf.f_bfree; @@ -388,16 +404,5 @@ int do_statfs(char *root, long *bsize_out, long long *blocks_out, spare_out[2] = buf.f_spare[2]; spare_out[3] = buf.f_spare[3]; spare_out[4] = buf.f_spare[4]; - return(0); + return 0; } - -/* - * Overrides for Emacs so that we follow Linus's tabbing style. - * Emacs will notice this stuff at the end of the file and automatically - * adjust the settings for this buffer only. This must remain at the end - * of the file. - * --------------------------------------------------------------------------- - * Local variables: - * c-file-style: "linux" - * End: - */ |