Remove building with NOCRYPTO option
[minix.git] / minix / lib / libpuffs / mount.c
blobc3d712f3db5e3d0636fb2cf637797760e4d2f0b5
1 /* Created (MFS based):
2 * June 2011 (Evgeniy Ivanov)
3 */
5 #include "fs.h"
6 #include <fcntl.h>
7 #include <minix/vfsif.h>
9 /*===========================================================================*
10 * fs_mount *
11 *===========================================================================*/
12 int fs_mount(dev_t __unused dev, unsigned int flags,
13 struct fsdriver_node *root_node, unsigned int *res_flags)
15 struct vattr *root_va;
17 is_readonly_fs = !!(flags & REQ_RDONLY);
19 /* Open root pnode */
20 global_pu->pu_pn_root->pn_count = 1;
22 /* Root pnode properties */
23 root_va = &global_pu->pu_pn_root->pn_va;
24 root_node->fn_ino_nr = root_va->va_fileid;
25 root_node->fn_mode = root_va->va_mode;
26 root_node->fn_size = root_va->va_size;
27 root_node->fn_uid = root_va->va_uid;
28 root_node->fn_gid = root_va->va_gid;
29 root_node->fn_dev = NO_DEV;
31 *res_flags = RES_NOFLAGS;
33 mounted = TRUE;
35 return(OK);
39 /*===========================================================================*
40 * fs_mountpt *
41 *===========================================================================*/
42 int fs_mountpt(ino_t ino_nr)
44 /* This function looks up the mount point, it checks the condition whether
45 * the partition can be mounted on the pnode or not.
47 int r = OK;
48 struct puffs_node *pn;
49 mode_t bits;
51 if ((pn = puffs_pn_nodewalk(global_pu, find_inode_cb, &ino_nr)) == NULL)
52 return(EINVAL);
54 if (pn->pn_mountpoint) r = EBUSY;
56 /* It may not be special. */
57 bits = pn->pn_va.va_mode & I_TYPE;
58 if(bits == I_BLOCK_SPECIAL || bits == I_CHAR_SPECIAL) r = ENOTDIR;
60 if (r == OK)
61 pn->pn_mountpoint = TRUE;
63 return(r);
67 /*===========================================================================*
68 * fs_unmount *
69 *===========================================================================*/
70 void fs_unmount(void)
72 int error;
74 /* Always force unmounting, as VFS will not tolerate failure. */
75 error = global_pu->pu_ops.puffs_fs_unmount(global_pu, MNT_FORCE);
76 if (error) {
77 lpuffs_debug("user handler failed to unmount filesystem!\
78 Force unmount!\n");
81 fs_sync();
83 /* Finish off the unmount. */
84 PU_SETSTATE(global_pu, PUFFS_STATE_UNMOUNTED);
85 mounted = FALSE;
86 global_pu->pu_pn_root->pn_count--;