add swifi to the build/install.
[minix.git] / servers / hgfs / mount.c
blobcdcd167b3b233649ee1e47bbe1073bdea2eefedb
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
7 * Created:
8 * April 2009 (D.C. van Moolenbroek)
9 */
11 #include "inc.h"
13 /*===========================================================================*
14 * do_readsuper *
15 *===========================================================================*/
16 PUBLIC int do_readsuper()
18 /* Mount the file system.
20 char path[PATH_MAX];
21 struct inode *ino;
22 struct hgfs_attr attr;
23 int r;
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");
31 return EINVAL;
34 state.read_only = !!(m_in.REQ_FLAGS & REQ_RDONLY);
35 state.dev = m_in.REQ_DEV;
37 init_dentry();
38 ino = init_inode();
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) {
47 if (r == EAGAIN)
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");
51 else
52 printf("HGFS: unable to access shared folders\n");
54 return r;
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;
65 state.mounted = TRUE;
67 return OK;
70 /*===========================================================================*
71 * do_unmount *
72 *===========================================================================*/
73 PUBLIC int do_unmount()
75 /* Unmount the file system.
77 struct inode *ino;
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)
83 return EINVAL;
85 put_inode(ino);
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;
93 return OK;