Remove building with NOCRYPTO option
[minix3.git] / minix / lib / libsffs / mount.c
blob998e0151f01b5fb2dde789624b35d3dfadb66635
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
7 * Created:
8 * April 2009 (D.C. van Moolenbroek)
9 */
11 #include "inc.h"
13 /*===========================================================================*
14 * do_mount *
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.
21 char path[PATH_MAX];
22 struct inode *ino;
23 struct sffs_attr attr;
24 int r;
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);
31 return EINVAL;
34 read_only = !!(flags & REQ_RDONLY);
36 init_dentry();
37 ino = init_inode();
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) {
46 if (r == EAGAIN)
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",
50 sffs_name);
51 else
52 printf("%s: unable to access shared folders\n", sffs_name);
54 return r;
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;
66 return OK;
69 /*===========================================================================*
70 * do_unmount *
71 *===========================================================================*/
72 void do_unmount(void)
74 /* Unmount the file system.
76 struct inode *ino;
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)
82 return;
84 put_inode(ino);
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);