Commit 84b3db04ca15a90273745e391462faf658b1e825

Authored by Jeff Dike
Committed by Linus Torvalds
1 parent baabd156e2

uml: fix hostfs style

Style fixes in hostfs.

Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 3 changed files with 202 additions and 172 deletions Side-by-side Diff

... ... @@ -3,7 +3,8 @@
3 3  
4 4 #include "os.h"
5 5  
6   -/* These are exactly the same definitions as in fs.h, but the names are
  6 +/*
  7 + * These are exactly the same definitions as in fs.h, but the names are
7 8 * changed so that this file can be included in both kernel and user files.
8 9 */
9 10  
... ... @@ -21,7 +22,8 @@
21 22 #define HOSTFS_ATTR_FORCE 512 /* Not a change, but a change it */
22 23 #define HOSTFS_ATTR_ATTR_FLAG 1024
23 24  
24   -/* If you are very careful, you'll notice that these two are missing:
  25 +/*
  26 + * If you are very careful, you'll notice that these two are missing:
25 27 *
26 28 * #define ATTR_KILL_SUID 2048
27 29 * #define ATTR_KILL_SGID 4096
... ... @@ -76,7 +78,8 @@
76 78 extern int unlink_file(const char *file);
77 79 extern int do_mkdir(const char *file, int mode);
78 80 extern int do_rmdir(const char *file);
79   -extern int do_mknod(const char *file, int mode, unsigned int major, unsigned int minor);
  81 +extern int do_mknod(const char *file, int mode, unsigned int major,
  82 + unsigned int minor);
80 83 extern int link_file(const char *from, const char *to);
81 84 extern int do_readlink(char *file, char *buf, int size);
82 85 extern int rename_file(char *from, char *to);
fs/hostfs/hostfs_kern.c
... ... @@ -6,21 +6,14 @@
6 6 * 2003-02-10 Petr Baudis <pasky@ucw.cz>
7 7 */
8 8  
9   -#include <linux/stddef.h>
10 9 #include <linux/fs.h>
11 10 #include <linux/module.h>
12   -#include <linux/init.h>
13   -#include <linux/slab.h>
  11 +#include <linux/mm.h>
14 12 #include <linux/pagemap.h>
15   -#include <linux/blkdev.h>
16   -#include <linux/list.h>
17 13 #include <linux/statfs.h>
18   -#include <linux/kdev_t.h>
19   -#include <asm/uaccess.h>
20 14 #include "hostfs.h"
21   -#include "kern_util.h"
22   -#include "kern.h"
23 15 #include "init.h"
  16 +#include "kern.h"
