Commit f1adc05e authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

uml: hostfs style fixes

hostfs needed some style goodness.
Signed-off-by: default avatarJeff Dike <jdike@linux.intel.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5822b7fa
...@@ -87,14 +87,3 @@ extern int do_statfs(char *root, long *bsize_out, long long *blocks_out, ...@@ -87,14 +87,3 @@ extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
long *spare_out); long *spare_out);
#endif #endif
/*
* 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:
*/
This diff is collapsed.
/* /*
* Copyright (C) 2000 Jeff Dike (jdike@karaya.com) * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
* Licensed under the GPL * Licensed under the GPL
*/ */
...@@ -27,9 +27,9 @@ int stat_file(const char *path, unsigned long long *inode_out, int *mode_out, ...@@ -27,9 +27,9 @@ int stat_file(const char *path, unsigned long long *inode_out, int *mode_out,
if(fd >= 0) { if(fd >= 0) {
if (fstat64(fd, &buf) < 0) if (fstat64(fd, &buf) < 0)
return(-errno); return -errno;
} else if(lstat64(path, &buf) < 0) { } else if(lstat64(path, &buf) < 0) {
return(-errno); return -errno;
} }
if(inode_out != NULL) *inode_out = buf.st_ino; 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, ...@@ -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(blksize_out != NULL) *blksize_out = buf.st_blksize;
if(blocks_out != NULL) *blocks_out = buf.st_blocks; if(blocks_out != NULL) *blocks_out = buf.st_blocks;
return(0); return 0;
} }
int file_type(const char *path, int *maj, int *min) int file_type(const char *path, int *maj, int *min)
...@@ -60,7 +60,7 @@ 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; struct stat64 buf;
if(lstat64(path, &buf) < 0) if(lstat64(path, &buf) < 0)
return(-errno); return -errno;
/*We cannot pass rdev as is because glibc and the kernel disagree /*We cannot pass rdev as is because glibc and the kernel disagree
*about its definition.*/ *about its definition.*/
if(maj != NULL) if(maj != NULL)
...@@ -68,13 +68,13 @@ int file_type(const char *path, int *maj, int *min) ...@@ -68,13 +68,13 @@ int file_type(const char *path, int *maj, int *min)
if(min != NULL) if(min != NULL)
*min = minor(buf.st_rdev); *min = minor(buf.st_rdev);
if(S_ISDIR(buf.st_mode)) return(OS_TYPE_DIR); if(S_ISDIR(buf.st_mode)) return OS_TYPE_DIR;
else if(S_ISLNK(buf.st_mode)) return(OS_TYPE_SYMLINK); 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_ISCHR(buf.st_mode)) return OS_TYPE_CHARDEV;
else if(S_ISBLK(buf.st_mode)) return(OS_TYPE_BLOCKDEV); 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_ISFIFO(buf.st_mode))return OS_TYPE_FIFO;
else if(S_ISSOCK(buf.st_mode))return(OS_TYPE_SOCK); else if(S_ISSOCK(buf.st_mode))return OS_TYPE_SOCK;
else return(OS_TYPE_FILE); else return OS_TYPE_FILE;
} }
int access_file(char *path, int r, int w, int x) 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) ...@@ -84,8 +84,9 @@ int access_file(char *path, int r, int w, int x)
if(r) mode = R_OK; if(r) mode = R_OK;
if(w) mode |= W_OK; if(w) mode |= W_OK;
if(x) mode |= X_OK; if(x) mode |= X_OK;
if(access(path, mode) != 0) return(-errno); if(access(path, mode) != 0)
else return(0); return -errno;
else return 0;
} }
int open_file(char *path, int r, int w, int append) 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) ...@@ -103,8 +104,9 @@ int open_file(char *path, int r, int w, int append)
if(append) if(append)
mode |= O_APPEND; mode |= O_APPEND;
fd = open64(path, mode); fd = open64(path, mode);
if(fd < 0) return(-errno); if(fd < 0)
else return(fd); return -errno;
else return fd;
} }
void *open_dir(char *path, int *err_out) void *open_dir(char *path, int *err_out)
...@@ -113,8 +115,9 @@ void *open_dir(char *path, int *err_out) ...@@ -113,8 +115,9 @@ void *open_dir(char *path, int *err_out)
dir = opendir(path); dir = opendir(path);
*err_out = errno; *err_out = errno;
if(dir == NULL) return(NULL); if(dir == NULL)
return(dir); return NULL;
return dir;
} }
char *read_dir(void *stream, unsigned long long *pos, char *read_dir(void *stream, unsigned long long *pos,
...@@ -125,11 +128,12 @@ 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); seekdir(dir, *pos);
ent = readdir(dir); ent = readdir(dir);
if(ent == NULL) return(NULL); if(ent == NULL)
return NULL;
*len_out = strlen(ent->d_name); *len_out = strlen(ent->d_name);
*ino_out = ent->d_ino; *ino_out = ent->d_ino;
*pos = telldir(dir); *pos = telldir(dir);
return(ent->d_name); return ent->d_name;
} }
int read_file(int fd, unsigned long long *offset, char *buf, int len) 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) ...@@ -137,9 +141,10 @@ int read_file(int fd, unsigned long long *offset, char *buf, int len)
int n; int n;
n = pread64(fd, buf, len, *offset); n = pread64(fd, buf, len, *offset);
if(n < 0) return(-errno); if(n < 0)
return -errno;
*offset += n; *offset += n;
return(n); return n;
} }
int write_file(int fd, unsigned long long *offset, const char *buf, int len) 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) ...@@ -147,9 +152,10 @@ int write_file(int fd, unsigned long long *offset, const char *buf, int len)
int n; int n;
n = pwrite64(fd, buf, len, *offset); n = pwrite64(fd, buf, len, *offset);
if(n < 0) return(-errno); if(n < 0)
return -errno;
*offset += n; *offset += n;
return(n); return n;
} }
int lseek_file(int fd, long long offset, int whence) int lseek_file(int fd, long long offset, int whence)
...@@ -158,8 +164,8 @@ 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); ret = lseek64(fd, offset, whence);
if(ret < 0) if(ret < 0)
return(-errno); return -errno;
return(0); return 0;
} }
int fsync_file(int fd, int datasync) int fsync_file(int fd, int datasync)
...@@ -202,8 +208,8 @@ int file_create(char *name, int ur, int uw, int ux, int gr, ...@@ -202,8 +208,8 @@ int file_create(char *name, int ur, int uw, int ux, int gr,
mode |= ox ? S_IXOTH : 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;
return(fd); return fd;
} }
int set_attr(const char *file, struct hostfs_iattr *attrs, int 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) ...@@ -217,31 +223,31 @@ int set_attr(const char *file, struct hostfs_iattr *attrs, int fd)
if (fchmod(fd, attrs->ia_mode) != 0) if (fchmod(fd, attrs->ia_mode) != 0)
return (-errno); return (-errno);
} else if (chmod(file, attrs->ia_mode) != 0) { } else if (chmod(file, attrs->ia_mode) != 0) {
return (-errno); return -errno;
} }
} }
if (attrs->ia_valid & HOSTFS_ATTR_UID) { if (attrs->ia_valid & HOSTFS_ATTR_UID) {
if (fd >= 0) { if (fd >= 0) {
if (fchown(fd, attrs->ia_uid, -1)) if (fchown(fd, attrs->ia_uid, -1))
return (-errno); return -errno;
} else if(chown(file, attrs->ia_uid, -1)) { } else if(chown(file, attrs->ia_uid, -1)) {
return (-errno); return -errno;
} }
} }
if (attrs->ia_valid & HOSTFS_ATTR_GID) { if (attrs->ia_valid & HOSTFS_ATTR_GID) {
if (fd >= 0) { if (fd >= 0) {
if (fchown(fd, -1, attrs->ia_gid)) if (fchown(fd, -1, attrs->ia_gid))
return (-errno); return -errno;
} else if (chown(file, -1, attrs->ia_gid)) { } else if (chown(file, -1, attrs->ia_gid)) {
return (-errno); return -errno;
} }
} }
if (attrs->ia_valid & HOSTFS_ATTR_SIZE) { if (attrs->ia_valid & HOSTFS_ATTR_SIZE) {
if (fd >= 0) { if (fd >= 0) {
if (ftruncate(fd, attrs->ia_size)) if (ftruncate(fd, attrs->ia_size))
return (-errno); return -errno;
} else if (truncate(file, attrs->ia_size)) { } 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) ...@@ -271,9 +277,9 @@ int set_attr(const char *file, struct hostfs_iattr *attrs, int fd)
if (fd >= 0) { if (fd >= 0) {
if (futimes(fd, times) != 0) if (futimes(fd, times) != 0)
return (-errno); return -errno;
} else if (utimes(file, times) != 0) { } 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) ...@@ -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, err = stat_file(file, NULL, NULL, NULL, NULL, NULL, NULL,
&attrs->ia_atime, &attrs->ia_mtime, NULL, &attrs->ia_atime, &attrs->ia_mtime, NULL,
NULL, NULL, fd); 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) int make_symlink(const char *from, const char *to)
...@@ -292,8 +299,9 @@ int make_symlink(const char *from, const char *to) ...@@ -292,8 +299,9 @@ int make_symlink(const char *from, const char *to)
int err; int err;
err = symlink(to, from); err = symlink(to, from);
if(err) return(-errno); if(err)
return(0); return -errno;
return 0;
} }
int unlink_file(const char *file) int unlink_file(const char *file)
...@@ -301,8 +309,9 @@ int unlink_file(const char *file) ...@@ -301,8 +309,9 @@ int unlink_file(const char *file)
int err; int err;
err = unlink(file); err = unlink(file);
if(err) return(-errno); if(err)
return(0); return -errno;
return 0;
} }
int do_mkdir(const char *file, int mode) int do_mkdir(const char *file, int mode)
...@@ -310,8 +319,9 @@ int do_mkdir(const char *file, int mode) ...@@ -310,8 +319,9 @@ int do_mkdir(const char *file, int mode)
int err; int err;
err = mkdir(file, mode); err = mkdir(file, mode);
if(err) return(-errno); if(err)
return(0); return -errno;
return 0;
} }
int do_rmdir(const char *file) int do_rmdir(const char *file)
...@@ -319,8 +329,9 @@ int do_rmdir(const char *file) ...@@ -319,8 +329,9 @@ int do_rmdir(const char *file)
int err; int err;
err = rmdir(file); err = rmdir(file);
if(err) return(-errno); if(err)
return(0); return -errno;
return 0;
} }
int do_mknod(const char *file, int mode, unsigned int major, unsigned int minor) 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) ...@@ -328,8 +339,9 @@ int do_mknod(const char *file, int mode, unsigned int major, unsigned int minor)
int err; int err;
err = mknod(file, mode, makedev(major, minor)); err = mknod(file, mode, makedev(major, minor));
if(err) return(-errno); if(err)
return(0); return -errno;
return 0;
} }
int link_file(const char *to, const char *from) int link_file(const char *to, const char *from)
...@@ -337,8 +349,9 @@ int link_file(const char *to, const char *from) ...@@ -337,8 +349,9 @@ int link_file(const char *to, const char *from)
int err; int err;
err = link(to, from); err = link(to, from);
if(err) return(-errno); if(err)
return(0); return -errno;
return 0;
} }
int do_readlink(char *file, char *buf, int size) int do_readlink(char *file, char *buf, int size)
...@@ -347,10 +360,10 @@ 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); n = readlink(file, buf, size);
if(n < 0) if(n < 0)
return(-errno); return -errno;
if(n < size) if(n < size)
buf[n] = '\0'; buf[n] = '\0';
return(n); return n;
} }
int rename_file(char *from, char *to) int rename_file(char *from, char *to)
...@@ -358,8 +371,9 @@ int rename_file(char *from, char *to) ...@@ -358,8 +371,9 @@ int rename_file(char *from, char *to)
int err; int err;
err = rename(from, to); err = rename(from, to);
if(err < 0) return(-errno); if(err < 0)
return(0); return -errno;
return 0;
} }
int do_statfs(char *root, long *bsize_out, long long *blocks_out, 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, ...@@ -372,7 +386,9 @@ int do_statfs(char *root, long *bsize_out, long long *blocks_out,
int err; int err;
err = statfs64(root, &buf); err = statfs64(root, &buf);
if(err < 0) return(-errno); if(err < 0)
return -errno;
*bsize_out = buf.f_bsize; *bsize_out = buf.f_bsize;
*blocks_out = buf.f_blocks; *blocks_out = buf.f_blocks;
*bfree_out = buf.f_bfree; *bfree_out = buf.f_bfree;
...@@ -388,16 +404,5 @@ int do_statfs(char *root, long *bsize_out, long long *blocks_out, ...@@ -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[2] = buf.f_spare[2];
spare_out[3] = buf.f_spare[3]; spare_out[3] = buf.f_spare[3];
spare_out[4] = buf.f_spare[4]; 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:
*/
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