1 /* This file contains mount and unmount functionality.
3 * The entry points into this file are:
4 * do_mount perform the READSUPER file system call
5 * do_unmount perform the UNMOUNT file system call
8 * April 2009 (D.C. van Moolenbroek)
13 /*===========================================================================*
15 *===========================================================================*/
16 int do_mount(dev_t __unused dev
, unsigned int flags
,
17 struct fsdriver_node
*root_node
, unsigned int *res_flags
)
19 /* Mount the file system.
23 struct sffs_attr attr
;
26 dprintf(("%s: mount (dev %"PRIx64
", flags %x)\n", sffs_name
, dev
, flags
));
28 if (flags
& REQ_ISROOT
) {
29 printf("%s: attempt to mount as root device\n", sffs_name
);
34 read_only
= !!(flags
& REQ_RDONLY
);
39 attr
.a_mask
= SFFS_ATTR_MODE
| SFFS_ATTR_SIZE
;
41 /* We cannot continue if we fail to get the properties of the root inode at
42 * all, because we cannot guess the details of the root node to return to
43 * VFS. Print a (hopefully) helpful error message, and abort the mount.
45 if ((r
= verify_inode(ino
, path
, &attr
)) != OK
) {
47 printf("%s: shared folders disabled\n", sffs_name
);
48 else if (sffs_params
->p_prefix
[0] && (r
== ENOENT
|| r
== EACCES
))
49 printf("%s: unable to access the given prefix directory\n",
52 printf("%s: unable to access shared folders\n", sffs_name
);
57 root_node
->fn_ino_nr
= INODE_NR(ino
);
58 root_node
->fn_mode
= get_mode(ino
, attr
.a_mode
);
59 root_node
->fn_size
= attr
.a_size
;
60 root_node
->fn_uid
= sffs_params
->p_uid
;
61 root_node
->fn_gid
= sffs_params
->p_gid
;
62 root_node
->fn_dev
= NO_DEV
;
64 *res_flags
= RES_64BIT
;
69 /*===========================================================================*
71 *===========================================================================*/
74 /* Unmount the file system.
78 dprintf(("%s: unmount\n", sffs_name
));
80 /* Decrease the reference count of the root inode. */
81 if ((ino
= find_inode(ROOT_INODE_NR
)) == NULL
)
86 /* There should not be any referenced inodes anymore now. */
87 if (have_used_inode())
88 printf("%s: in-use inodes left at unmount time!\n", sffs_name
);