aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-05-08 03:23:18 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:14:57 -0400
commitf1adc05e77383017bc63ea9c48ba217da76682b8 (patch)
treee58290483a62ce846bb63d2b965952bd038707bb
parent5822b7faca709c03a59c2929005bfe9caffe6592 (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>
-rw-r--r--fs/hostfs/hostfs.h11
-rw-r--r--fs/hostfs/hostfs_kern.c186
-rw-r--r--fs/hostfs/hostfs_user.c141
3 files changed, 167 insertions, 171 deletions
diff --git a/fs/hostfs/hostfs.h b/fs/hostfs/hostfs.h
index d8850c701564..06e5930515fe 100644
--- a/fs/hostfs/hostfs.h
+++ b/fs/hostfs/hostfs.h
@@ -87,14 +87,3 @@ extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
87 long *spare_out); 87 long *spare_out);
88 88
89#endif 89#endif
90
91/*
92 * Overrides for Emacs so that we follow Linus's tabbing style.
93 * Emacs will notice this stuff at the end of the file and automatically
94 * adjust the settings for this buffer only. This must remain at the end
95 * of the file.
96 * ---------------------------------------------------------------------------
97 * Local variables:
98 * c-file-style: "linux"
99 * End:
100 */
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 4e8bb2fba048..8286491dbf31 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2000, 2001, 2002 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 * Ported the filesystem routines to 2.5. 5 * Ported the filesystem routines to 2.5.
@@ -31,14 +31,14 @@ struct hostfs_inode_info {
31 31
32static inline struct hostfs_inode_info *HOSTFS_I(struct inode *inode) 32static inline struct hostfs_inode_info *HOSTFS_I(struct inode *inode)
33{ 33{
34 return(list_entry(inode, struct hostfs_inode_info, vfs_inode)); 34 return list_entry(inode, struct hostfs_inode_info, vfs_inode);
35} 35}
36 36
37#define FILE_HOSTFS_I(file) HOSTFS_I((file)->f_path.dentry->d_inode) 37#define FILE_HOSTFS_I(file) HOSTFS_I((file)->f_path.dentry->d_inode)
38 38
39int hostfs_d_delete(struct dentry *dentry) 39int hostfs_d_delete(struct dentry *dentry)
40{ 40{
41 return(1); 41 return 1;
42} 42}
43 43
44struct dentry_operations hostfs_dentry_ops = { 44struct dentry_operations hostfs_dentry_ops = {
@@ -79,7 +79,7 @@ static int __init hostfs_args(char *options, int *add)
79 } 79 }
80 options = ptr; 80 options = ptr;
81 } 81 }
82 return(0); 82 return 0;
83} 83}
84 84
85__uml_setup("hostfs=", hostfs_args, 85__uml_setup("hostfs=", hostfs_args,
@@ -110,7 +110,8 @@ static char *dentry_name(struct dentry *dentry, int extra)
110 root = HOSTFS_I(parent->d_inode)->host_filename; 110 root = HOSTFS_I(parent->d_inode)->host_filename;
111 len += strlen(root); 111 len += strlen(root);
112 name = kmalloc(len + extra + 1, GFP_KERNEL); 112 name = kmalloc(len + extra + 1, GFP_KERNEL);
113 if(name == NULL) return(NULL); 113 if(name == NULL)
114 return NULL;
114 115
115 name[len] = '\0'; 116 name[len] = '\0';
116 parent = dentry; 117 parent = dentry;
@@ -122,7 +123,7 @@ static char *dentry_name(struct dentry *dentry, int extra)
122 parent = parent->d_parent; 123 parent = parent->d_parent;
123 } 124 }
124 strncpy(name, root, strlen(root)); 125 strncpy(name, root, strlen(root));
125 return(name); 126 return name;
126} 127}
127 128
128static char *inode_name(struct inode *ino, int extra) 129static char *inode_name(struct inode *ino, int extra)
@@ -130,7 +131,7 @@ static char *inode_name(struct inode *ino, int extra)
130 struct dentry *dentry; 131 struct dentry *dentry;
131 132
132 dentry = list_entry(ino->i_dentry.next, struct dentry, d_alias); 133 dentry = list_entry(ino->i_dentry.next, struct dentry, d_alias);
133 return(dentry_name(dentry, extra)); 134 return dentry_name(dentry, extra);
134} 135}
135 136
136static int read_name(struct inode *ino, char *name) 137static int read_name(struct inode *ino, char *name)
@@ -149,14 +150,14 @@ static int read_name(struct inode *ino, char *name)
149 &ino->i_gid, &i_size, &ino->i_atime, &ino->i_mtime, 150 &ino->i_gid, &i_size, &ino->i_atime, &ino->i_mtime,
150 &ino->i_ctime, &i_blksize, &i_blocks, -1); 151 &ino->i_ctime, &i_blksize, &i_blocks, -1);
151 if(err) 152 if(err)
152 return(err); 153 return err;
153 154
154 ino->i_ino = i_ino; 155 ino->i_ino = i_ino;
155 ino->i_mode = i_mode; 156 ino->i_mode = i_mode;
156 ino->i_nlink = i_nlink; 157 ino->i_nlink = i_nlink;
157 ino->i_size = i_size; 158 ino->i_size = i_size;
158 ino->i_blocks = i_blocks; 159 ino->i_blocks = i_blocks;
159 return(0); 160 return 0;
160} 161}
161 162
162static char *follow_link(char *link) 163static char *follow_link(char *link)
@@ -181,11 +182,11 @@ static char *follow_link(char *link)
181 goto out_free; 182 goto out_free;
182 183
183 if(*name == '/') 184 if(*name == '/')
184 return(name); 185 return name;
185 186
186 end = strrchr(link, '/'); 187 end = strrchr(link, '/');
187 if(end == NULL) 188 if(end == NULL)
188 return(name); 189 return name;
189 190
190 *(end + 1) = '\0'; 191 *(end + 1) = '\0';
191 len = strlen(link) + strlen(name) + 1; 192 len = strlen(link) + strlen(name) + 1;
@@ -199,12 +200,12 @@ static char *follow_link(char *link)
199 sprintf(resolved, "%s%s", link, name); 200 sprintf(resolved, "%s%s", link, name);
200 kfree(name); 201 kfree(name);
201 kfree(link); 202 kfree(link);
202 return(resolved); 203 return resolved;
203 204
204 out_free: 205 out_free:
205 kfree(name); 206 kfree(name);
206 out: 207 out:
207 return(ERR_PTR(n)); 208 return ERR_PTR(n);
208} 209}
209 210
210static int read_inode(struct inode *ino) 211static int read_inode(struct inode *ino)
@@ -234,7 +235,7 @@ static int read_inode(struct inode *ino)
234 err = read_name(ino, name); 235 err = read_name(ino, name);
235 kfree(name); 236 kfree(name);
236 out: 237 out:
237 return(err); 238 return err;
238} 239}
239 240
240int hostfs_statfs(struct dentry *dentry, struct kstatfs *sf) 241int hostfs_statfs(struct dentry *dentry, struct kstatfs *sf)
@@ -254,14 +255,15 @@ int hostfs_statfs(struct dentry *dentry, struct kstatfs *sf)
254 &sf->f_bsize, &f_blocks, &f_bfree, &f_bavail, &f_files, 255 &sf->f_bsize, &f_blocks, &f_bfree, &f_bavail, &f_files,
255 &f_ffree, &sf->f_fsid, sizeof(sf->f_fsid), 256 &f_ffree, &sf->f_fsid, sizeof(sf->f_fsid),
256 &sf->f_namelen, sf->f_spare); 257 &sf->f_namelen, sf->f_spare);
257 if(err) return(err); 258 if(err)
259 return err;
258 sf->f_blocks = f_blocks; 260 sf->f_blocks = f_blocks;
259 sf->f_bfree = f_bfree; 261 sf->f_bfree = f_bfree;
260 sf->f_bavail = f_bavail; 262 sf->f_bavail = f_bavail;
261 sf->f_files = f_files; 263 sf->f_files = f_files;
262 sf->f_ffree = f_ffree; 264 sf->f_ffree = f_ffree;
263 sf->f_type = HOSTFS_SUPER_MAGIC; 265 sf->f_type = HOSTFS_SUPER_MAGIC;
264 return(0); 266 return 0;
265} 267}
266 268
267static struct inode *hostfs_alloc_inode(struct super_block *sb) 269static struct inode *hostfs_alloc_inode(struct super_block *sb)
@@ -270,13 +272,13 @@ static struct inode *hostfs_alloc_inode(struct super_block *sb)
270 272
271 hi = kmalloc(sizeof(*hi), GFP_KERNEL); 273 hi = kmalloc(sizeof(*hi), GFP_KERNEL);
272 if(hi == NULL) 274 if(hi == NULL)
273 return(NULL); 275 return NULL;
274 276
275 *hi = ((struct hostfs_inode_info) { .host_filename = NULL, 277 *hi = ((struct hostfs_inode_info) { .host_filename = NULL,
276 .fd = -1, 278 .fd = -1,
277 .mode = 0 }); 279 .mode = 0 });
278 inode_init_once(&hi->vfs_inode); 280 inode_init_once(&hi->vfs_inode);
279 return(&hi->vfs_inode); 281 return &hi->vfs_inode;
280} 282}
281 283
282static void hostfs_delete_inode(struct inode *inode) 284static void hostfs_delete_inode(struct inode *inode)
@@ -325,10 +327,12 @@ int hostfs_readdir(struct file *file, void *ent, filldir_t filldir)
325 int error, len; 327 int error, len;
326 328
327 name = dentry_name(file->f_path.dentry, 0); 329 name = dentry_name(file->f_path.dentry, 0);
328 if(name == NULL) return(-ENOMEM); 330 if(name == NULL)
331 return -ENOMEM;
329 dir = open_dir(name, &error); 332 dir = open_dir(name, &error);
330 kfree(name); 333 kfree(name);
331 if(dir == NULL) return(-error); 334 if(dir == NULL)
335 return -error;
332 next = file->f_pos; 336 next = file->f_pos;
333 while((name = read_dir(dir, &next, &ino, &len)) != NULL){ 337 while((name = read_dir(dir, &next, &ino, &len)) != NULL){
334 error = (*filldir)(ent, name, len, file->f_pos, 338 error = (*filldir)(ent, name, len, file->f_pos,
@@ -337,7 +341,7 @@ int hostfs_readdir(struct file *file, void *ent, filldir_t filldir)
337 file->f_pos = next; 341 file->f_pos = next;
338 } 342 }
339 close_dir(dir); 343 close_dir(dir);
340 return(0); 344 return 0;
341} 345}
342 346
343int hostfs_file_open(struct inode *ino, struct file *file) 347int hostfs_file_open(struct inode *ino, struct file *file)
@@ -347,7 +351,7 @@ int hostfs_file_open(struct inode *ino, struct file *file)
347 351
348 mode = file->f_mode & (FMODE_READ | FMODE_WRITE); 352 mode = file->f_mode & (FMODE_READ | FMODE_WRITE);
349 if((mode & HOSTFS_I(ino)->mode) == mode) 353 if((mode & HOSTFS_I(ino)->mode) == mode)
350 return(0); 354 return 0;
351 355
352 /* The file may already have been opened, but with the wrong access, 356 /* The file may already have been opened, but with the wrong access,
353 * so this resets things and reopens the file with the new access. 357 * so this resets things and reopens the file with the new access.
@@ -367,14 +371,15 @@ int hostfs_file_open(struct inode *ino, struct file *file)
367 371
368 name = dentry_name(file->f_path.dentry, 0); 372 name = dentry_name(file->f_path.dentry, 0);
369 if(name == NULL) 373 if(name == NULL)
370 return(-ENOMEM); 374 return -ENOMEM;
371 375
372 fd = open_file(name, r, w, append); 376 fd = open_file(name, r, w, append);
373 kfree(name); 377 kfree(name);
374 if(fd < 0) return(fd); 378 if(fd < 0)
379 return fd;
375 FILE_HOSTFS_I(file)->fd = fd; 380 FILE_HOSTFS_I(file)->fd = fd;
376 381
377 return(0); 382 return 0;
378} 383}
379 384
380int hostfs_fsync(struct file *file, struct dentry *dentry, int datasync) 385int hostfs_fsync(struct file *file, struct dentry *dentry, int datasync)
@@ -458,7 +463,7 @@ int hostfs_readpage(struct file *file, struct page *page)
458 out: 463 out:
459 kunmap(page); 464 kunmap(page);
460 unlock_page(page); 465 unlock_page(page);
461 return(err); 466 return err;
462} 467}
463 468
464int hostfs_prepare_write(struct file *file, struct page *page, 469int hostfs_prepare_write(struct file *file, struct page *page,
@@ -485,7 +490,7 @@ int hostfs_prepare_write(struct file *file, struct page *page,
485 err = 0; 490 err = 0;
486 out: 491 out:
487 kunmap(page); 492 kunmap(page);
488 return(err); 493 return err;
489} 494}
490 495
491int hostfs_commit_write(struct file *file, struct page *page, unsigned from, 496int hostfs_commit_write(struct file *file, struct page *page, unsigned from,
@@ -511,7 +516,7 @@ int hostfs_commit_write(struct file *file, struct page *page, unsigned from,
511 inode->i_size = start; 516 inode->i_size = start;
512 517
513 kunmap(page); 518 kunmap(page);
514 return(err); 519 return err;
515} 520}
516 521
517static const struct address_space_operations hostfs_aops = { 522static const struct address_space_operations hostfs_aops = {
@@ -569,7 +574,7 @@ static int init_inode(struct inode *inode, struct dentry *dentry)
569 break; 574 break;
570 } 575 }
571 out: 576 out:
572 return(err); 577 return err;
573} 578}
574 579
575int hostfs_create(struct inode *dir, struct dentry *dentry, int mode, 580int hostfs_create(struct inode *dir, struct dentry *dentry, int mode,
@@ -607,16 +612,16 @@ int hostfs_create(struct inode *dir, struct dentry *dentry, int mode,
607 HOSTFS_I(inode)->fd = fd; 612 HOSTFS_I(inode)->fd = fd;
608 HOSTFS_I(inode)->mode = FMODE_READ | FMODE_WRITE; 613 HOSTFS_I(inode)->mode = FMODE_READ | FMODE_WRITE;
609 d_instantiate(dentry, inode); 614 d_instantiate(dentry, inode);
610 return(0); 615 return 0;
611 616
612 out_put: 617 out_put:
613 iput(inode); 618 iput(inode);
614 out: 619 out:
615 return(error); 620 return error;
616} 621}
617 622
618struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry, 623struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry,
619 struct nameidata *nd) 624 struct nameidata *nd)
620{ 625{
621 struct inode *inode; 626 struct inode *inode;
622 char *name; 627 char *name;
@@ -647,44 +652,45 @@ struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry,
647 652
648 d_add(dentry, inode); 653 d_add(dentry, inode);
649 dentry->d_op = &hostfs_dentry_ops; 654 dentry->d_op = &hostfs_dentry_ops;
650 return(NULL); 655 return NULL;
651 656
652 out_put: 657 out_put:
653 iput(inode); 658 iput(inode);
654 out: 659 out:
655 return(ERR_PTR(err)); 660 return ERR_PTR(err);
656} 661}
657 662
658static char *inode_dentry_name(struct inode *ino, struct dentry *dentry) 663static char *inode_dentry_name(struct inode *ino, struct dentry *dentry)
659{ 664{
660 char *file; 665 char *file;
661 int len; 666 int len;
662 667
663 file = inode_name(ino, dentry->d_name.len + 1); 668 file = inode_name(ino, dentry->d_name.len + 1);
664 if(file == NULL) return(NULL); 669 if(file == NULL)
665 strcat(file, "/"); 670 return NULL;
671 strcat(file, "/");
666 len = strlen(file); 672 len = strlen(file);
667 strncat(file, dentry->d_name.name, dentry->d_name.len); 673 strncat(file, dentry->d_name.name, dentry->d_name.len);
668 file[len + dentry->d_name.len] = '\0'; 674 file[len + dentry->d_name.len] = '\0';
669 return(file); 675 return file;
670} 676}
671 677
672int hostfs_link(struct dentry *to, struct inode *ino, struct dentry *from) 678int hostfs_link(struct dentry *to, struct inode *ino, struct dentry *from)
673{ 679{
674 char *from_name, *to_name; 680 char *from_name, *to_name;
675 int err; 681 int err;
676 682
677 if((from_name = inode_dentry_name(ino, from)) == NULL) 683 if((from_name = inode_dentry_name(ino, from)) == NULL)
678 return(-ENOMEM); 684 return -ENOMEM;
679 to_name = dentry_name(to, 0); 685 to_name = dentry_name(to, 0);
680 if(to_name == NULL){ 686 if(to_name == NULL){
681 kfree(from_name); 687 kfree(from_name);
682 return(-ENOMEM); 688 return -ENOMEM;
683 } 689 }
684 err = link_file(to_name, from_name); 690 err = link_file(to_name, from_name);
685 kfree(from_name); 691 kfree(from_name);
686 kfree(to_name); 692 kfree(to_name);
687 return(err); 693 return err;
688} 694}
689 695
690int hostfs_unlink(struct inode *ino, struct dentry *dentry) 696int hostfs_unlink(struct inode *ino, struct dentry *dentry)
@@ -692,13 +698,14 @@ int hostfs_unlink(struct inode *ino, struct dentry *dentry)
692 char *file; 698 char *file;
693 int err; 699 int err;
694 700
695 if((file = inode_dentry_name(ino, dentry)) == NULL) return(-ENOMEM); 701 if((file = inode_dentry_name(ino, dentry)) == NULL)
702 return -ENOMEM;
696 if(append) 703 if(append)
697 return(-EPERM); 704 return -EPERM;
698 705
699 err = unlink_file(file); 706 err = unlink_file(file);
700 kfree(file); 707 kfree(file);
701 return(err); 708 return err;
702} 709}
703 710
704int hostfs_symlink(struct inode *ino, struct dentry *dentry, const char *to) 711int hostfs_symlink(struct inode *ino, struct dentry *dentry, const char *to)
@@ -706,10 +713,11 @@ int hostfs_symlink(struct inode *ino, struct dentry *dentry, const char *to)
706 char *file; 713 char *file;
707 int err; 714 int err;
708 715
709 if((file = inode_dentry_name(ino, dentry)) == NULL) return(-ENOMEM); 716 if((file = inode_dentry_name(ino, dentry)) == NULL)
717 return -ENOMEM;
710 err = make_symlink(file, to); 718 err = make_symlink(file, to);
711 kfree(file); 719 kfree(file);
712 return(err); 720 return err;
713} 721}
714 722
715int hostfs_mkdir(struct inode *ino, struct dentry *dentry, int mode) 723int hostfs_mkdir(struct inode *ino, struct dentry *dentry, int mode)
@@ -717,10 +725,11 @@ int hostfs_mkdir(struct inode *ino, struct dentry *dentry, int mode)
717 char *file; 725 char *file;
718 int err; 726 int err;
719 727
720 if((file = inode_dentry_name(ino, dentry)) == NULL) return(-ENOMEM); 728 if((file = inode_dentry_name(ino, dentry)) == NULL)
729 return -ENOMEM;
721 err = do_mkdir(file, mode); 730 err = do_mkdir(file, mode);
722 kfree(file); 731 kfree(file);
723 return(err); 732 return err;
724} 733}
725 734
726int hostfs_rmdir(struct inode *ino, struct dentry *dentry) 735int hostfs_rmdir(struct inode *ino, struct dentry *dentry)
@@ -728,10 +737,11 @@ int hostfs_rmdir(struct inode *ino, struct dentry *dentry)
728 char *file; 737 char *file;
729 int err; 738 int err;
730 739
731 if((file = inode_dentry_name(ino, dentry)) == NULL) return(-ENOMEM); 740 if((file = inode_dentry_name(ino, dentry)) == NULL)
741 return -ENOMEM;
732 err = do_rmdir(file); 742 err = do_rmdir(file);
733 kfree(file); 743 kfree(file);
734 return(err); 744 return err;
735} 745}
736 746
737int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) 747int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
@@ -764,14 +774,14 @@ int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
764 goto out_put; 774 goto out_put;
765 775
766 d_instantiate(dentry, inode); 776 d_instantiate(dentry, inode);
767 return(0); 777 return 0;
768 778
769 out_free: 779 out_free:
770 kfree(name); 780 kfree(name);
771 out_put: 781 out_put:
772 iput(inode); 782 iput(inode);
773 out: 783 out:
774 return(err); 784 return err;
775} 785}
776 786
777int hostfs_rename(struct inode *from_ino, struct dentry *from, 787int hostfs_rename(struct inode *from_ino, struct dentry *from,
@@ -781,15 +791,15 @@ int hostfs_rename(struct inode *from_ino, struct dentry *from,
781 int err; 791 int err;
782 792
783 if((from_name = inode_dentry_name(from_ino, from)) == NULL) 793 if((from_name = inode_dentry_name(from_ino, from)) == NULL)
784 return(-ENOMEM); 794 return -ENOMEM;
785 if((to_name = inode_dentry_name(to_ino, to)) == NULL){ 795 if((to_name = inode_dentry_name(to_ino, to)) == NULL){
786 kfree(from_name); 796 kfree(from_name);
787 return(-ENOMEM); 797 return -ENOMEM;
788 } 798 }
789 err = rename_file(from_name, to_name); 799 err = rename_file(from_name, to_name);
790 kfree(from_name); 800 kfree(from_name);
791 kfree(to_name); 801 kfree(to_name);
792 return(err); 802 return err;
793} 803}
794 804
795int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd) 805int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd)
@@ -801,7 +811,8 @@ int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd)
801 if (desired & MAY_WRITE) w = 1; 811 if (desired & MAY_WRITE) w = 1;
802 if (desired & MAY_EXEC) x = 1; 812 if (desired & MAY_EXEC) x = 1;
803 name = inode_name(ino, 0); 813 name = inode_name(ino, 0);
804 if (name == NULL) return(-ENOMEM); 814 if (name == NULL)
815 return -ENOMEM;
805 816
806 if (S_ISCHR(ino->i_mode) || S_ISBLK(ino->i_mode) || 817 if (S_ISCHR(ino->i_mode) || S_ISBLK(ino->i_mode) ||
807 S_ISFIFO(ino->i_mode) || S_ISSOCK(ino->i_mode)) 818 S_ISFIFO(ino->i_mode) || S_ISSOCK(ino->i_mode))
@@ -865,20 +876,21 @@ int hostfs_setattr(struct dentry *dentry, struct iattr *attr)
865 attrs.ia_valid |= HOSTFS_ATTR_MTIME_SET; 876 attrs.ia_valid |= HOSTFS_ATTR_MTIME_SET;
866 } 877 }
867 name = dentry_name(dentry, 0); 878 name = dentry_name(dentry, 0);
868 if(name == NULL) return(-ENOMEM); 879 if(name == NULL)
880 return -ENOMEM;
869 err = set_attr(name, &attrs, fd); 881 err = set_attr(name, &attrs, fd);
870 kfree(name); 882 kfree(name);
871 if(err) 883 if(err)
872 return(err); 884 return err;
873 885
874 return(inode_setattr(dentry->d_inode, attr)); 886 return inode_setattr(dentry->d_inode, attr);
875} 887}
876 888
877int hostfs_getattr(struct vfsmount *mnt, struct dentry *dentry, 889int hostfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
878 struct kstat *stat) 890 struct kstat *stat)
879{ 891{
880 generic_fillattr(dentry->d_inode, stat); 892 generic_fillattr(dentry->d_inode, stat);
881 return(0); 893 return 0;
882} 894}
883 895
884static const struct inode_operations hostfs_iops = { 896static const struct inode_operations hostfs_iops = {
@@ -917,7 +929,8 @@ int hostfs_link_readpage(struct file *file, struct page *page)
917 929
918 buffer = kmap(page); 930 buffer = kmap(page);
919 name = inode_name(page->mapping->host, 0); 931 name = inode_name(page->mapping->host, 0);
920 if(name == NULL) return(-ENOMEM); 932 if(name == NULL)
933 return -ENOMEM;
921 err = do_readlink(name, buffer, PAGE_CACHE_SIZE); 934 err = do_readlink(name, buffer, PAGE_CACHE_SIZE);
922 kfree(name); 935 kfree(name);
923 if(err == PAGE_CACHE_SIZE) 936 if(err == PAGE_CACHE_SIZE)
@@ -930,7 +943,7 @@ int hostfs_link_readpage(struct file *file, struct page *page)
930 } 943 }
931 kunmap(page); 944 kunmap(page);
932 unlock_page(page); 945 unlock_page(page);
933 return(err); 946 return err;
934} 947}
935 948
936static const struct address_space_operations hostfs_link_aops = { 949static const struct address_space_operations hostfs_link_aops = {
@@ -980,20 +993,20 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
980 993
981 err = read_inode(root_inode); 994 err = read_inode(root_inode);
982 if(err){ 995 if(err){
983 /* No iput in this case because the dput does that for us */ 996 /* No iput in this case because the dput does that for us */
984 dput(sb->s_root); 997 dput(sb->s_root);
985 sb->s_root = NULL; 998 sb->s_root = NULL;
986 goto out; 999 goto out;
987 } 1000 }
988 1001
989 return(0); 1002 return 0;
990 1003
991 out_put: 1004out_put:
992 iput(root_inode); 1005 iput(root_inode);
993 out_free: 1006out_free:
994 kfree(host_root_path); 1007 kfree(host_root_path);
995 out: 1008out:
996 return(err); 1009 return err;
997} 1010}
998 1011
999static int hostfs_read_sb(struct file_system_type *type, 1012static int hostfs_read_sb(struct file_system_type *type,
@@ -1013,7 +1026,7 @@ static struct file_system_type hostfs_type = {
1013 1026
1014static int __init init_hostfs(void) 1027static int __init init_hostfs(void)
1015{ 1028{
1016 return(register_filesystem(&hostfs_type)); 1029 return register_filesystem(&hostfs_type);
1017} 1030}
1018 1031
1019static void __exit exit_hostfs(void) 1032static void __exit exit_hostfs(void)
@@ -1024,14 +1037,3 @@ static void __exit exit_hostfs(void)
1024module_init(init_hostfs) 1037module_init(init_hostfs)
1025module_exit(exit_hostfs) 1038module_exit(exit_hostfs)
1026MODULE_LICENSE("GPL"); 1039MODULE_LICENSE("GPL");
1027
1028/*
1029 * Overrides for Emacs so that we follow Linus's tabbing style.
1030 * Emacs will notice this stuff at the end of the file and automatically
1031 * adjust the settings for this buffer only. This must remain at the end
1032 * of the file.
1033 * ---------------------------------------------------------------------------
1034 * Local variables:
1035 * c-file-style: "linux"
1036 * End:
1037 */
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
58int file_type(const char *path, int *maj, int *min) 58int 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
80int access_file(char *path, int r, int w, int x) 80int 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
91int open_file(char *path, int r, int w, int append) 92int 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
110void *open_dir(char *path, int *err_out) 112void *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
120char *read_dir(void *stream, unsigned long long *pos, 123char *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
135int read_file(int fd, unsigned long long *offset, char *buf, int len) 139int 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
145int write_file(int fd, unsigned long long *offset, const char *buf, int len) 150int 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
155int lseek_file(int fd, long long offset, int whence) 161int 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
165int fsync_file(int fd, int datasync) 171int 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
209int set_attr(const char *file, struct hostfs_iattr *attrs, int fd) 215int 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
290int make_symlink(const char *from, const char *to) 297int 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
299int unlink_file(const char *file) 307int 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
308int do_mkdir(const char *file, int mode) 317int 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
317int do_rmdir(const char *file) 327int 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
326int do_mknod(const char *file, int mode, unsigned int major, unsigned int minor) 337int 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
335int link_file(const char *to, const char *from) 347int 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
344int do_readlink(char *file, char *buf, int size) 357int 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
356int rename_file(char *from, char *to) 369int 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
365int do_statfs(char *root, long *bsize_out, long long *blocks_out, 379int 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 */