diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-05-08 03:23:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 14:14:57 -0400 |
commit | f1adc05e77383017bc63ea9c48ba217da76682b8 (patch) | |
tree | e58290483a62ce846bb63d2b965952bd038707bb /fs/hostfs/hostfs_user.c | |
parent | 5822b7faca709c03a59c2929005bfe9caffe6592 (diff) |
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 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) | 2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -27,9 +27,9 @@ int stat_file(const char *path, unsigned long long *inode_out, int *mode_out, | |||
27 | 27 | ||
28 | if(fd >= 0) { | 28 | if(fd >= 0) { |
29 | if (fstat64(fd, &buf) < 0) | 29 | if (fstat64(fd, &buf) < 0) |
30 | return(-errno); | 30 | return -errno; |
31 | } else if(lstat64(path, &buf) < 0) { | 31 | } else if(lstat64(path, &buf) < 0) { |
32 | return(-errno); | 32 | return -errno; |
33 | } | 33 | } |
34 | 34 | ||
35 | if(inode_out != NULL) *inode_out = buf.st_ino; | 35 | 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 | } | 52 | } |
53 | if(blksize_out != NULL) *blksize_out = buf.st_blksize; | 53 | if(blksize_out != NULL) *blksize_out = buf.st_blksize; |
54 | if(blocks_out != NULL) *blocks_out = buf.st_blocks; | 54 | if(blocks_out != NULL) *blocks_out = buf.st_blocks; |
55 | return(0); | 55 | return 0; |
56 | } | 56 | } |
57 | 57 | ||
58 | int file_type(const char *path, int *maj, int *min) | 58 | 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 | struct stat64 buf; | 60 | struct stat64 buf; |
61 | 61 | ||
62 | if(lstat64(path, &buf) < 0) | 62 | if(lstat64(path, &buf) < 0) |
63 | return(-errno); | 63 | return -errno; |
64 | /*We cannot pass rdev as is because glibc and the kernel disagree | 64 | /*We cannot pass rdev as is because glibc and the kernel disagree |
65 | *about its definition.*/ | 65 | *about its definition.*/ |
66 | if(maj != NULL) | 66 | if(maj != NULL) |
@@ -68,13 +68,13 @@ int file_type(const char *path, int *maj, int *min) | |||
68 | if(min != NULL) | 68 | if(min != NULL) |
69 | *min = minor(buf.st_rdev); | 69 | *min = minor(buf.st_rdev); |
70 | 70 | ||
71 | if(S_ISDIR(buf.st_mode)) return(OS_TYPE_DIR); | 71 | if(S_ISDIR(buf.st_mode)) return OS_TYPE_DIR; |
72 | else if(S_ISLNK(buf.st_mode)) return(OS_TYPE_SYMLINK); | 72 | else if(S_ISLNK(buf.st_mode)) return OS_TYPE_SYMLINK; |
73 | else if(S_ISCHR(buf.st_mode)) return(OS_TYPE_CHARDEV); | 73 | else if(S_ISCHR(buf.st_mode)) return OS_TYPE_CHARDEV; |
74 | else if(S_ISBLK(buf.st_mode)) return(OS_TYPE_BLOCKDEV); | 74 | else if(S_ISBLK(buf.st_mode)) return OS_TYPE_BLOCKDEV; |
75 | else if(S_ISFIFO(buf.st_mode))return(OS_TYPE_FIFO); | 75 | else if(S_ISFIFO(buf.st_mode))return OS_TYPE_FIFO; |
76 | else if(S_ISSOCK(buf.st_mode))return(OS_TYPE_SOCK); | 76 | else if(S_ISSOCK(buf.st_mode))return OS_TYPE_SOCK; |
77 | else return(OS_TYPE_FILE); | 77 | else return OS_TYPE_FILE; |
78 | } | 78 | } |
79 | 79 | ||
80 | int access_file(char *path, int r, int w, int x) | 80 | 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 | if(r) mode = R_OK; | 84 | if(r) mode = R_OK; |
85 | if(w) mode |= W_OK; | 85 | if(w) mode |= W_OK; |
86 | if(x) mode |= X_OK; | 86 | if(x) mode |= X_OK; |
87 | if(access(path, mode) != 0) return(-errno); | 87 | if(access(path, mode) != 0) |
88 | else return(0); | 88 | return -errno; |
89 | else return 0; | ||
89 | } | 90 | } |
90 | 91 | ||
91 | int open_file(char *path, int r, int w, int append) | 92 | 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 | if(append) | 104 | if(append) |
104 | mode |= O_APPEND; | 105 | mode |= O_APPEND; |
105 | fd = open64(path, mode); | 106 | fd = open64(path, mode); |
106 | if(fd < 0) return(-errno); | 107 | if(fd < 0) |
107 | else return(fd); | 108 | return -errno; |
109 | else return fd; | ||
108 | } | 110 | } |
109 | 111 | ||
110 | void *open_dir(char *path, int *err_out) | 112 | void *open_dir(char *path, int *err_out) |
@@ -113,8 +115,9 @@ void *open_dir(char *path, int *err_out) | |||
113 | 115 | ||
114 | dir = opendir(path); | 116 | dir = opendir(path); |
115 | *err_out = errno; | 117 | *err_out = errno; |
116 | if(dir == NULL) return(NULL); | 118 | if(dir == NULL) |
117 | return(dir); | 119 | return NULL; |
120 | return dir; | ||
118 | } | 121 | } |
119 | 122 | ||
120 | char *read_dir(void *stream, unsigned long long *pos, | 123 | char *read_dir(void *stream, unsigned long long *pos, |
@@ -125,11 +128,12 @@ char *read_dir(void *stream, unsigned long long *pos, | |||
125 | 128 | ||
126 | seekdir(dir, *pos); | 129 | seekdir(dir, *pos); |
127 | ent = readdir(dir); | 130 | ent = readdir(dir); |
128 | if(ent == NULL) return(NULL); | 131 | if(ent == NULL) |
132 | return NULL; | ||
129 | *len_out = strlen(ent->d_name); | 133 | *len_out = strlen(ent->d_name); |
130 | *ino_out = ent->d_ino; | 134 | *ino_out = ent->d_ino; |
131 | *pos = telldir(dir); | 135 | *pos = telldir(dir); |
132 | return(ent->d_name); | 136 | return ent->d_name; |
133 | } | 137 | } |
134 | 138 | ||
135 | int read_file(int fd, unsigned long long *offset, char *buf, int len) | 139 | 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 | int n; | 141 | int n; |
138 | 142 | ||
139 | n = pread64(fd, buf, len, *offset); | 143 | n = pread64(fd, buf, len, *offset); |
140 | if(n < 0) return(-errno); | 144 | if(n < 0) |
145 | return -errno; | ||
141 | *offset += n; | 146 | *offset += n; |
142 | return(n); | 147 | return n; |
143 | } | 148 | } |
144 | 149 | ||
145 | int write_file(int fd, unsigned long long *offset, const char *buf, int len) | 150 | 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 | int n; | 152 | int n; |
148 | 153 | ||
149 | n = pwrite64(fd, buf, len, *offset); | 154 | n = pwrite64(fd, buf, len, *offset); |
150 | if(n < 0) return(-errno); | 155 | if(n < 0) |
156 | return -errno; | ||
151 | *offset += n; | 157 | *offset += n; |
152 | return(n); | 158 | return n; |
153 | } | 159 | } |
154 | 160 | ||
155 | int lseek_file(int fd, long long offset, int whence) | 161 | 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 | 164 | ||
159 | ret = lseek64(fd, offset, whence); | 165 | ret = lseek64(fd, offset, whence); |
160 | if(ret < 0) | 166 | if(ret < 0) |
161 | return(-errno); | 167 | return -errno; |
162 | return(0); | 168 | return 0; |
163 | } | 169 | } |
164 | 170 | ||
165 | int fsync_file(int fd, int datasync) | 171 | 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 | mode |= ox ? S_IXOTH : 0; | 208 | mode |= ox ? S_IXOTH : 0; |
203 | fd = open64(name, O_CREAT | O_RDWR, mode); | 209 | fd = open64(name, O_CREAT | O_RDWR, mode); |
204 | if(fd < 0) | 210 | if(fd < 0) |
205 | return(-errno); | 211 | return -errno; |
206 | return(fd); | 212 | return fd; |
207 | } | 213 | } |
208 | 214 | ||
209 | int set_attr(const char *file, struct hostfs_iattr *attrs, int fd) | 215 | 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 | if (fchmod(fd, attrs->ia_mode) != 0) | 223 | if (fchmod(fd, attrs->ia_mode) != 0) |
218 | return (-errno); | 224 | return (-errno); |
219 | } else if (chmod(file, attrs->ia_mode) != 0) { | 225 | } else if (chmod(file, attrs->ia_mode) != 0) { |
220 | return (-errno); | 226 | return -errno; |
221 | } | 227 | } |
222 | } | 228 | } |
223 | if (attrs->ia_valid & HOSTFS_ATTR_UID) { | 229 | if (attrs->ia_valid & HOSTFS_ATTR_UID) { |
224 | if (fd >= 0) { | 230 | if (fd >= 0) { |
225 | if (fchown(fd, attrs->ia_uid, -1)) | 231 | if (fchown(fd, attrs->ia_uid, -1)) |
226 | return (-errno); | 232 | return -errno; |
227 | } else if(chown(file, attrs->ia_uid, -1)) { | 233 | } else if(chown(file, attrs->ia_uid, -1)) { |
228 | return (-errno); | 234 | return -errno; |
229 | } | 235 | } |
230 | } | 236 | } |
231 | if (attrs->ia_valid & HOSTFS_ATTR_GID) { | 237 | if (attrs->ia_valid & HOSTFS_ATTR_GID) { |
232 | if (fd >= 0) { | 238 | if (fd >= 0) { |
233 | if (fchown(fd, -1, attrs->ia_gid)) | 239 | if (fchown(fd, -1, attrs->ia_gid)) |
234 | return (-errno); | 240 | return -errno; |
235 | } else if (chown(file, -1, attrs->ia_gid)) { | 241 | } else if (chown(file, -1, attrs->ia_gid)) { |
236 | return (-errno); | 242 | return -errno; |
237 | } | 243 | } |
238 | } | 244 | } |
239 | if (attrs->ia_valid & HOSTFS_ATTR_SIZE) { | 245 | if (attrs->ia_valid & HOSTFS_ATTR_SIZE) { |
240 | if (fd >= 0) { | 246 | if (fd >= 0) { |
241 | if (ftruncate(fd, attrs->ia_size)) | 247 | if (ftruncate(fd, attrs->ia_size)) |
242 | return (-errno); | 248 | return -errno; |
243 | } else if (truncate(file, attrs->ia_size)) { | 249 | } else if (truncate(file, attrs->ia_size)) { |
244 | return (-errno); | 250 | return -errno; |
245 | } | 251 | } |
246 | } | 252 | } |
247 | 253 | ||
@@ -271,9 +277,9 @@ int set_attr(const char *file, struct hostfs_iattr *attrs, int fd) | |||
271 | 277 | ||
272 | if (fd >= 0) { | 278 | if (fd >= 0) { |
273 | if (futimes(fd, times) != 0) | 279 | if (futimes(fd, times) != 0) |
274 | return (-errno); | 280 | return -errno; |
275 | } else if (utimes(file, times) != 0) { | 281 | } else if (utimes(file, times) != 0) { |
276 | return (-errno); | 282 | return -errno; |
277 | } | 283 | } |
278 | } | 284 | } |
279 | 285 | ||
@@ -282,9 +288,10 @@ int set_attr(const char *file, struct hostfs_iattr *attrs, int fd) | |||
282 | err = stat_file(file, NULL, NULL, NULL, NULL, NULL, NULL, | 288 | err = stat_file(file, NULL, NULL, NULL, NULL, NULL, NULL, |
283 | &attrs->ia_atime, &attrs->ia_mtime, NULL, | 289 | &attrs->ia_atime, &attrs->ia_mtime, NULL, |
284 | NULL, NULL, fd); | 290 | NULL, NULL, fd); |
285 | if(err != 0) return(err); | 291 | if(err != 0) |
292 | return err; | ||
286 | } | 293 | } |
287 | return(0); | 294 | return 0; |
288 | } | 295 | } |
289 | 296 | ||
290 | int make_symlink(const char *from, const char *to) | 297 | int make_symlink(const char *from, const char *to) |
@@ -292,8 +299,9 @@ int make_symlink(const char *from, const char *to) | |||
292 | int err; | 299 | int err; |
293 | 300 | ||
294 | err = symlink(to, from); | 301 | err = symlink(to, from); |
295 | if(err) return(-errno); | 302 | if(err) |
296 | return(0); | 303 | return -errno; |
304 | return 0; | ||
297 | } | 305 | } |
298 | 306 | ||
299 | int unlink_file(const char *file) | 307 | int unlink_file(const char *file) |
@@ -301,8 +309,9 @@ int unlink_file(const char *file) | |||
301 | int err; | 309 | int err; |
302 | 310 | ||
303 | err = unlink(file); | 311 | err = unlink(file); |
304 | if(err) return(-errno); | 312 | if(err) |
305 | return(0); | 313 | return -errno; |
314 | return 0; | ||
306 | } | 315 | } |
307 | 316 | ||
308 | int do_mkdir(const char *file, int mode) | 317 | int do_mkdir(const char *file, int mode) |
@@ -310,8 +319,9 @@ int do_mkdir(const char *file, int mode) | |||
310 | int err; | 319 | int err; |
311 | 320 | ||
312 | err = mkdir(file, mode); | 321 | err = mkdir(file, mode); |
313 | if(err) return(-errno); | 322 | if(err) |
314 | return(0); | 323 | return -errno; |
324 | return 0; | ||
315 | } | 325 | } |
316 | 326 | ||
317 | int do_rmdir(const char *file) | 327 | int do_rmdir(const char *file) |
@@ -319,8 +329,9 @@ int do_rmdir(const char *file) | |||
319 | int err; | 329 | int err; |
320 | 330 | ||
321 | err = rmdir(file); | 331 | err = rmdir(file); |
322 | if(err) return(-errno); | 332 | if(err) |
323 | return(0); | 333 | return -errno; |
334 | return 0; | ||
324 | } | 335 | } |
325 | 336 | ||
326 | int do_mknod(const char *file, int mode, unsigned int major, unsigned int minor) | 337 | 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 | int err; | 339 | int err; |
329 | 340 | ||
330 | err = mknod(file, mode, makedev(major, minor)); | 341 | err = mknod(file, mode, makedev(major, minor)); |
331 | if(err) return(-errno); | 342 | if(err) |
332 | return(0); | 343 | return -errno; |
344 | return 0; | ||
333 | } | 345 | } |
334 | 346 | ||
335 | int link_file(const char *to, const char *from) | 347 | int link_file(const char *to, const char *from) |
@@ -337,8 +349,9 @@ int link_file(const char *to, const char *from) | |||
337 | int err; | 349 | int err; |
338 | 350 | ||
339 | err = link(to, from); | 351 | err = link(to, from); |
340 | if(err) return(-errno); | 352 | if(err) |
341 | return(0); | 353 | return -errno; |
354 | return 0; | ||
342 | } | 355 | } |
343 | 356 | ||
344 | int do_readlink(char *file, char *buf, int size) | 357 | int do_readlink(char *file, char *buf, int size) |
@@ -347,10 +360,10 @@ int do_readlink(char *file, char *buf, int size) | |||
347 | 360 | ||
348 | n = readlink(file, buf, size); | 361 | n = readlink(file, buf, size); |
349 | if(n < 0) | 362 | if(n < 0) |
350 | return(-errno); | 363 | return -errno; |
351 | if(n < size) | 364 | if(n < size) |
352 | buf[n] = '\0'; | 365 | buf[n] = '\0'; |
353 | return(n); | 366 | return n; |
354 | } | 367 | } |
355 | 368 | ||
356 | int rename_file(char *from, char *to) | 369 | int rename_file(char *from, char *to) |
@@ -358,8 +371,9 @@ int rename_file(char *from, char *to) | |||
358 | int err; | 371 | int err; |
359 | 372 | ||
360 | err = rename(from, to); | 373 | err = rename(from, to); |
361 | if(err < 0) return(-errno); | 374 | if(err < 0) |
362 | return(0); | 375 | return -errno; |
376 | return 0; | ||
363 | } | 377 | } |
364 | 378 | ||
365 | int do_statfs(char *root, long *bsize_out, long long *blocks_out, | 379 | 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 | int err; | 386 | int err; |
373 | 387 | ||
374 | err = statfs64(root, &buf); | 388 | err = statfs64(root, &buf); |
375 | if(err < 0) return(-errno); | 389 | if(err < 0) |
390 | return -errno; | ||
391 | |||
376 | *bsize_out = buf.f_bsize; | 392 | *bsize_out = buf.f_bsize; |
377 | *blocks_out = buf.f_blocks; | 393 | *blocks_out = buf.f_blocks; |
378 | *bfree_out = buf.f_bfree; | 394 | *bfree_out = buf.f_bfree; |
@@ -388,16 +404,5 @@ int do_statfs(char *root, long *bsize_out, long long *blocks_out, | |||
388 | spare_out[2] = buf.f_spare[2]; | 404 | spare_out[2] = buf.f_spare[2]; |
389 | spare_out[3] = buf.f_spare[3]; | 405 | spare_out[3] = buf.f_spare[3]; |
390 | spare_out[4] = buf.f_spare[4]; | 406 | spare_out[4] = buf.f_spare[4]; |
391 | return(0); | 407 | return 0; |
392 | } | 408 | } |
393 | |||
394 | /* | ||
395 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
396 | * Emacs will notice this stuff at the end of the file and automatically | ||
397 | * adjust the settings for this buffer only. This must remain at the end | ||
398 | * of the file. | ||
399 | * --------------------------------------------------------------------------- | ||
400 | * Local variables: | ||
401 | * c-file-style: "linux" | ||
402 | * End: | ||
403 | */ | ||