diff options
Diffstat (limited to 'fs/befs/linuxvfs.c')
-rw-r--r-- | fs/befs/linuxvfs.c | 106 |
1 files changed, 54 insertions, 52 deletions
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 079872d61f75..5188f1222987 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c | |||
@@ -5,6 +5,8 @@ | |||
5 | * | 5 | * |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
9 | |||
8 | #include <linux/module.h> | 10 | #include <linux/module.h> |
9 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
10 | #include <linux/fs.h> | 12 | #include <linux/fs.h> |
@@ -130,26 +132,28 @@ befs_get_block(struct inode *inode, sector_t block, | |||
130 | ulong disk_off; | 132 | ulong disk_off; |
131 | 133 | ||
132 | befs_debug(sb, "---> befs_get_block() for inode %lu, block %ld", | 134 | befs_debug(sb, "---> befs_get_block() for inode %lu, block %ld", |
133 | inode->i_ino, block); | 135 | (unsigned long)inode->i_ino, (long)block); |
134 | 136 | ||
135 | if (block < 0) { | 137 | if (block < 0) { |
136 | befs_error(sb, "befs_get_block() was asked for a block " | 138 | befs_error(sb, "befs_get_block() was asked for a block " |
137 | "number less than zero: block %ld in inode %lu", | 139 | "number less than zero: block %ld in inode %lu", |
138 | block, inode->i_ino); | 140 | (long)block, (unsigned long)inode->i_ino); |
139 | return -EIO; | 141 | return -EIO; |
140 | } | 142 | } |
141 | 143 | ||
142 | if (create) { | 144 | if (create) { |
143 | befs_error(sb, "befs_get_block() was asked to write to " | 145 | befs_error(sb, "befs_get_block() was asked to write to " |
144 | "block %ld in inode %lu", block, inode->i_ino); | 146 | "block %ld in inode %lu", (long)block, |
147 | (unsigned long)inode->i_ino); | ||
145 | return -EPERM; | 148 | return -EPERM; |
146 | } | 149 | } |
147 | 150 | ||
148 | res = befs_fblock2brun(sb, ds, block, &run); | 151 | res = befs_fblock2brun(sb, ds, block, &run); |
149 | if (res != BEFS_OK) { | 152 | if (res != BEFS_OK) { |
150 | befs_error(sb, | 153 | befs_error(sb, |
151 | "<--- befs_get_block() for inode %lu, block " | 154 | "<--- %s for inode %lu, block %ld ERROR", |
152 | "%ld ERROR", inode->i_ino, block); | 155 | __func__, (unsigned long)inode->i_ino, |
156 | (long)block); | ||
153 | return -EFBIG; | 157 | return -EFBIG; |
154 | } | 158 | } |
155 | 159 | ||
@@ -157,8 +161,9 @@ befs_get_block(struct inode *inode, sector_t block, | |||
157 | 161 | ||
158 | map_bh(bh_result, inode->i_sb, disk_off); | 162 | map_bh(bh_result, inode->i_sb, disk_off); |
159 | 163 | ||
160 | befs_debug(sb, "<--- befs_get_block() for inode %lu, block %ld, " | 164 | befs_debug(sb, "<--- %s for inode %lu, block %ld, disk address %lu", |
161 | "disk address %lu", inode->i_ino, block, disk_off); | 165 | __func__, (unsigned long)inode->i_ino, (long)block, |
166 | (unsigned long)disk_off); | ||
162 | 167 | ||
163 | return 0; | 168 | return 0; |
164 | } | 169 | } |
@@ -175,15 +180,15 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) | |||
175 | char *utfname; | 180 | char *utfname; |
176 | const char *name = dentry->d_name.name; | 181 | const char *name = dentry->d_name.name; |
177 | 182 | ||
178 | befs_debug(sb, "---> befs_lookup() " | 183 | befs_debug(sb, "---> %s name %s inode %ld", __func__, |
179 | "name %s inode %ld", dentry->d_name.name, dir->i_ino); | 184 | dentry->d_name.name, dir->i_ino); |
180 | 185 | ||
181 | /* Convert to UTF-8 */ | 186 | /* Convert to UTF-8 */ |
182 | if (BEFS_SB(sb)->nls) { | 187 | if (BEFS_SB(sb)->nls) { |
183 | ret = | 188 | ret = |
184 | befs_nls2utf(sb, name, strlen(name), &utfname, &utfnamelen); | 189 | befs_nls2utf(sb, name, strlen(name), &utfname, &utfnamelen); |
185 | if (ret < 0) { | 190 | if (ret < 0) { |
186 | befs_debug(sb, "<--- befs_lookup() ERROR"); | 191 | befs_debug(sb, "<--- %s ERROR", __func__); |
187 | return ERR_PTR(ret); | 192 | return ERR_PTR(ret); |
188 | } | 193 | } |
189 | ret = befs_btree_find(sb, ds, utfname, &offset); | 194 | ret = befs_btree_find(sb, ds, utfname, &offset); |
@@ -194,12 +199,12 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) | |||
194 | } | 199 | } |
195 | 200 | ||
196 | if (ret == BEFS_BT_NOT_FOUND) { | 201 | if (ret == BEFS_BT_NOT_FOUND) { |
197 | befs_debug(sb, "<--- befs_lookup() %s not found", | 202 | befs_debug(sb, "<--- %s %s not found", __func__, |
198 | dentry->d_name.name); | 203 | dentry->d_name.name); |
199 | return ERR_PTR(-ENOENT); | 204 | return ERR_PTR(-ENOENT); |
200 | 205 | ||
201 | } else if (ret != BEFS_OK || offset == 0) { | 206 | } else if (ret != BEFS_OK || offset == 0) { |
202 | befs_warning(sb, "<--- befs_lookup() Error"); | 207 | befs_warning(sb, "<--- %s Error", __func__); |
203 | return ERR_PTR(-ENODATA); | 208 | return ERR_PTR(-ENODATA); |
204 | } | 209 | } |
205 | 210 | ||
@@ -209,7 +214,7 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) | |||
209 | 214 | ||
210 | d_add(dentry, inode); | 215 | d_add(dentry, inode); |
211 | 216 | ||
212 | befs_debug(sb, "<--- befs_lookup()"); | 217 | befs_debug(sb, "<--- %s", __func__); |
213 | 218 | ||
214 | return NULL; | 219 | return NULL; |
215 | } | 220 | } |
@@ -227,26 +232,25 @@ befs_readdir(struct file *file, struct dir_context *ctx) | |||
227 | char keybuf[BEFS_NAME_LEN + 1]; | 232 | char keybuf[BEFS_NAME_LEN + 1]; |
228 | const char *dirname = file->f_path.dentry->d_name.name; | 233 | const char *dirname = file->f_path.dentry->d_name.name; |
229 | 234 | ||
230 | befs_debug(sb, "---> befs_readdir() " | 235 | befs_debug(sb, "---> %s name %s, inode %ld, ctx->pos %lld", |
231 | "name %s, inode %ld, ctx->pos %Ld", | 236 | __func__, dirname, inode->i_ino, ctx->pos); |
232 | dirname, inode->i_ino, ctx->pos); | ||
233 | 237 | ||
234 | more: | 238 | more: |
235 | result = befs_btree_read(sb, ds, ctx->pos, BEFS_NAME_LEN + 1, | 239 | result = befs_btree_read(sb, ds, ctx->pos, BEFS_NAME_LEN + 1, |
236 | keybuf, &keysize, &value); | 240 | keybuf, &keysize, &value); |
237 | 241 | ||
238 | if (result == BEFS_ERR) { | 242 | if (result == BEFS_ERR) { |
239 | befs_debug(sb, "<--- befs_readdir() ERROR"); | 243 | befs_debug(sb, "<--- %s ERROR", __func__); |
240 | befs_error(sb, "IO error reading %s (inode %lu)", | 244 | befs_error(sb, "IO error reading %s (inode %lu)", |
241 | dirname, inode->i_ino); | 245 | dirname, inode->i_ino); |
242 | return -EIO; | 246 | return -EIO; |
243 | 247 | ||
244 | } else if (result == BEFS_BT_END) { | 248 | } else if (result == BEFS_BT_END) { |
245 | befs_debug(sb, "<--- befs_readdir() END"); | 249 | befs_debug(sb, "<--- %s END", __func__); |
246 | return 0; | 250 | return 0; |
247 | 251 | ||
248 | } else if (result == BEFS_BT_EMPTY) { | 252 | } else if (result == BEFS_BT_EMPTY) { |
249 | befs_debug(sb, "<--- befs_readdir() Empty directory"); | 253 | befs_debug(sb, "<--- %s Empty directory", __func__); |
250 | return 0; | 254 | return 0; |
251 | } | 255 | } |
252 | 256 | ||
@@ -259,7 +263,7 @@ more: | |||
259 | result = | 263 | result = |
260 | befs_utf2nls(sb, keybuf, keysize, &nlsname, &nlsnamelen); | 264 | befs_utf2nls(sb, keybuf, keysize, &nlsname, &nlsnamelen); |
261 | if (result < 0) { | 265 | if (result < 0) { |
262 | befs_debug(sb, "<--- befs_readdir() ERROR"); | 266 | befs_debug(sb, "<--- %s ERROR", __func__); |
263 | return result; | 267 | return result; |
264 | } | 268 | } |
265 | if (!dir_emit(ctx, nlsname, nlsnamelen, | 269 | if (!dir_emit(ctx, nlsname, nlsnamelen, |
@@ -276,7 +280,7 @@ more: | |||
276 | ctx->pos++; | 280 | ctx->pos++; |
277 | goto more; | 281 | goto more; |
278 | 282 | ||
279 | befs_debug(sb, "<--- befs_readdir() pos %Ld", ctx->pos); | 283 | befs_debug(sb, "<--- %s pos %lld", __func__, ctx->pos); |
280 | 284 | ||
281 | return 0; | 285 | return 0; |
282 | } | 286 | } |
@@ -320,7 +324,7 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino) | |||
320 | struct inode *inode; | 324 | struct inode *inode; |
321 | long ret = -EIO; | 325 | long ret = -EIO; |
322 | 326 | ||
323 | befs_debug(sb, "---> befs_read_inode() " "inode = %lu", ino); | 327 | befs_debug(sb, "---> %s inode = %lu", __func__, ino); |
324 | 328 | ||
325 | inode = iget_locked(sb, ino); | 329 | inode = iget_locked(sb, ino); |
326 | if (!inode) | 330 | if (!inode) |
@@ -427,7 +431,7 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino) | |||
427 | } | 431 | } |
428 | 432 | ||
429 | brelse(bh); | 433 | brelse(bh); |
430 | befs_debug(sb, "<--- befs_read_inode()"); | 434 | befs_debug(sb, "<--- %s", __func__); |
431 | unlock_new_inode(inode); | 435 | unlock_new_inode(inode); |
432 | return inode; | 436 | return inode; |
433 | 437 | ||
@@ -436,7 +440,7 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino) | |||
436 | 440 | ||
437 | unacquire_none: | 441 | unacquire_none: |
438 | iget_failed(inode); | 442 | iget_failed(inode); |
439 | befs_debug(sb, "<--- befs_read_inode() - Bad inode"); | 443 | befs_debug(sb, "<--- %s - Bad inode", __func__); |
440 | return ERR_PTR(ret); | 444 | return ERR_PTR(ret); |
441 | } | 445 | } |
442 | 446 | ||
@@ -453,11 +457,9 @@ befs_init_inodecache(void) | |||
453 | SLAB_MEM_SPREAD), | 457 | SLAB_MEM_SPREAD), |
454 | init_once); | 458 | init_once); |
455 | if (befs_inode_cachep == NULL) { | 459 | if (befs_inode_cachep == NULL) { |
456 | printk(KERN_ERR "befs_init_inodecache: " | 460 | pr_err("%s: Couldn't initialize inode slabcache\n", __func__); |
457 | "Couldn't initialize inode slabcache\n"); | ||
458 | return -ENOMEM; | 461 | return -ENOMEM; |
459 | } | 462 | } |
460 | |||
461 | return 0; | 463 | return 0; |
462 | } | 464 | } |
463 | 465 | ||
@@ -543,16 +545,16 @@ befs_utf2nls(struct super_block *sb, const char *in, | |||
543 | */ | 545 | */ |
544 | int maxlen = in_len + 1; | 546 | int maxlen = in_len + 1; |
545 | 547 | ||
546 | befs_debug(sb, "---> utf2nls()"); | 548 | befs_debug(sb, "---> %s", __func__); |
547 | 549 | ||
548 | if (!nls) { | 550 | if (!nls) { |
549 | befs_error(sb, "befs_utf2nls called with no NLS table loaded"); | 551 | befs_error(sb, "%s called with no NLS table loaded", __func__); |
550 | return -EINVAL; | 552 | return -EINVAL; |
551 | } | 553 | } |
552 | 554 | ||
553 | *out = result = kmalloc(maxlen, GFP_NOFS); | 555 | *out = result = kmalloc(maxlen, GFP_NOFS); |
554 | if (!*out) { | 556 | if (!*out) { |
555 | befs_error(sb, "befs_utf2nls() cannot allocate memory"); | 557 | befs_error(sb, "%s cannot allocate memory", __func__); |
556 | *out_len = 0; | 558 | *out_len = 0; |
557 | return -ENOMEM; | 559 | return -ENOMEM; |
558 | } | 560 | } |
@@ -574,14 +576,14 @@ befs_utf2nls(struct super_block *sb, const char *in, | |||
574 | result[o] = '\0'; | 576 | result[o] = '\0'; |
575 | *out_len = o; | 577 | *out_len = o; |
576 | 578 | ||
577 | befs_debug(sb, "<--- utf2nls()"); | 579 | befs_debug(sb, "<--- %s", __func__); |
578 | 580 | ||
579 | return o; | 581 | return o; |
580 | 582 | ||
581 | conv_err: | 583 | conv_err: |
582 | befs_error(sb, "Name using character set %s contains a character that " | 584 | befs_error(sb, "Name using character set %s contains a character that " |
583 | "cannot be converted to unicode.", nls->charset); | 585 | "cannot be converted to unicode.", nls->charset); |
584 | befs_debug(sb, "<--- utf2nls()"); | 586 | befs_debug(sb, "<--- %s", __func__); |
585 | kfree(result); | 587 | kfree(result); |
586 | return -EILSEQ; | 588 | return -EILSEQ; |
587 | } | 589 | } |
@@ -622,16 +624,17 @@ befs_nls2utf(struct super_block *sb, const char *in, | |||
622 | * in special cases */ | 624 | * in special cases */ |
623 | int maxlen = (3 * in_len) + 1; | 625 | int maxlen = (3 * in_len) + 1; |
624 | 626 | ||
625 | befs_debug(sb, "---> nls2utf()\n"); | 627 | befs_debug(sb, "---> %s\n", __func__); |
626 | 628 | ||
627 | if (!nls) { | 629 | if (!nls) { |
628 | befs_error(sb, "befs_nls2utf called with no NLS table loaded."); | 630 | befs_error(sb, "%s called with no NLS table loaded.", |
631 | __func__); | ||
629 | return -EINVAL; | 632 | return -EINVAL; |
630 | } | 633 | } |
631 | 634 | ||
632 | *out = result = kmalloc(maxlen, GFP_NOFS); | 635 | *out = result = kmalloc(maxlen, GFP_NOFS); |
633 | if (!*out) { | 636 | if (!*out) { |
634 | befs_error(sb, "befs_nls2utf() cannot allocate memory"); | 637 | befs_error(sb, "%s cannot allocate memory", __func__); |
635 | *out_len = 0; | 638 | *out_len = 0; |
636 | return -ENOMEM; | 639 | return -ENOMEM; |
637 | } | 640 | } |
@@ -652,14 +655,14 @@ befs_nls2utf(struct super_block *sb, const char *in, | |||
652 | result[o] = '\0'; | 655 | result[o] = '\0'; |
653 | *out_len = o; | 656 | *out_len = o; |
654 | 657 | ||
655 | befs_debug(sb, "<--- nls2utf()"); | 658 | befs_debug(sb, "<--- %s", __func__); |
656 | 659 | ||
657 | return i; | 660 | return i; |
658 | 661 | ||
659 | conv_err: | 662 | conv_err: |
660 | befs_error(sb, "Name using charecter set %s contains a charecter that " | 663 | befs_error(sb, "Name using charecter set %s contains a charecter that " |
661 | "cannot be converted to unicode.", nls->charset); | 664 | "cannot be converted to unicode.", nls->charset); |
662 | befs_debug(sb, "<--- nls2utf()"); | 665 | befs_debug(sb, "<--- %s", __func__); |
663 | kfree(result); | 666 | kfree(result); |
664 | return -EILSEQ; | 667 | return -EILSEQ; |
665 | } | 668 | } |
@@ -714,8 +717,8 @@ parse_options(char *options, befs_mount_options * opts) | |||
714 | if (option >= 0) | 717 | if (option >= 0) |
715 | uid = make_kuid(current_user_ns(), option); | 718 | uid = make_kuid(current_user_ns(), option); |
716 | if (!uid_valid(uid)) { | 719 | if (!uid_valid(uid)) { |
717 | printk(KERN_ERR "BeFS: Invalid uid %d, " | 720 | pr_err("Invalid uid %d, " |
718 | "using default\n", option); | 721 | "using default\n", option); |
719 | break; | 722 | break; |
720 | } | 723 | } |
721 | opts->uid = uid; | 724 | opts->uid = uid; |
@@ -728,8 +731,8 @@ parse_options(char *options, befs_mount_options * opts) | |||
728 | if (option >= 0) | 731 | if (option >= 0) |
729 | gid = make_kgid(current_user_ns(), option); | 732 | gid = make_kgid(current_user_ns(), option); |
730 | if (!gid_valid(gid)) { | 733 | if (!gid_valid(gid)) { |
731 | printk(KERN_ERR "BeFS: Invalid gid %d, " | 734 | pr_err("Invalid gid %d, " |
732 | "using default\n", option); | 735 | "using default\n", option); |
733 | break; | 736 | break; |
734 | } | 737 | } |
735 | opts->gid = gid; | 738 | opts->gid = gid; |
@@ -739,8 +742,8 @@ parse_options(char *options, befs_mount_options * opts) | |||
739 | kfree(opts->iocharset); | 742 | kfree(opts->iocharset); |
740 | opts->iocharset = match_strdup(&args[0]); | 743 | opts->iocharset = match_strdup(&args[0]); |
741 | if (!opts->iocharset) { | 744 | if (!opts->iocharset) { |
742 | printk(KERN_ERR "BeFS: allocation failure for " | 745 | pr_err("allocation failure for " |
743 | "iocharset string\n"); | 746 | "iocharset string\n"); |
744 | return 0; | 747 | return 0; |
745 | } | 748 | } |
746 | break; | 749 | break; |
@@ -748,8 +751,8 @@ parse_options(char *options, befs_mount_options * opts) | |||
748 | opts->debug = 1; | 751 | opts->debug = 1; |
749 | break; | 752 | break; |
750 | default: | 753 | default: |
751 | printk(KERN_ERR "BeFS: Unrecognized mount option \"%s\" " | 754 | pr_err("Unrecognized mount option \"%s\" " |
752 | "or missing value\n", p); | 755 | "or missing value\n", p); |
753 | return 0; | 756 | return 0; |
754 | } | 757 | } |
755 | } | 758 | } |
@@ -792,8 +795,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent) | |||
792 | 795 | ||
793 | sb->s_fs_info = kzalloc(sizeof(*befs_sb), GFP_KERNEL); | 796 | sb->s_fs_info = kzalloc(sizeof(*befs_sb), GFP_KERNEL); |
794 | if (sb->s_fs_info == NULL) { | 797 | if (sb->s_fs_info == NULL) { |
795 | printk(KERN_ERR | 798 | pr_err("(%s): Unable to allocate memory for private " |
796 | "BeFS(%s): Unable to allocate memory for private " | ||
797 | "portion of superblock. Bailing.\n", sb->s_id); | 799 | "portion of superblock. Bailing.\n", sb->s_id); |
798 | goto unacquire_none; | 800 | goto unacquire_none; |
799 | } | 801 | } |
@@ -804,7 +806,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent) | |||
804 | goto unacquire_priv_sbp; | 806 | goto unacquire_priv_sbp; |
805 | } | 807 | } |
806 | 808 | ||
807 | befs_debug(sb, "---> befs_fill_super()"); | 809 | befs_debug(sb, "---> %s", __func__); |
808 | 810 | ||
809 | #ifndef CONFIG_BEFS_RW | 811 | #ifndef CONFIG_BEFS_RW |
810 | if (!(sb->s_flags & MS_RDONLY)) { | 812 | if (!(sb->s_flags & MS_RDONLY)) { |
@@ -852,7 +854,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent) | |||
852 | goto unacquire_priv_sbp; | 854 | goto unacquire_priv_sbp; |
853 | 855 | ||
854 | if( befs_sb->num_blocks > ~((sector_t)0) ) { | 856 | if( befs_sb->num_blocks > ~((sector_t)0) ) { |
855 | befs_error(sb, "blocks count: %Lu " | 857 | befs_error(sb, "blocks count: %llu " |
856 | "is larger than the host can use", | 858 | "is larger than the host can use", |
857 | befs_sb->num_blocks); | 859 | befs_sb->num_blocks); |
858 | goto unacquire_priv_sbp; | 860 | goto unacquire_priv_sbp; |
@@ -922,7 +924,7 @@ befs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
922 | struct super_block *sb = dentry->d_sb; | 924 | struct super_block *sb = dentry->d_sb; |
923 | u64 id = huge_encode_dev(sb->s_bdev->bd_dev); | 925 | u64 id = huge_encode_dev(sb->s_bdev->bd_dev); |
924 | 926 | ||
925 | befs_debug(sb, "---> befs_statfs()"); | 927 | befs_debug(sb, "---> %s", __func__); |
926 | 928 | ||
927 | buf->f_type = BEFS_SUPER_MAGIC; | 929 | buf->f_type = BEFS_SUPER_MAGIC; |
928 | buf->f_bsize = sb->s_blocksize; | 930 | buf->f_bsize = sb->s_blocksize; |
@@ -935,7 +937,7 @@ befs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
935 | buf->f_fsid.val[1] = (u32)(id >> 32); | 937 | buf->f_fsid.val[1] = (u32)(id >> 32); |
936 | buf->f_namelen = BEFS_NAME_LEN; | 938 | buf->f_namelen = BEFS_NAME_LEN; |
937 | 939 | ||
938 | befs_debug(sb, "<--- befs_statfs()"); | 940 | befs_debug(sb, "<--- %s", __func__); |
939 | 941 | ||
940 | return 0; | 942 | return 0; |
941 | } | 943 | } |
@@ -961,7 +963,7 @@ init_befs_fs(void) | |||
961 | { | 963 | { |
962 | int err; | 964 | int err; |
963 | 965 | ||
964 | printk(KERN_INFO "BeFS version: %s\n", BEFS_VERSION); | 966 | pr_info("version: %s\n", BEFS_VERSION); |
965 | 967 | ||
966 | err = befs_init_inodecache(); | 968 | err = befs_init_inodecache(); |
967 | if (err) | 969 | if (err) |