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 *===========================================================================*/
16 PUBLIC
int do_readsuper()
18 /* Mount the file system.
22 struct hgfs_attr attr
;
25 dprintf(("HGFS: readsuper (dev %x, flags %x)\n",
26 (dev_t
) m_in
.REQ_DEV
, m_in
.REQ_FLAGS
));
28 if (m_in
.REQ_FLAGS
& REQ_ISROOT
) {
29 printf("HGFS: attempt to mount as root device\n");
34 state
.read_only
= !!(m_in
.REQ_FLAGS
& REQ_RDONLY
);
35 state
.dev
= m_in
.REQ_DEV
;
40 attr
.a_mask
= HGFS_ATTR_MODE
| HGFS_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("HGFS: shared folders disabled\n");
49 else if (opt
.prefix
[0] && (r
== ENOENT
|| r
== EACCES
))
50 printf("HGFS: unable to access the given prefix directory\n");
52 printf("HGFS: unable to access shared folders\n");
57 m_out
.RES_INODE_NR
= INODE_NR(ino
);
58 m_out
.RES_MODE
= get_mode(ino
, attr
.a_mode
);
59 m_out
.RES_FILE_SIZE_HI
= ex64hi(attr
.a_size
);
60 m_out
.RES_FILE_SIZE_LO
= ex64lo(attr
.a_size
);
61 m_out
.RES_UID
= opt
.uid
;
62 m_out
.RES_GID
= opt
.gid
;
63 m_out
.RES_DEV
= NO_DEV
;
70 /*===========================================================================*
72 *===========================================================================*/
73 PUBLIC
int do_unmount()
75 /* Unmount the file system.
79 dprintf(("HGFS: do_unmount\n"));
81 /* Decrease the reference count of the root inode. */
82 if ((ino
= find_inode(ROOT_INODE_NR
)) == NIL_INODE
)
87 /* There should not be any referenced inodes anymore now. */
88 if (have_used_inode())
89 printf("HGFS: in-use inodes left at unmount time!\n");
91 state
.mounted
= FALSE
;