kernel: separate state for trace-deferred syscalls
[minix.git] / lib / libpuffs / mount.c
blobbeaa2533ba963bbc1f7643677686c71cd815039a
1 /* Created (MFS based):
2 * June 2011 (Evgeniy Ivanov)
3 */
5 #include "fs.h"
6 #include <fcntl.h>
7 #include <string.h>
8 #include <minix/com.h>
9 #include <sys/stat.h>
10 #include <minix/ds.h>
11 #include <minix/vfsif.h>
13 #include "puffs_priv.h"
15 /*===========================================================================*
16 * fs_readsuper *
17 *===========================================================================*/
18 int fs_readsuper()
20 struct vattr *root_va;
22 fs_dev = fs_m_in.REQ_DEV;
23 is_readonly_fs = (fs_m_in.REQ_FLAGS & REQ_RDONLY) ? 1 : 0;
24 is_root_fs = (fs_m_in.REQ_FLAGS & REQ_ISROOT) ? 1 : 0;
26 /* Open root pnode */
27 global_pu->pu_pn_root->pn_count = 1;
29 /* Root pnode properties */
30 root_va = &global_pu->pu_pn_root->pn_va;
31 fs_m_out.RES_INODE_NR = root_va->va_fileid;
32 fs_m_out.RES_MODE = root_va->va_mode;
33 fs_m_out.RES_FILE_SIZE_LO = root_va->va_size;
34 fs_m_out.RES_UID = root_va->va_uid;
35 fs_m_out.RES_GID = root_va->va_gid;
36 fs_m_out.RES_CONREQS = 1;
38 return(OK);
42 /*===========================================================================*
43 * fs_mountpoint *
44 *===========================================================================*/
45 int fs_mountpoint()
47 /* This function looks up the mount point, it checks the condition whether
48 * the partition can be mounted on the pnode or not.
50 int r = OK;
51 struct puffs_node *pn;
52 mode_t bits;
55 * XXX: we assume that lookup was done first, so pnode can be found with
56 * puffs_pn_nodewalk.
58 if ((pn = puffs_pn_nodewalk(global_pu, 0, &fs_m_in.REQ_INODE_NR)) == NULL)
59 return(EINVAL);
62 if (pn->pn_mountpoint) r = EBUSY;
64 /* It may not be special. */
65 bits = pn->pn_va.va_mode & I_TYPE;
66 if(bits == I_BLOCK_SPECIAL || bits == I_CHAR_SPECIAL) r = ENOTDIR;
68 if (r == OK)
69 pn->pn_mountpoint = TRUE;
71 return(r);
75 /*===========================================================================*
76 * fs_unmount *
77 *===========================================================================*/
78 int fs_unmount()
80 int error;
82 /* XXX there is no information about flags, 0 should be safe enough */
83 error = global_pu->pu_ops.puffs_fs_unmount(global_pu, 0);
84 if (error) {
85 /* XXX we can't return any error to VFS */
86 lpuffs_debug("user handler failed to unmount filesystem!\
87 Force unmount!\n");
90 fs_sync();
92 /* Finish off the unmount. */
93 PU_SETSTATE(global_pu, PUFFS_STATE_UNMOUNTED);
94 unmountdone = TRUE;
95 global_pu->pu_pn_root->pn_count--;
97 return(OK);