24 17  
25 18 struct hostfs_inode_info {
26 19 char *host_filename;
27 20  
28 21  
29 22  
30 23  
... ... @@ -61,18 +54,18 @@
61 54 char *ptr;
62 55  
63 56 ptr = strchr(options, ',');
64   - if(ptr != NULL)
  57 + if (ptr != NULL)
65 58 *ptr++ = '\0';
66   - if(*options != '(*options != '\0')')
  59 + if (*options != '(*options != '\0')')
67 60 root_ino = options;
68 61  
69 62 options = ptr;
70   - while(options){
  63 + while (options) {
71 64 ptr = strchr(options, ',');
72   - if(ptr != NULL)
  65 + if (ptr != NULL)
73 66 *ptr++ = '\0';
74   - if(*options != '\0'){
75   - if(!strcmp(options, "append"))
  67 + if (*options != '\0') {
  68 + if (!strcmp(options, "append"))
76 69 append = 1;
77 70 else printf("hostfs_args - unsupported option - %s\n",
78 71 options);
... ... @@ -102,7 +95,7 @@
102 95  
103 96 len = 0;
104 97 parent = dentry;
105   - while(parent->d_parent != parent){
  98 + while (parent->d_parent != parent) {
106 99 len += parent->d_name.len + 1;
107 100 parent = parent->d_parent;
108 101 }
109 102  
... ... @@ -110,12 +103,12 @@
110 103 root = HOSTFS_I(parent->d_inode)->host_filename;
111 104 len += strlen(root);
112 105 name = kmalloc(len + extra + 1, GFP_KERNEL);
113   - if(name == NULL)
  106 + if (name == NULL)
114 107 return NULL;
115 108  
116 109 name[len] = '\0';
117 110 parent = dentry;
118   - while(parent->d_parent != parent){
  111 + while (parent->d_parent != parent) {
119 112 len -= parent->d_name.len + 1;
120 113 name[len] = '/';
121 114 strncpy(&name[len + 1], parent->d_name.name,
... ... @@ -136,7 +129,8 @@
136 129  
137 130 static int read_name(struct inode *ino, char *name)
138 131 {
139   - /* The non-int inode fields are copied into ints by stat_file and
  132 + /*
  133 + * The non-int inode fields are copied into ints by stat_file and
140 134 * then copied into the inode because passing the actual pointers
141 135 * in and having them treated as int * breaks on big-endian machines
142 136 */
... ... @@ -149,7 +143,7 @@
149 143 err = stat_file(name, &i_ino, &i_mode, &i_nlink, &ino->i_uid,
150 144 &ino->i_gid, &i_size, &ino->i_atime, &ino->i_mtime,
151 145 &ino->i_ctime, &i_blksize, &i_blocks, -1);
152   - if(err)
  146 + if (err)
153 147 return err;
154 148  
155 149 ino->i_ino = i_ino;
156 150  
157 151  
158 152  
159 153  
160 154  
161 155  
... ... @@ -166,33 +160,33 @@
166 160 char *name, *resolved, *end;
167 161  
168 162 len = 64;
169   - while(1){
  163 + while (1) {
170 164 n = -ENOMEM;
171 165 name = kmalloc(len, GFP_KERNEL);
172   - if(name == NULL)
  166 + if (name == NULL)
173 167 goto out;
174 168  
175 169 n = do_readlink(link, name, len);
176   - if(n < len)
  170 + if (n < len)
177 171 break;
178 172 len *= 2;
179 173 kfree(name);
180 174 }
181   - if(n < 0)
  175 + if (n < 0)
182 176 goto out_free;
183 177  
184   - if(*name == '/')
  178 + if (*name == '/')
185 179 return name;
186 180  
187 181 end = strrchr(link, '/');
188   - if(end == NULL)
  182 + if (end == NULL)
189 183 return name;
190 184  
191 185 *(end + 1) = '\0';
192 186 len = strlen(link) + strlen(name) + 1;
193 187  
194 188 resolved = kmalloc(len, GFP_KERNEL);
195   - if(resolved == NULL){
  189 + if (resolved == NULL) {
196 190 n = -ENOMEM;
197 191 goto out_free;
198 192 }
199 193  
200 194  
201 195  
202 196  
... ... @@ -213,20 +207,21 @@
213 207 char *name;
214 208 int err = 0;
215 209  
216   - /* Unfortunately, we are called from iget() when we don't have a dentry
  210 + /*
  211 + * Unfortunately, we are called from iget() when we don't have a dentry
217 212 * allocated yet.
218 213 */
219   - if(list_empty(&ino->i_dentry))
  214 + if (list_empty(&ino->i_dentry))
220 215 goto out;
221 216  
222 217 err = -ENOMEM;
223 218 name = inode_name(ino, 0);
224   - if(name == NULL)
  219 + if (name == NULL)
225 220 goto out;
226 221  
227   - if(file_type(name, NULL, NULL) == OS_TYPE_SYMLINK){
  222 + if (file_type(name, NULL, NULL) == OS_TYPE_SYMLINK) {
228 223 name = follow_link(name);
229   - if(IS_ERR(name)){
  224 + if (IS_ERR(name)) {
230 225 err = PTR_ERR(name);
231 226 goto out;
232 227 }
... ... @@ -240,7 +235,8 @@
240 235  
241 236 int hostfs_statfs(struct dentry *dentry, struct kstatfs *sf)
242 237 {
243   - /* do_statfs uses struct statfs64 internally, but the linux kernel
  238 + /*
  239 + * do_statfs uses struct statfs64 internally, but the linux kernel
244 240 * struct statfs still has 32-bit versions for most of these fields,
245 241 * so we convert them here
246 242 */
... ... @@ -255,7 +251,7 @@
255 251 &sf->f_bsize, &f_blocks, &f_bfree, &f_bavail, &f_files,
256 252 &f_ffree, &sf->f_fsid, sizeof(sf->f_fsid),
257 253 &sf->f_namelen, sf->f_spare);
258   - if(err)
  254 + if (err)
259 255 return err;
260 256 sf->f_blocks = f_blocks;
261 257 sf->f_bfree = f_bfree;
... ... @@ -271,7 +267,7 @@
271 267 struct hostfs_inode_info *hi;
272 268  
273 269 hi = kmalloc(sizeof(*hi), GFP_KERNEL);
274   - if(hi == NULL)
  270 + if (hi == NULL)
275 271 return NULL;
276 272  
277 273 *hi = ((struct hostfs_inode_info) { .host_filename = NULL,
... ... @@ -284,7 +280,7 @@
284 280 static void hostfs_delete_inode(struct inode *inode)
285 281 {
286 282 truncate_inode_pages(&inode->i_data, 0);
287   - if(HOSTFS_I(inode)->fd != -1) {
  283 + if (HOSTFS_I(inode)->fd != -1) {
288 284 close_file(&HOSTFS_I(inode)->fd);
289 285 HOSTFS_I(inode)->fd = -1;
290 286 }
... ... @@ -295,9 +291,11 @@
295 291 {
296 292 kfree(HOSTFS_I(inode)->host_filename);
297 293  
298   - /*XXX: This should not happen, probably. The check is here for
299   - * additional safety.*/
300   - if(HOSTFS_I(inode)->fd != -1) {
  294 + /*
  295 + * XXX: This should not happen, probably. The check is here for
  296 + * additional safety.
  297 + */
  298 + if (HOSTFS_I(inode)->fd != -1) {
301 299 close_file(&HOSTFS_I(inode)->fd);
302 300 printk(KERN_DEBUG "Closing host fd in .destroy_inode\n");
303 301 }
304 302  
305 303  
306 304  
... ... @@ -327,17 +325,17 @@
327 325 int error, len;
328 326  
329 327 name = dentry_name(file->f_path.dentry, 0);
330   - if(name == NULL)
  328 + if (name == NULL)
331 329 return -ENOMEM;
332 330 dir = open_dir(name, &error);
333 331 kfree(name);
334   - if(dir == NULL)
  332 + if (dir == NULL)
335 333 return -error;
336 334 next = file->f_pos;
337   - while((name = read_dir(dir, &next, &ino, &len)) != NULL){
  335 + while ((name = read_dir(dir, &next, &ino, &len)) != NULL) {
338 336 error = (*filldir)(ent, name, len, file->f_pos,
339 337 ino, DT_UNKNOWN);
340   - if(error) break;
  338 + if (error) break;
341 339 file->f_pos = next;
342 340 }
343 341 close_dir(dir);
344 342  
345 343  
346 344  
347 345  
348 346  
349 347  
350 348  
... ... @@ -350,32 +348,33 @@
350 348 int mode = 0, r = 0, w = 0, fd;
351 349  
352 350 mode = file->f_mode & (FMODE_READ | FMODE_WRITE);
353   - if((mode & HOSTFS_I(ino)->mode) == mode)
  351 + if ((mode & HOSTFS_I(ino)->mode) == mode)
354 352 return 0;
355 353  
356   - /* The file may already have been opened, but with the wrong access,
  354 + /*
  355 + * The file may already have been opened, but with the wrong access,
357 356 * so this resets things and reopens the file with the new access.
358 357 */
359   - if(HOSTFS_I(ino)->fd != -1){
  358 + if (HOSTFS_I(ino)->fd != -1) {
360 359 close_file(&HOSTFS_I(ino)->fd);
361 360 HOSTFS_I(ino)->fd = -1;
362 361 }
363 362  
364 363 HOSTFS_I(ino)->mode |= mode;
365   - if(HOSTFS_I(ino)->mode & FMODE_READ)
  364 + if (HOSTFS_I(ino)->mode & FMODE_READ)
366 365 r = 1;
367   - if(HOSTFS_I(ino)->mode & FMODE_WRITE)
  366 + if (HOSTFS_I(ino)->mode & FMODE_WRITE)
368 367 w = 1;
369   - if(w)
  368 + if (w)
370 369 r = 1;
371 370  
372 371 name = dentry_name(file->f_path.dentry, 0);
373   - if(name == NULL)
  372 + if (name == NULL)
374 373 return -ENOMEM;
375 374  
376 375 fd = open_file(name, r, w, append);
377 376 kfree(name);
378   - if(fd < 0)
  377 + if (fd < 0)
379 378 return fd;
380 379 FILE_HOSTFS_I(file)->fd = fd;
381 380  
... ... @@ -423,7 +422,7 @@
423 422 base = ((unsigned long long) page->index) << PAGE_CACHE_SHIFT;
424 423  
425 424 err = write_file(HOSTFS_I(inode)->fd, &base, buffer, count);
426   - if(err != count){
  425 + if (err != count) {
427 426 ClearPageUptodate(page);
428 427 goto out;
429 428 }
... ... @@ -452,7 +451,8 @@
452 451 buffer = kmap(page);
453 452 err = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer,
454 453 PAGE_CACHE_SIZE);
455   - if(err < 0) goto out;
  454 + if (err < 0)
  455 + goto out;
456 456  
457 457 memset(&buffer[err], 0, PAGE_CACHE_SIZE - err);
458 458  
... ... @@ -494,7 +494,8 @@
494 494 if (!PageUptodate(page) && err == PAGE_CACHE_SIZE)
495 495 SetPageUptodate(page);
496 496  
497   - /* If err > 0, write_file has added err to pos, so we are comparing
  497 + /*
  498 + * If err > 0, write_file has added err to pos, so we are comparing
498 499 * i_size against the last byte written.
499 500 */
500 501 if (err > 0 && (pos > inode->i_size))
501 502  
502 503  
503 504  
504 505  
505 506  
506 507  
... ... @@ -520,28 +521,28 @@
520 521 int maj, min;
521 522 dev_t rdev = 0;
522 523  
523   - if(dentry){
  524 + if (dentry) {
524 525 name = dentry_name(dentry, 0);
525   - if(name == NULL)
  526 + if (name == NULL)
526 527 goto out;
527 528 type = file_type(name, &maj, &min);
528   - /*Reencode maj and min with the kernel encoding.*/
  529 + /* Reencode maj and min with the kernel encoding.*/
529 530 rdev = MKDEV(maj, min);
530 531 kfree(name);
531 532 }
532 533 else type = OS_TYPE_DIR;
533 534  
534 535 err = 0;
535   - if(type == OS_TYPE_SYMLINK)
  536 + if (type == OS_TYPE_SYMLINK)
536 537 inode->i_op = &page_symlink_inode_operations;
537   - else if(type == OS_TYPE_DIR)
  538 + else if (type == OS_TYPE_DIR)
538 539 inode->i_op = &hostfs_dir_iops;
539 540 else inode->i_op = &hostfs_iops;
540 541  
541   - if(type == OS_TYPE_DIR) inode->i_fop = &hostfs_dir_fops;
  542 + if (type == OS_TYPE_DIR) inode->i_fop = &hostfs_dir_fops;
542 543 else inode->i_fop = &hostfs_file_fops;
543 544  
544   - if(type == OS_TYPE_SYMLINK)
  545 + if (type == OS_TYPE_SYMLINK)
545 546 inode->i_mapping->a_ops = &hostfs_link_aops;
546 547 else inode->i_mapping->a_ops = &hostfs_aops;
547 548  
... ... @@ -564,7 +565,7 @@
564 565 }
565 566  
566 567 int hostfs_create(struct inode *dir, struct dentry *dentry, int mode,
567   - struct nameidata *nd)
  568 + struct nameidata *nd)
568 569 {
569 570 struct inode *inode;
570 571 char *name;
571 572  
572 573  
573 574  
574 575  
... ... @@ -572,27 +573,28 @@
572 573  
573 574 error = -ENOMEM;
574 575 inode = iget(dir->i_sb, 0);
575   - if(inode == NULL) goto out;
  576 + if (inode == NULL)
  577 + goto out;
576 578  
577 579 error = init_inode(inode, dentry);
578   - if(error)
  580 + if (error)
579 581 goto out_put;
580 582  
581 583 error = -ENOMEM;
582 584 name = dentry_name(dentry, 0);
583   - if(name == NULL)
  585 + if (name == NULL)
584 586 goto out_put;
585 587  
586 588 fd = file_create(name,
587 589 mode & S_IRUSR, mode & S_IWUSR, mode & S_IXUSR,
588 590 mode & S_IRGRP, mode & S_IWGRP, mode & S_IXGRP,
589 591 mode & S_IROTH, mode & S_IWOTH, mode & S_IXOTH);
590   - if(fd < 0)
  592 + if (fd < 0)
591 593 error = fd;
592 594 else error = read_name(inode, name);
593 595  
594 596 kfree(name);
595   - if(error)
  597 + if (error)
596 598 goto out_put;
597 599  
598 600 HOSTFS_I(inode)->fd = fd;
599 601  
600 602  
601 603  
602 604  
... ... @@ -615,25 +617,25 @@
615 617  
616 618 err = -ENOMEM;
617 619 inode = iget(ino->i_sb, 0);
618   - if(inode == NULL)
  620 + if (inode == NULL)
619 621 goto out;
620 622  
621 623 err = init_inode(inode, dentry);
622   - if(err)
  624 + if (err)
623 625 goto out_put;
624 626  
625 627 err = -ENOMEM;
626 628 name = dentry_name(dentry, 0);
627   - if(name == NULL)
  629 + if (name == NULL)
628 630 goto out_put;
629 631  
630 632 err = read_name(inode, name);
631 633 kfree(name);
632   - if(err == -ENOENT){
  634 + if (err == -ENOENT) {
633 635 iput(inode);
634 636 inode = NULL;
635 637 }
636   - else if(err)
  638 + else if (err)
637 639 goto out_put;
638 640  
639 641 d_add(dentry, inode);
... ... @@ -652,7 +654,7 @@
652 654 int len;
653 655  
654 656 file = inode_name(ino, dentry->d_name.len + 1);
655   - if(file == NULL)
  657 + if (file == NULL)
656 658 return NULL;
657 659 strcat(file, "/");
658 660 len = strlen(file);
659 661  
... ... @@ -666,10 +668,10 @@
666 668 char *from_name, *to_name;
667 669 int err;
668 670  
669   - if((from_name = inode_dentry_name(ino, from)) == NULL)
  671 + if ((from_name = inode_dentry_name(ino, from)) == NULL)
670 672 return -ENOMEM;
671 673 to_name = dentry_name(to, 0);
672   - if(to_name == NULL){
  674 + if (to_name == NULL) {
673 675 kfree(from_name);
674 676 return -ENOMEM;
675 677 }
676 678  
... ... @@ -684,9 +686,9 @@
684 686 char *file;
685 687 int err;
686 688  
687   - if((file = inode_dentry_name(ino, dentry)) == NULL)
  689 + if ((file = inode_dentry_name(ino, dentry)) == NULL)
688 690 return -ENOMEM;
689   - if(append)
  691 + if (append)
690 692 return -EPERM;
691 693  
692 694 err = unlink_file(file);
... ... @@ -699,7 +701,7 @@
699 701 char *file;
700 702 int err;
701 703  
702   - if((file = inode_dentry_name(ino, dentry)) == NULL)
  704 + if ((file = inode_dentry_name(ino, dentry)) == NULL)
703 705 return -ENOMEM;
704 706 err = make_symlink(file, to);
705 707 kfree(file);
... ... @@ -711,7 +713,7 @@
711 713 char *file;
712 714 int err;
713 715  
714   - if((file = inode_dentry_name(ino, dentry)) == NULL)
  716 + if ((file = inode_dentry_name(ino, dentry)) == NULL)
715 717 return -ENOMEM;
716 718 err = do_mkdir(file, mode);
717 719 kfree(file);
... ... @@ -723,7 +725,7 @@
723 725 char *file;
724 726 int err;
725 727  
726   - if((file = inode_dentry_name(ino, dentry)) == NULL)
  728 + if ((file = inode_dentry_name(ino, dentry)) == NULL)
727 729 return -ENOMEM;
728 730 err = do_rmdir(file);
729 731 kfree(file);
730 732  
731 733  
732 734  
733 735  
... ... @@ -737,26 +739,26 @@
737 739 int err = -ENOMEM;
738 740  
739 741 inode = iget(dir->i_sb, 0);
740   - if(inode == NULL)
  742 + if (inode == NULL)
741 743 goto out;
742 744  
743 745 err = init_inode(inode, dentry);
744   - if(err)
  746 + if (err)
745 747 goto out_put;
746 748  
747 749 err = -ENOMEM;
748 750 name = dentry_name(dentry, 0);
749   - if(name == NULL)
  751 + if (name == NULL)
750 752 goto out_put;
751 753  
752 754 init_special_inode(inode, mode, dev);
753 755 err = do_mknod(name, mode, MAJOR(dev), MINOR(dev));
754   - if(err)
  756 + if (err)
755 757 goto out_free;
756 758  
757 759 err = read_name(inode, name);
758 760 kfree(name);
759   - if(err)
  761 + if (err)
760 762 goto out_put;
761 763  
762 764 d_instantiate(dentry, inode);
763 765  
... ... @@ -776,9 +778,9 @@
776 778 char *from_name, *to_name;
777 779 int err;
778 780  
779   - if((from_name = inode_dentry_name(from_ino, from)) == NULL)
  781 + if ((from_name = inode_dentry_name(from_ino, from)) == NULL)
780 782 return -ENOMEM;
781   - if((to_name = inode_dentry_name(to_ino, to)) == NULL){
  783 + if ((to_name = inode_dentry_name(to_ino, to)) == NULL) {
782 784 kfree(from_name);
783 785 return -ENOMEM;
784 786 }
785 787  
... ... @@ -801,12 +803,12 @@
801 803 return -ENOMEM;
802 804  
803 805 if (S_ISCHR(ino->i_mode) || S_ISBLK(ino->i_mode) ||
804   - S_ISFIFO(ino->i_mode) || S_ISSOCK(ino->i_mode))
  806 + S_ISFIFO(ino->i_mode) || S_ISSOCK(ino->i_mode))
805 807 err = 0;
806 808 else
807 809 err = access_file(name, r, w, x);
808 810 kfree(name);
809   - if(!err)
  811 + if (!err)
810 812 err = generic_permission(ino, desired, NULL);
811 813 return err;
812 814 }
813 815  
814 816  
815 817  
816 818  
817 819  
818 820  
819 821  
820 822  
821 823  
822 824  
823 825  
... ... @@ -823,50 +825,50 @@
823 825 if (err)
824 826 return err;
825 827  
826   - if(append)
  828 + if (append)
827 829 attr->ia_valid &= ~ATTR_SIZE;
828 830  
829 831 attrs.ia_valid = 0;
830   - if(attr->ia_valid & ATTR_MODE){
  832 + if (attr->ia_valid & ATTR_MODE) {
831 833 attrs.ia_valid |= HOSTFS_ATTR_MODE;
832 834 attrs.ia_mode = attr->ia_mode;
833 835 }
834   - if(attr->ia_valid & ATTR_UID){
  836 + if (attr->ia_valid & ATTR_UID) {
835 837 attrs.ia_valid |= HOSTFS_ATTR_UID;
836 838 attrs.ia_uid = attr->ia_uid;
837 839 }
838   - if(attr->ia_valid & ATTR_GID){
  840 + if (attr->ia_valid & ATTR_GID) {
839 841 attrs.ia_valid |= HOSTFS_ATTR_GID;
840 842 attrs.ia_gid = attr->ia_gid;
841 843 }
842   - if(attr->ia_valid & ATTR_SIZE){
  844 + if (attr->ia_valid & ATTR_SIZE) {
843 845 attrs.ia_valid |= HOSTFS_ATTR_SIZE;
844 846 attrs.ia_size = attr->ia_size;
845 847 }
846   - if(attr->ia_valid & ATTR_ATIME){
  848 + if (attr->ia_valid & ATTR_ATIME) {
847 849 attrs.ia_valid |= HOSTFS_ATTR_ATIME;
848 850 attrs.ia_atime = attr->ia_atime;
849 851 }
850   - if(attr->ia_valid & ATTR_MTIME){
  852 + if (attr->ia_valid & ATTR_MTIME) {
851 853 attrs.ia_valid |= HOSTFS_ATTR_MTIME;
852 854 attrs.ia_mtime = attr->ia_mtime;
853 855 }
854   - if(attr->ia_valid & ATTR_CTIME){
  856 + if (attr->ia_valid & ATTR_CTIME) {
855 857 attrs.ia_valid |= HOSTFS_ATTR_CTIME;
856 858 attrs.ia_ctime = attr->ia_ctime;
857 859 }
858   - if(attr->ia_valid & ATTR_ATIME_SET){
  860 + if (attr->ia_valid & ATTR_ATIME_SET) {
859 861 attrs.ia_valid |= HOSTFS_ATTR_ATIME_SET;
860 862 }
861   - if(attr->ia_valid & ATTR_MTIME_SET){
  863 + if (attr->ia_valid & ATTR_MTIME_SET) {
862 864 attrs.ia_valid |= HOSTFS_ATTR_MTIME_SET;
863 865 }
864 866 name = dentry_name(dentry, 0);
865   - if(name == NULL)
  867 + if (name == NULL)
866 868 return -ENOMEM;
867 869 err = set_attr(name, &attrs, fd);
868 870 kfree(name);
869   - if(err)
  871 + if (err)
870 872 return err;
871 873  
872 874 return inode_setattr(dentry->d_inode, attr);
873 875  
874 876  
... ... @@ -906,13 +908,13 @@
906 908  
907 909 buffer = kmap(page);
908 910 name = inode_name(page->mapping->host, 0);
909   - if(name == NULL)
  911 + if (name == NULL)
910 912 return -ENOMEM;
911 913 err = do_readlink(name, buffer, PAGE_CACHE_SIZE);
912 914 kfree(name);
913   - if(err == PAGE_CACHE_SIZE)
  915 + if (err == PAGE_CACHE_SIZE)
914 916 err = -E2BIG;
915   - else if(err > 0){
  917 + else if (err > 0) {
916 918 flush_dcache_page(page);
917 919 SetPageUptodate(page);
918 920 if (PageError(page)) ClearPageError(page);
919 921  
920 922  
921 923  
922 924  
923 925  
... ... @@ -945,31 +947,33 @@
945 947 err = -ENOMEM;
946 948 host_root_path = kmalloc(strlen(root_ino) + 1
947 949 + strlen(req_root) + 1, GFP_KERNEL);
948   - if(host_root_path == NULL)
  950 + if (host_root_path == NULL)
949 951 goto out;
950 952  
951 953 sprintf(host_root_path, "%s/%s", root_ino, req_root);
952 954  
953 955 root_inode = iget(sb, 0);
954   - if(root_inode == NULL)
  956 + if (root_inode == NULL)
955 957 goto out_free;
956 958  
957 959 err = init_inode(root_inode, NULL);
958   - if(err)
  960 + if (err)
959 961 goto out_put;
960 962  
961 963 HOSTFS_I(root_inode)->host_filename = host_root_path;
962   - /* Avoid that in the error path, iput(root_inode) frees again
963   - * host_root_path through hostfs_destroy_inode! */
  964 + /*
  965 + * Avoid that in the error path, iput(root_inode) frees again
  966 + * host_root_path through hostfs_destroy_inode!
  967 + */
964 968 host_root_path = NULL;
965 969  
966 970 err = -ENOMEM;
967 971 sb->s_root = d_alloc_root(root_inode);
968   - if(sb->s_root == NULL)
  972 + if (sb->s_root == NULL)
969 973 goto out_put;
970 974  
971 975 err = read_inode(root_inode);
972   - if(err){
  976 + if (err) {
973 977 /* No iput in this case because the dput does that for us */
974 978 dput(sb->s_root);
975 979 sb->s_root = NULL;
fs/hostfs/hostfs_user.c
... ... @@ -3,19 +3,21 @@
3 3 * Licensed under the GPL
4 4 */
5 5  
6   -#include <unistd.h>
7 6 #include <stdio.h>
8   -#include <fcntl.h>
  7 +#include <stddef.h>
  8 +#include <unistd.h>
9 9 #include <dirent.h>
10 10 #include <errno.h>
11   -#include <utime.h>
  11 +#include <fcntl.h>
12 12 #include <string.h>
13 13 #include <sys/stat.h>
14 14 #include <sys/time.h>
  15 +#include <sys/types.h>
15 16 #include <sys/vfs.h>
16 17 #include "hostfs.h"
17   -#include "kern_util.h"
  18 +#include "os.h"
18 19 #include "user.h"
  20 +#include <utime.h>
19 21  
20 22 int stat_file(const char *path, unsigned long long *inode_out, int *mode_out,
21 23 int *nlink_out, int *uid_out, int *gid_out,
22 24  
23 25  
24 26  
25 27  
26 28  
... ... @@ -25,33 +27,41 @@
25 27 {
26 28 struct stat64 buf;
27 29  
28   - if(fd >= 0) {
  30 + if (fd >= 0) {
29 31 if (fstat64(fd, &buf) < 0)
30 32 return -errno;
31   - } else if(lstat64(path, &buf) < 0) {
  33 + } else if (lstat64(path, &buf) < 0) {
32 34 return -errno;
33 35 }
34 36  
35   - if(inode_out != NULL) *inode_out = buf.st_ino;
36   - if(mode_out != NULL) *mode_out = buf.st_mode;
37   - if(nlink_out != NULL) *nlink_out = buf.st_nlink;
38   - if(uid_out != NULL) *uid_out = buf.st_uid;
39   - if(gid_out != NULL) *gid_out = buf.st_gid;
40   - if(size_out != NULL) *size_out = buf.st_size;
41   - if(atime_out != NULL) {
  37 + if (inode_out != NULL)
  38 + *inode_out = buf.st_ino;
  39 + if (mode_out != NULL)
  40 + *mode_out = buf.st_mode;
  41 + if (nlink_out != NULL)
  42 + *nlink_out = buf.st_nlink;
  43 + if (uid_out != NULL)
  44 + *uid_out = buf.st_uid;
  45 + if (gid_out != NULL)
  46 + *gid_out = buf.st_gid;
  47 + if (size_out != NULL)
  48 + *size_out = buf.st_size;
  49 + if (atime_out != NULL) {
42 50 atime_out->tv_sec = buf.st_atime;
43 51 atime_out->tv_nsec = 0;
44 52 }
45   - if(mtime_out != NULL) {
  53 + if (mtime_out != NULL) {
46 54 mtime_out->tv_sec = buf.st_mtime;
47 55 mtime_out->tv_nsec = 0;
48 56 }
49   - if(ctime_out != NULL) {
  57 + if (ctime_out != NULL) {
50 58 ctime_out->tv_sec = buf.st_ctime;
51 59 ctime_out->tv_nsec = 0;
52 60 }
53   - if(blksize_out != NULL) *blksize_out = buf.st_blksize;
54   - if(blocks_out != NULL) *blocks_out = buf.st_blocks;
  61 + if (blksize_out != NULL)
  62 + *blksize_out = buf.st_blksize;
  63 + if (blocks_out != NULL)
  64 + *blocks_out = buf.st_blocks;
55 65 return 0;
56 66 }
57 67  
58 68  
59 69  
60 70  
... ... @@ -59,21 +69,29 @@
59 69 {
60 70 struct stat64 buf;
61 71  
62   - if(lstat64(path, &buf) < 0)
  72 + if (lstat64(path, &buf) < 0)
63 73 return -errno;
64   - /*We cannot pass rdev as is because glibc and the kernel disagree
65   - *about its definition.*/
66   - if(maj != NULL)
  74 + /*
  75 + * We cannot pass rdev as is because glibc and the kernel disagree
  76 + * about its definition.
  77 + */
  78 + if (maj != NULL)
67 79 *maj = major(buf.st_rdev);
68   - if(min != NULL)
  80 + if (min != NULL)
69 81 *min = minor(buf.st_rdev);
70 82  
71   - if(S_ISDIR(buf.st_mode)) return OS_TYPE_DIR;
72   - else if(S_ISLNK(buf.st_mode)) return OS_TYPE_SYMLINK;
73   - else if(S_ISCHR(buf.st_mode)) return OS_TYPE_CHARDEV;
74   - else if(S_ISBLK(buf.st_mode)) return OS_TYPE_BLOCKDEV;
75   - else if(S_ISFIFO(buf.st_mode))return OS_TYPE_FIFO;
76   - else if(S_ISSOCK(buf.st_mode))return OS_TYPE_SOCK;
  83 + if (S_ISDIR(buf.st_mode))
  84 + return OS_TYPE_DIR;
  85 + else if (S_ISLNK(buf.st_mode))
  86 + return OS_TYPE_SYMLINK;
  87 + else if (S_ISCHR(buf.st_mode))
  88 + return OS_TYPE_CHARDEV;
  89 + else if (S_ISBLK(buf.st_mode))
  90 + return OS_TYPE_BLOCKDEV;
  91 + else if (S_ISFIFO(buf.st_mode))
  92 + return OS_TYPE_FIFO;
  93 + else if (S_ISSOCK(buf.st_mode))
  94 + return OS_TYPE_SOCK;
77 95 else return OS_TYPE_FILE;
78 96 }
79 97  
... ... @@ -81,10 +99,13 @@
81 99 {
82 100 int mode = 0;
83 101  
84   - if(r) mode = R_OK;
85   - if(w) mode |= W_OK;
86   - if(x) mode |= X_OK;
87   - if(access(path, mode) != 0)
  102 + if (r)
  103 + mode = R_OK;
  104 + if (w)
  105 + mode |= W_OK;
  106 + if (x)
  107 + mode |= X_OK;
  108 + if (access(path, mode) != 0)
88 109 return -errno;
89 110 else return 0;
90 111 }
91 112  
92 113  
93 114  
94 115  
... ... @@ -93,18 +114,18 @@
93 114 {
94 115 int mode = 0, fd;
95 116  
96   - if(r && !w)
  117 + if (r && !w)
97 118 mode = O_RDONLY;
98   - else if(!r && w)
  119 + else if (!r && w)
99 120 mode = O_WRONLY;
100   - else if(r && w)
  121 + else if (r && w)
101 122 mode = O_RDWR;
102 123 else panic("Impossible mode in open_file");
103 124  
104   - if(append)
  125 + if (append)
105 126 mode |= O_APPEND;
106 127 fd = open64(path, mode);
107   - if(fd < 0)
  128 + if (fd < 0)
108 129 return -errno;
109 130 else return fd;
110 131 }
... ... @@ -115,7 +136,7 @@
115 136  
116 137 dir = opendir(path);
117 138 *err_out = errno;
118   - if(dir == NULL)
  139 + if (dir == NULL)
119 140 return NULL;
120 141 return dir;
121 142 }
... ... @@ -128,7 +149,7 @@
128 149  
129 150 seekdir(dir, *pos);
130 151 ent = readdir(dir);
131   - if(ent == NULL)
  152 + if (ent == NULL)
132 153 return NULL;
133 154 *len_out = strlen(ent->d_name);
134 155 *ino_out = ent->d_ino;
... ... @@ -141,7 +162,7 @@
141 162 int n;
142 163  
143 164 n = pread64(fd, buf, len, *offset);
144   - if(n < 0)
  165 + if (n < 0)
145 166 return -errno;
146 167 *offset += n;
147 168 return n;
... ... @@ -152,7 +173,7 @@
152 173 int n;
153 174  
154 175 n = pwrite64(fd, buf, len, *offset);
155   - if(n < 0)
  176 + if (n < 0)
156 177 return -errno;
157 178 *offset += n;
158 179 return n;
... ... @@ -163,7 +184,7 @@
163 184 int ret;
164 185  
165 186 ret = lseek64(fd, offset, whence);
166   - if(ret < 0)
  187 + if (ret < 0)
167 188 return -errno;
168 189 return 0;
169 190 }
... ... @@ -207,7 +228,7 @@
207 228 mode |= ow ? S_IWOTH : 0;
208 229 mode |= ox ? S_IXOTH : 0;
209 230 fd = open64(name, O_CREAT | O_RDWR, mode);
210   - if(fd < 0)
  231 + if (fd < 0)
211 232 return -errno;
212 233 return fd;
213 234 }
... ... @@ -230,7 +251,7 @@
230 251 if (fd >= 0) {
231 252 if (fchown(fd, attrs->ia_uid, -1))
232 253 return -errno;
233   - } else if(chown(file, attrs->ia_uid, -1)) {
  254 + } else if (chown(file, attrs->ia_uid, -1)) {
234 255 return -errno;
235 256 }
236 257 }
237 258  
... ... @@ -251,9 +272,11 @@
251 272 }
252 273 }
253 274  
254   - /* Update accessed and/or modified time, in two parts: first set
  275 + /*
  276 + * Update accessed and/or modified time, in two parts: first set
255 277 * times according to the changes to perform, and then call futimes()
256   - * or utimes() to apply them. */
  278 + * or utimes() to apply them.
  279 + */
257 280 ma = (HOSTFS_ATTR_ATIME_SET | HOSTFS_ATTR_MTIME_SET);
258 281 if (attrs->ia_valid & ma) {
259 282 err = stat_file(file, NULL, NULL, NULL, NULL, NULL, NULL,
260 283  
... ... @@ -284,11 +307,11 @@
284 307 }
285 308  
286 309 /* Note: ctime is not handled */
287   - if(attrs->ia_valid & (HOSTFS_ATTR_ATIME | HOSTFS_ATTR_MTIME)){
  310 + if (attrs->ia_valid & (HOSTFS_ATTR_ATIME | HOSTFS_ATTR_MTIME)) {
288 311 err = stat_file(file, NULL, NULL, NULL, NULL, NULL, NULL,
289 312 &attrs->ia_atime, &attrs->ia_mtime, NULL,
290 313 NULL, NULL, fd);
291   - if(err != 0)
  314 + if (err != 0)
292 315 return err;
293 316 }
294 317 return 0;
... ... @@ -299,7 +322,7 @@
299 322 int err;
300 323  
301 324 err = symlink(to, from);
302   - if(err)
  325 + if (err)
303 326 return -errno;
304 327 return 0;
305 328 }
... ... @@ -309,7 +332,7 @@
309 332 int err;
310 333  
311 334 err = unlink(file);
312   - if(err)
  335 + if (err)
313 336 return -errno;
314 337 return 0;
315 338 }
... ... @@ -319,7 +342,7 @@
319 342 int err;
320 343  
321 344 err = mkdir(file, mode);
322   - if(err)
  345 + if (err)
323 346 return -errno;
324 347 return 0;
325 348 }
... ... @@ -329,7 +352,7 @@
329 352 int err;
330 353  
331 354 err = rmdir(file);
332   - if(err)
  355 + if (err)
333 356 return -errno;
334 357 return 0;
335 358 }
... ... @@ -339,7 +362,7 @@
339 362 int err;
340 363  
341 364 err = mknod(file, mode, makedev(major, minor));
342   - if(err)
  365 + if (err)
343 366 return -errno;
344 367 return 0;
345 368 }
... ... @@ -349,7 +372,7 @@
349 372 int err;
350 373  
351 374 err = link(to, from);
352   - if(err)
  375 + if (err)
353 376 return -errno;
354 377 return 0;
355 378 }
356 379  
... ... @@ -359,9 +382,9 @@
359 382 int n;
360 383  
361 384 n = readlink(file, buf, size);
362   - if(n < 0)
  385 + if (n < 0)
363 386 return -errno;
364   - if(n < size)
  387 + if (n < size)
365 388 buf[n] = '\0';
366 389 return n;
367 390 }
... ... @@ -371,7 +394,7 @@
371 394 int err;
372 395  
373 396 err = rename(from, to);
374   - if(err < 0)
  397 + if (err < 0)
375 398 return -errno;
376 399 return 0;
377 400 }
... ... @@ -386,7 +409,7 @@
386 409 int err;
387 410  
388 411 err = statfs64(root, &buf);
389   - if(err < 0)
  412 + if (err < 0)
390 413 return -errno;
391 414  
392 415 *bsize_out = buf.f_bsize;