diff options
Diffstat (limited to 'fs/hostfs/hostfs_kern.c')
-rw-r--r-- | fs/hostfs/hostfs_kern.c | 186 |
1 files changed, 94 insertions, 92 deletions
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 | ||
32 | static inline struct hostfs_inode_info *HOSTFS_I(struct inode *inode) | 32 | static 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 | ||
39 | int hostfs_d_delete(struct dentry *dentry) | 39 | int hostfs_d_delete(struct dentry *dentry) |
40 | { | 40 | { |
41 | return(1); | 41 | return 1; |
42 | } | 42 | } |
43 | 43 | ||
44 | struct dentry_operations hostfs_dentry_ops = { | 44 | struct 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 | ||
128 | static char *inode_name(struct inode *ino, int extra) | 129 | static 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 | ||
136 | static int read_name(struct inode *ino, char *name) | 137 | static 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 | ||
162 | static char *follow_link(char *link) | 163 | static 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 | ||
210 | static int read_inode(struct inode *ino) | 211 | static 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 | ||
240 | int hostfs_statfs(struct dentry *dentry, struct kstatfs *sf) | 241 | int 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 | ||
267 | static struct inode *hostfs_alloc_inode(struct super_block *sb) | 269 | static 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 | ||
282 | static void hostfs_delete_inode(struct inode *inode) | 284 | static 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 | ||
343 | int hostfs_file_open(struct inode *ino, struct file *file) | 347 | int 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 | ||
380 | int hostfs_fsync(struct file *file, struct dentry *dentry, int datasync) | 385 | int 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 | ||
464 | int hostfs_prepare_write(struct file *file, struct page *page, | 469 | int 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 | ||
491 | int hostfs_commit_write(struct file *file, struct page *page, unsigned from, | 496 | int 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 | ||
517 | static const struct address_space_operations hostfs_aops = { | 522 | static 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 | ||
575 | int hostfs_create(struct inode *dir, struct dentry *dentry, int mode, | 580 | int 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 | ||
618 | struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry, | 623 | struct 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 | ||
658 | static char *inode_dentry_name(struct inode *ino, struct dentry *dentry) | 663 | static 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 | ||
672 | int hostfs_link(struct dentry *to, struct inode *ino, struct dentry *from) | 678 | int 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 | ||
690 | int hostfs_unlink(struct inode *ino, struct dentry *dentry) | 696 | int 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 | ||
704 | int hostfs_symlink(struct inode *ino, struct dentry *dentry, const char *to) | 711 | int 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 | ||
715 | int hostfs_mkdir(struct inode *ino, struct dentry *dentry, int mode) | 723 | int 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 | ||
726 | int hostfs_rmdir(struct inode *ino, struct dentry *dentry) | 735 | int 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 | ||
737 | int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) | 747 | int 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 | ||
777 | int hostfs_rename(struct inode *from_ino, struct dentry *from, | 787 | int 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 | ||
795 | int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd) | 805 | int 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 | ||
877 | int hostfs_getattr(struct vfsmount *mnt, struct dentry *dentry, | 889 | int 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 | ||
884 | static const struct inode_operations hostfs_iops = { | 896 | static 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 | ||
936 | static const struct address_space_operations hostfs_link_aops = { | 949 | static 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: | 1004 | out_put: |
992 | iput(root_inode); | 1005 | iput(root_inode); |
993 | out_free: | 1006 | out_free: |
994 | kfree(host_root_path); | 1007 | kfree(host_root_path); |
995 | out: | 1008 | out: |
996 | return(err); | 1009 | return err; |
997 | } | 1010 | } |
998 | 1011 | ||
999 | static int hostfs_read_sb(struct file_system_type *type, | 1012 | static int hostfs_read_sb(struct file_system_type *type, |
@@ -1013,7 +1026,7 @@ static struct file_system_type hostfs_type = { | |||
1013 | 1026 | ||
1014 | static int __init init_hostfs(void) | 1027 | static int __init init_hostfs(void) |
1015 | { | 1028 | { |
1016 | return(register_filesystem(&hostfs_type)); | 1029 | return register_filesystem(&hostfs_type); |
1017 | } | 1030 | } |
1018 | 1031 | ||
1019 | static void __exit exit_hostfs(void) | 1032 | static void __exit exit_hostfs(void) |
@@ -1024,14 +1037,3 @@ static void __exit exit_hostfs(void) | |||
1024 | module_init(init_hostfs) | 1037 | module_init(init_hostfs) |
1025 | module_exit(exit_hostfs) | 1038 | module_exit(exit_hostfs) |
1026 | MODULE_LICENSE("GPL"); | 1039 | MODULE_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 | */ | ||