1 /* This file contains mount and unmount functionality.
3 * The entry points into this file are:
4 * do_readsuper perform the READSUPER file system call
5 * do_unmount perform the UNMOUNT file system call
8 * April 2009 (D.C. van Moolenbroek)
13 /*===========================================================================*
15 *===========================================================================*/
18 /* Mount the file system.
22 struct sffs_attr attr
;
25 dprintf(("%s: readsuper (dev %x, flags %x)\n",
26 sffs_name
, (dev_t
) m_in
.REQ_DEV
, m_in
.REQ_FLAGS
));
28 if (m_in
.REQ_FLAGS
& REQ_ISROOT
) {
29 printf("%s: attempt to mount as root device\n", sffs_name
);
34 state
.s_read_only
= !!(m_in
.REQ_FLAGS
& REQ_RDONLY
);
35 state
.s_dev
= m_in
.REQ_DEV
;
40 attr
.a_mask
= SFFS_ATTR_MODE
| SFFS_ATTR_SIZE
;
42 /* We cannot continue if we fail to get the properties of the root inode at
43 * all, because we cannot guess the details of the root node to return to
44 * VFS. Print a (hopefully) helpful error message, and abort the mount.
46 if ((r
= verify_inode(ino
, path
, &attr
)) != OK
) {
48 printf("%s: shared folders disabled\n", sffs_name
);
49 else if (sffs_params
->p_prefix
[0] && (r
== ENOENT
|| r
== EACCES
))
50 printf("%s: unable to access the given prefix directory\n",
53 printf("%s: unable to access shared folders\n", sffs_name
);
58 m_out
.RES_INODE_NR
= INODE_NR(ino
);
59 m_out
.RES_MODE
= get_mode(ino
, attr
.a_mode
);
60 m_out
.RES_FILE_SIZE_HI
= ex64hi(attr
.a_size
);
61 m_out
.RES_FILE_SIZE_LO
= ex64lo(attr
.a_size
);
62 m_out
.RES_UID
= sffs_params
->p_uid
;
63 m_out
.RES_GID
= sffs_params
->p_gid
;
64 m_out
.RES_DEV
= NO_DEV
;
65 m_out
.RES_CONREQS
= 1; /* We can handle only 1 request at a time */
67 state
.s_mounted
= TRUE
;
72 /*===========================================================================*
74 *===========================================================================*/
77 /* Unmount the file system.
81 dprintf(("%s: do_unmount\n", sffs_name
));
83 /* Decrease the reference count of the root inode. */
84 if ((ino
= find_inode(ROOT_INODE_NR
)) == NULL
)
89 /* There should not be any referenced inodes anymore now. */
90 if (have_used_inode())
91 printf("%s: in-use inodes left at unmount time!\n", sffs_name
);
93 state
.s_mounted
= FALSE
;