2 * linux/fs/befs/linuxvfs.c
4 * Copyright (C) 2001 Will Dyson <will_dyson@pobox.com
8 #include <linux/module.h>
9 #include <linux/slab.h>
11 #include <linux/errno.h>
12 #include <linux/stat.h>
13 #include <linux/nls.h>
14 #include <linux/buffer_head.h>
15 #include <linux/vfs.h>
20 #include "datastream.h"
25 MODULE_DESCRIPTION("BeOS File System (BeFS) driver");
26 MODULE_AUTHOR("Will Dyson");
27 MODULE_LICENSE("GPL");
29 /* The units the vfs expects inode->i_blocks to be in */
30 #define VFS_BLOCK_SIZE 512
32 static int befs_readdir(struct file
*, void *, filldir_t
);
33 static int befs_get_block(struct inode
*, sector_t
, struct buffer_head
*, int);
34 static int befs_readpage(struct file
*file
, struct page
*page
);
35 static sector_t
befs_bmap(struct address_space
*mapping
, sector_t block
);
36 static struct dentry
*befs_lookup(struct inode
*, struct dentry
*, struct nameidata
*);
37 static void befs_read_inode(struct inode
*ino
);
38 static struct inode
*befs_alloc_inode(struct super_block
*sb
);
39 static void befs_destroy_inode(struct inode
*inode
);
40 static int befs_init_inodecache(void);
41 static void befs_destroy_inodecache(void);
42 static int befs_readlink(struct dentry
*, char *, int);
43 static int befs_follow_link(struct dentry
*, struct nameidata
*nd
);
44 static int befs_utf2nls(struct super_block
*sb
, const char *in
, int in_len
,
45 char **out
, int *out_len
);
46 static int befs_nls2utf(struct super_block
*sb
, const char *in
, int in_len
,
47 char **out
, int *out_len
);
48 static void befs_put_super(struct super_block
*);
49 static int befs_remount(struct super_block
*, int *, char *);
50 static int befs_statfs(struct super_block
*, struct kstatfs
*);
51 static int parse_options(char *, befs_mount_options
*);
53 static const struct super_operations befs_sops
= {
54 .read_inode
= befs_read_inode
, /* initialize & read inode */
55 .alloc_inode
= befs_alloc_inode
, /* allocate a new inode */
56 .destroy_inode
= befs_destroy_inode
, /* deallocate an inode */
57 .put_super
= befs_put_super
, /* uninit super */
58 .statfs
= befs_statfs
, /* statfs */
59 .remount_fs
= befs_remount
,
62 /* slab cache for befs_inode_info objects */
63 static kmem_cache_t
*befs_inode_cachep
;
65 struct file_operations befs_dir_operations
= {
66 .read
= generic_read_dir
,
67 .readdir
= befs_readdir
,
70 struct inode_operations befs_dir_inode_operations
= {
71 .lookup
= befs_lookup
,
74 struct file_operations befs_file_operations
= {
75 .llseek
= default_llseek
,
76 .read
= generic_file_read
,
77 .mmap
= generic_file_readonly_mmap
,
80 struct address_space_operations befs_aops
= {
81 .readpage
= befs_readpage
,
82 .sync_page
= block_sync_page
,
86 static struct inode_operations befs_symlink_inode_operations
= {
87 .readlink
= befs_readlink
,
88 .follow_link
= befs_follow_link
,
92 * Called by generic_file_read() to read a page of data
94 * In turn, simply calls a generic block read function and
95 * passes it the address of befs_get_block, for mapping file
96 * positions to disk blocks.
99 befs_readpage(struct file
*file
, struct page
*page
)
101 return block_read_full_page(page
, befs_get_block
);
105 befs_bmap(struct address_space
*mapping
, sector_t block
)
107 return generic_block_bmap(mapping
, block
, befs_get_block
);
111 * Generic function to map a file position (block) to a
112 * disk offset (passed back in bh_result).
114 * Used by many higher level functions.
116 * Calls befs_fblock2brun() in datastream.c to do the real work.
122 befs_get_block(struct inode
*inode
, sector_t block
,
123 struct buffer_head
*bh_result
, int create
)
125 struct super_block
*sb
= inode
->i_sb
;
126 befs_data_stream
*ds
= &BEFS_I(inode
)->i_data
.ds
;
127 befs_block_run run
= BAD_IADDR
;
131 befs_debug(sb
, "---> befs_get_block() for inode %lu, block %ld",
132 inode
->i_ino
, block
);
135 befs_error(sb
, "befs_get_block() was asked for a block "
136 "number less than zero: block %ld in inode %lu",
137 block
, inode
->i_ino
);
142 befs_error(sb
, "befs_get_block() was asked to write to "
143 "block %ld in inode %lu", block
, inode
->i_ino
);
147 res
= befs_fblock2brun(sb
, ds
, block
, &run
);
148 if (res
!= BEFS_OK
) {
150 "<--- befs_get_block() for inode %lu, block "
151 "%ld ERROR", inode
->i_ino
, block
);
155 disk_off
= (ulong
) iaddr2blockno(sb
, &run
);
157 map_bh(bh_result
, inode
->i_sb
, disk_off
);
159 befs_debug(sb
, "<--- befs_get_block() for inode %lu, block %ld, "
160 "disk address %lu", inode
->i_ino
, block
, disk_off
);
165 static struct dentry
*
166 befs_lookup(struct inode
*dir
, struct dentry
*dentry
, struct nameidata
*nd
)
168 struct inode
*inode
= NULL
;
169 struct super_block
*sb
= dir
->i_sb
;
170 befs_data_stream
*ds
= &BEFS_I(dir
)->i_data
.ds
;
175 const char *name
= dentry
->d_name
.name
;
177 befs_debug(sb
, "---> befs_lookup() "
178 "name %s inode %ld", dentry
->d_name
.name
, dir
->i_ino
);
180 /* Convert to UTF-8 */
181 if (BEFS_SB(sb
)->nls
) {
183 befs_nls2utf(sb
, name
, strlen(name
), &utfname
, &utfnamelen
);
185 befs_debug(sb
, "<--- befs_lookup() ERROR");
188 ret
= befs_btree_find(sb
, ds
, utfname
, &offset
);
192 ret
= befs_btree_find(sb
, ds
, dentry
->d_name
.name
, &offset
);
195 if (ret
== BEFS_BT_NOT_FOUND
) {
196 befs_debug(sb
, "<--- befs_lookup() %s not found",
197 dentry
->d_name
.name
);
198 return ERR_PTR(-ENOENT
);
200 } else if (ret
!= BEFS_OK
|| offset
== 0) {
201 befs_warning(sb
, "<--- befs_lookup() Error");
202 return ERR_PTR(-ENODATA
);
205 inode
= iget(dir
->i_sb
, (ino_t
) offset
);
207 return ERR_PTR(-EACCES
);
209 d_add(dentry
, inode
);
211 befs_debug(sb
, "<--- befs_lookup()");
217 befs_readdir(struct file
*filp
, void *dirent
, filldir_t filldir
)
219 struct inode
*inode
= filp
->f_dentry
->d_inode
;
220 struct super_block
*sb
= inode
->i_sb
;
221 befs_data_stream
*ds
= &BEFS_I(inode
)->i_data
.ds
;
225 unsigned char d_type
;
226 char keybuf
[BEFS_NAME_LEN
+ 1];
229 const char *dirname
= filp
->f_dentry
->d_name
.name
;
231 befs_debug(sb
, "---> befs_readdir() "
232 "name %s, inode %ld, filp->f_pos %Ld",
233 dirname
, inode
->i_ino
, filp
->f_pos
);
235 result
= befs_btree_read(sb
, ds
, filp
->f_pos
, BEFS_NAME_LEN
+ 1,
236 keybuf
, &keysize
, &value
);
238 if (result
== BEFS_ERR
) {
239 befs_debug(sb
, "<--- befs_readdir() ERROR");
240 befs_error(sb
, "IO error reading %s (inode %lu)",
241 dirname
, inode
->i_ino
);
244 } else if (result
== BEFS_BT_END
) {
245 befs_debug(sb
, "<--- befs_readdir() END");
248 } else if (result
== BEFS_BT_EMPTY
) {
249 befs_debug(sb
, "<--- befs_readdir() Empty directory");
256 if (BEFS_SB(sb
)->nls
) {
258 befs_utf2nls(sb
, keybuf
, keysize
, &nlsname
, &nlsnamelen
);
260 befs_debug(sb
, "<--- befs_readdir() ERROR");
263 result
= filldir(dirent
, nlsname
, nlsnamelen
, filp
->f_pos
,
264 (ino_t
) value
, d_type
);
268 result
= filldir(dirent
, keybuf
, keysize
, filp
->f_pos
,
269 (ino_t
) value
, d_type
);
274 befs_debug(sb
, "<--- befs_readdir() filp->f_pos %Ld", filp
->f_pos
);
279 static struct inode
*
280 befs_alloc_inode(struct super_block
*sb
)
282 struct befs_inode_info
*bi
;
283 bi
= (struct befs_inode_info
*)kmem_cache_alloc(befs_inode_cachep
,
287 return &bi
->vfs_inode
;
291 befs_destroy_inode(struct inode
*inode
)
293 kmem_cache_free(befs_inode_cachep
, BEFS_I(inode
));
296 static void init_once(void * foo
, kmem_cache_t
* cachep
, unsigned long flags
)
298 struct befs_inode_info
*bi
= (struct befs_inode_info
*) foo
;
300 if ((flags
& (SLAB_CTOR_VERIFY
|SLAB_CTOR_CONSTRUCTOR
)) ==
301 SLAB_CTOR_CONSTRUCTOR
) {
302 inode_init_once(&bi
->vfs_inode
);
307 befs_read_inode(struct inode
*inode
)
309 struct buffer_head
*bh
= NULL
;
310 befs_inode
*raw_inode
= NULL
;
312 struct super_block
*sb
= inode
->i_sb
;
313 befs_sb_info
*befs_sb
= BEFS_SB(sb
);
314 befs_inode_info
*befs_ino
= NULL
;
316 befs_debug(sb
, "---> befs_read_inode() " "inode = %lu", inode
->i_ino
);
318 befs_ino
= BEFS_I(inode
);
320 /* convert from vfs's inode number to befs's inode number */
321 befs_ino
->i_inode_num
= blockno2iaddr(sb
, inode
->i_ino
);
323 befs_debug(sb
, " real inode number [%u, %hu, %hu]",
324 befs_ino
->i_inode_num
.allocation_group
,
325 befs_ino
->i_inode_num
.start
, befs_ino
->i_inode_num
.len
);
327 bh
= befs_bread_iaddr(sb
, befs_ino
->i_inode_num
);
329 befs_error(sb
, "unable to read inode block - "
330 "inode = %lu", inode
->i_ino
);
334 raw_inode
= (befs_inode
*) bh
->b_data
;
336 befs_dump_inode(sb
, raw_inode
);
338 if (befs_check_inode(sb
, raw_inode
, inode
->i_ino
) != BEFS_OK
) {
339 befs_error(sb
, "Bad inode: %lu", inode
->i_ino
);
343 inode
->i_mode
= (umode_t
) fs32_to_cpu(sb
, raw_inode
->mode
);
346 * set uid and gid. But since current BeOS is single user OS, so
347 * you can change by "uid" or "gid" options.
350 inode
->i_uid
= befs_sb
->mount_opts
.use_uid
?
351 befs_sb
->mount_opts
.uid
: (uid_t
) fs32_to_cpu(sb
, raw_inode
->uid
);
352 inode
->i_gid
= befs_sb
->mount_opts
.use_gid
?
353 befs_sb
->mount_opts
.gid
: (gid_t
) fs32_to_cpu(sb
, raw_inode
->gid
);
358 * BEFS's time is 64 bits, but current VFS is 32 bits...
359 * BEFS don't have access time. Nor inode change time. VFS
360 * doesn't have creation time.
361 * Also, the lower 16 bits of the last_modified_time and
362 * create_time are just a counter to help ensure uniqueness
363 * for indexing purposes. (PFD, page 54)
366 inode
->i_mtime
.tv_sec
=
367 fs64_to_cpu(sb
, raw_inode
->last_modified_time
) >> 16;
368 inode
->i_mtime
.tv_nsec
= 0; /* lower 16 bits are not a time */
369 inode
->i_ctime
= inode
->i_mtime
;
370 inode
->i_atime
= inode
->i_mtime
;
371 inode
->i_blksize
= befs_sb
->block_size
;
373 befs_ino
->i_inode_num
= fsrun_to_cpu(sb
, raw_inode
->inode_num
);
374 befs_ino
->i_parent
= fsrun_to_cpu(sb
, raw_inode
->parent
);
375 befs_ino
->i_attribute
= fsrun_to_cpu(sb
, raw_inode
->attributes
);
376 befs_ino
->i_flags
= fs32_to_cpu(sb
, raw_inode
->flags
);
378 if (S_ISLNK(inode
->i_mode
) && !(inode
->i_flags
& BEFS_LONG_SYMLINK
)) {
380 inode
->i_blocks
= befs_sb
->block_size
/ VFS_BLOCK_SIZE
;
381 strncpy(befs_ino
->i_data
.symlink
, raw_inode
->data
.symlink
,
386 befs_ino
->i_data
.ds
=
387 fsds_to_cpu(sb
, raw_inode
->data
.datastream
);
389 num_blks
= befs_count_blocks(sb
, &befs_ino
->i_data
.ds
);
391 num_blks
* (befs_sb
->block_size
/ VFS_BLOCK_SIZE
);
392 inode
->i_size
= befs_ino
->i_data
.ds
.size
;
395 inode
->i_mapping
->a_ops
= &befs_aops
;
397 if (S_ISREG(inode
->i_mode
)) {
398 inode
->i_fop
= &befs_file_operations
;
399 } else if (S_ISDIR(inode
->i_mode
)) {
400 inode
->i_op
= &befs_dir_inode_operations
;
401 inode
->i_fop
= &befs_dir_operations
;
402 } else if (S_ISLNK(inode
->i_mode
)) {
403 inode
->i_op
= &befs_symlink_inode_operations
;
405 befs_error(sb
, "Inode %lu is not a regular file, "
406 "directory or symlink. THAT IS WRONG! BeFS has no "
407 "on disk special files", inode
->i_ino
);
412 befs_debug(sb
, "<--- befs_read_inode()");
419 make_bad_inode(inode
);
420 befs_debug(sb
, "<--- befs_read_inode() - Bad inode");
424 /* Initialize the inode cache. Called at fs setup.
426 * Taken from NFS implementation by Al Viro.
429 befs_init_inodecache(void)
431 befs_inode_cachep
= kmem_cache_create("befs_inode_cache",
432 sizeof (struct befs_inode_info
),
433 0, SLAB_HWCACHE_ALIGN
|SLAB_RECLAIM_ACCOUNT
,
435 if (befs_inode_cachep
== NULL
) {
436 printk(KERN_ERR
"befs_init_inodecache: "
437 "Couldn't initalize inode slabcache\n");
444 /* Called at fs teardown.
446 * Taken from NFS implementation by Al Viro.
449 befs_destroy_inodecache(void)
451 if (kmem_cache_destroy(befs_inode_cachep
))
452 printk(KERN_ERR
"befs_destroy_inodecache: "
453 "not all structures were freed\n");
457 * The inode of symbolic link is different to data stream.
458 * The data stream become link name. Unless the LONG_SYMLINK
462 befs_follow_link(struct dentry
*dentry
, struct nameidata
*nd
)
464 struct super_block
*sb
= dentry
->d_sb
;
465 befs_inode_info
*befs_ino
= BEFS_I(dentry
->d_inode
);
469 if (befs_ino
->i_flags
& BEFS_LONG_SYMLINK
) {
470 befs_data_stream
*data
= &befs_ino
->i_data
.ds
;
471 befs_off_t linklen
= data
->size
;
473 befs_debug(sb
, "Follow long symlink");
475 link
= kmalloc(linklen
, GFP_NOFS
);
479 if (befs_read_lsymlink(sb
, data
, link
, linklen
) != linklen
) {
481 befs_error(sb
, "Failed to read entire long symlink");
485 res
= vfs_follow_link(nd
, link
);
489 link
= befs_ino
->i_data
.symlink
;
490 res
= vfs_follow_link(nd
, link
);
497 befs_readlink(struct dentry
*dentry
, char *buffer
, int buflen
)
499 struct super_block
*sb
= dentry
->d_sb
;
500 befs_inode_info
*befs_ino
= BEFS_I(dentry
->d_inode
);
504 if (befs_ino
->i_flags
& BEFS_LONG_SYMLINK
) {
505 befs_data_stream
*data
= &befs_ino
->i_data
.ds
;
506 befs_off_t linklen
= data
->size
;
508 befs_debug(sb
, "Read long symlink");
510 link
= kmalloc(linklen
, GFP_NOFS
);
514 if (befs_read_lsymlink(sb
, data
, link
, linklen
) != linklen
) {
516 befs_error(sb
, "Failed to read entire long symlink");
520 res
= vfs_readlink(dentry
, buffer
, buflen
, link
);
524 link
= befs_ino
->i_data
.symlink
;
525 res
= vfs_readlink(dentry
, buffer
, buflen
, link
);
532 * UTF-8 to NLS charset convert routine
535 * Changed 8/10/01 by Will Dyson. Now use uni2char() / char2uni() rather than
536 * the nls tables directly
540 befs_utf2nls(struct super_block
*sb
, const char *in
,
541 int in_len
, char **out
, int *out_len
)
543 struct nls_table
*nls
= BEFS_SB(sb
)->nls
;
548 int maxlen
= in_len
; /* The utf8->nls conversion can't make more chars */
550 befs_debug(sb
, "---> utf2nls()");
553 befs_error(sb
, "befs_utf2nls called with no NLS table loaded");
557 *out
= result
= kmalloc(maxlen
, GFP_NOFS
);
559 befs_error(sb
, "befs_utf2nls() cannot allocate memory");
564 for (i
= o
= 0; i
< in_len
; i
+= utflen
, o
+= unilen
) {
566 /* convert from UTF-8 to Unicode */
567 utflen
= utf8_mbtowc(&uni
, &in
[i
], in_len
- i
);
572 /* convert from Unicode to nls */
573 unilen
= nls
->uni2char(uni
, &result
[o
], 1);
581 befs_debug(sb
, "<--- utf2nls()");
586 befs_error(sb
, "Name using charecter set %s contains a charecter that "
587 "cannot be converted to unicode.", nls
->charset
);
588 befs_debug(sb
, "<--- utf2nls()");
594 * befs_nls2utf - Convert NLS string to utf8 encodeing
596 * @src: Input string buffer in NLS format
597 * @srclen: Length of input string in bytes
598 * @dest: The output string in UTF8 format
599 * @destlen: Length of the output buffer
601 * Converts input string @src, which is in the format of the loaded NLS map,
602 * into a utf8 string.
604 * The destination string @dest is allocated by this function and the caller is
605 * responsible for freeing it with kfree()
607 * On return, *@destlen is the length of @dest in bytes.
609 * On success, the return value is the number of utf8 characters written to
610 * the output buffer @dest.
612 * On Failure, a negative number coresponding to the error code is returned.
616 befs_nls2utf(struct super_block
*sb
, const char *in
,
617 int in_len
, char **out
, int *out_len
)
619 struct nls_table
*nls
= BEFS_SB(sb
)->nls
;
624 int maxlen
= 3 * in_len
;
626 befs_debug(sb
, "---> nls2utf()\n");
629 befs_error(sb
, "befs_nls2utf called with no NLS table loaded.");
633 *out
= result
= kmalloc(maxlen
, GFP_NOFS
);
635 befs_error(sb
, "befs_nls2utf() cannot allocate memory");
640 for (i
= o
= 0; i
< in_len
; i
+= unilen
, o
+= utflen
) {
642 /* convert from nls to unicode */
643 unilen
= nls
->char2uni(&in
[i
], in_len
- i
, &uni
);
648 /* convert from unicode to UTF-8 */
649 utflen
= utf8_wctomb(&result
[o
], uni
, 3);
658 befs_debug(sb
, "<--- nls2utf()");
663 befs_error(sb
, "Name using charecter set %s contains a charecter that "
664 "cannot be converted to unicode.", nls
->charset
);
665 befs_debug(sb
, "<--- nls2utf()");
671 parse_options(char *options
, befs_mount_options
* opts
)
677 /* Initialize options */
682 opts
->iocharset
= NULL
;
688 while ((this_char
= strsep(&options
, ",")) != NULL
) {
690 if ((value
= strchr(this_char
, '=')) != NULL
)
693 if (!strcmp(this_char
, "uid")) {
694 if (!value
|| !*value
) {
697 opts
->uid
= simple_strtoul(value
, &value
, 0);
700 printk(KERN_ERR
"BEFS: Invalid uid "
701 "option: %s\n", value
);
705 } else if (!strcmp(this_char
, "gid")) {
706 if (!value
|| !*value
)
709 opts
->gid
= simple_strtoul(value
, &value
, 0);
713 "BEFS: Invalid gid option: "
718 } else if (!strcmp(this_char
, "iocharset") && value
) {
722 while (*value
&& *value
!= ',')
726 char *buffer
= kmalloc(len
+ 1, GFP_NOFS
);
728 opts
->iocharset
= buffer
;
729 memcpy(buffer
, p
, len
);
733 printk(KERN_ERR
"BEFS: "
734 "cannot allocate memory\n");
738 } else if (!strcmp(this_char
, "debug")) {
746 /* This function has the responsibiltiy of getting the
747 * filesystem ready for unmounting.
748 * Basicly, we free everything that we allocated in
752 befs_put_super(struct super_block
*sb
)
754 if (BEFS_SB(sb
)->mount_opts
.iocharset
) {
755 kfree(BEFS_SB(sb
)->mount_opts
.iocharset
);
756 BEFS_SB(sb
)->mount_opts
.iocharset
= NULL
;
759 if (BEFS_SB(sb
)->nls
) {
760 unload_nls(BEFS_SB(sb
)->nls
);
761 BEFS_SB(sb
)->nls
= NULL
;
765 kfree(sb
->s_fs_info
);
766 sb
->s_fs_info
= NULL
;
771 /* Allocate private field of the superblock, fill it.
773 * Finish filling the public superblock fields
774 * Make the root directory
775 * Load a set of NLS translations if needed.
778 befs_fill_super(struct super_block
*sb
, void *data
, int silent
)
780 struct buffer_head
*bh
;
781 befs_sb_info
*befs_sb
;
782 befs_super_block
*disk_sb
;
784 const unsigned long sb_block
= 0;
785 const off_t x86_sb_off
= 512;
787 sb
->s_fs_info
= kmalloc(sizeof (*befs_sb
), GFP_KERNEL
);
788 if (sb
->s_fs_info
== NULL
) {
790 "BeFS(%s): Unable to allocate memory for private "
791 "portion of superblock. Bailing.\n", sb
->s_id
);
794 befs_sb
= BEFS_SB(sb
);
795 memset(befs_sb
, 0, sizeof(befs_sb_info
));
797 if (!parse_options((char *) data
, &befs_sb
->mount_opts
)) {
798 befs_error(sb
, "cannot parse mount options");
799 goto unaquire_priv_sbp
;
802 befs_debug(sb
, "---> befs_fill_super()");
804 #ifndef CONFIG_BEFS_RW
805 if (!(sb
->s_flags
& MS_RDONLY
)) {
807 "No write support. Marking filesystem read-only");
808 sb
->s_flags
|= MS_RDONLY
;
810 #endif /* CONFIG_BEFS_RW */
813 * Set dummy blocksize to read super block.
814 * Will be set to real fs blocksize later.
816 * Linux 2.4.10 and later refuse to read blocks smaller than
817 * the hardsect size for the device. But we also need to read at
818 * least 1k to get the second 512 bytes of the volume.
821 sb_min_blocksize(sb
, 1024);
823 if (!(bh
= sb_bread(sb
, sb_block
))) {
824 befs_error(sb
, "unable to read superblock");
825 goto unaquire_priv_sbp
;
828 /* account for offset of super block on x86 */
829 disk_sb
= (befs_super_block
*) bh
->b_data
;
830 if ((le32_to_cpu(disk_sb
->magic1
) == BEFS_SUPER_MAGIC1
) ||
831 (be32_to_cpu(disk_sb
->magic1
) == BEFS_SUPER_MAGIC1
)) {
832 befs_debug(sb
, "Using PPC superblock location");
834 befs_debug(sb
, "Using x86 superblock location");
836 (befs_super_block
*) ((void *) bh
->b_data
+ x86_sb_off
);
839 if (befs_load_sb(sb
, disk_sb
) != BEFS_OK
)
842 befs_dump_super_block(sb
, disk_sb
);
846 if (befs_check_sb(sb
) != BEFS_OK
)
847 goto unaquire_priv_sbp
;
850 * set up enough so that it can read an inode
851 * Fill in kernel superblock fields from private sb
853 sb
->s_magic
= BEFS_SUPER_MAGIC
;
854 /* Set real blocksize of fs */
855 sb_set_blocksize(sb
, (ulong
) befs_sb
->block_size
);
856 sb
->s_op
= (struct super_operations
*) &befs_sops
;
858 d_alloc_root(iget(sb
, iaddr2blockno(sb
, &(befs_sb
->root_dir
))));
860 befs_error(sb
, "get root inode failed");
861 goto unaquire_priv_sbp
;
864 /* load nls library */
865 if (befs_sb
->mount_opts
.iocharset
) {
866 befs_debug(sb
, "Loading nls: %s",
867 befs_sb
->mount_opts
.iocharset
);
868 befs_sb
->nls
= load_nls(befs_sb
->mount_opts
.iocharset
);
870 befs_warning(sb
, "Cannot load nls %s"
871 "loding default nls",
872 befs_sb
->mount_opts
.iocharset
);
873 befs_sb
->nls
= load_nls_default();
883 kfree(sb
->s_fs_info
);
886 sb
->s_fs_info
= NULL
;
891 befs_remount(struct super_block
*sb
, int *flags
, char *data
)
893 if (!(*flags
& MS_RDONLY
))
899 befs_statfs(struct super_block
*sb
, struct kstatfs
*buf
)
902 befs_debug(sb
, "---> befs_statfs()");
904 buf
->f_type
= BEFS_SUPER_MAGIC
;
905 buf
->f_bsize
= sb
->s_blocksize
;
906 buf
->f_blocks
= BEFS_SB(sb
)->num_blocks
;
907 buf
->f_bfree
= BEFS_SB(sb
)->num_blocks
- BEFS_SB(sb
)->used_blocks
;
908 buf
->f_bavail
= buf
->f_bfree
;
909 buf
->f_files
= 0; /* UNKNOWN */
910 buf
->f_ffree
= 0; /* UNKNOWN */
911 buf
->f_namelen
= BEFS_NAME_LEN
;
913 befs_debug(sb
, "<--- befs_statfs()");
918 static struct super_block
*
919 befs_get_sb(struct file_system_type
*fs_type
, int flags
, const char *dev_name
,
922 return get_sb_bdev(fs_type
, flags
, dev_name
, data
, befs_fill_super
);
925 static struct file_system_type befs_fs_type
= {
926 .owner
= THIS_MODULE
,
928 .get_sb
= befs_get_sb
,
929 .kill_sb
= kill_block_super
,
930 .fs_flags
= FS_REQUIRES_DEV
,
938 printk(KERN_INFO
"BeFS version: %s\n", BEFS_VERSION
);
940 err
= befs_init_inodecache();
944 return register_filesystem(&befs_fs_type
);
950 befs_destroy_inodecache();
952 unregister_filesystem(&befs_fs_type
);
956 Macros that typecheck the init and exit functions,
957 ensures that they are called at init and cleanup,
958 and eliminates warnings about unused functions.
960 module_init(init_befs_fs
)
961 module_exit(exit_befs_fs
)