tools/llvm: Do not build with symbols
[minix3.git] / lib / libpuffs / mount.c
blob036c5bd900c61f049c7f4108ac59fdda3e4b7e73
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(void)
20 struct vattr *root_va;
22 fs_dev = fs_m_in.m_vfs_fs_readsuper.device;
23 is_readonly_fs = (fs_m_in.m_vfs_fs_readsuper.flags & REQ_RDONLY) ? 1 : 0;
24 is_root_fs = (fs_m_in.m_vfs_fs_readsuper.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.m_fs_vfs_readsuper.inode = root_va->va_fileid;
32 fs_m_out.m_fs_vfs_readsuper.mode = root_va->va_mode;
33 fs_m_out.m_fs_vfs_readsuper.file_size = root_va->va_size;
34 fs_m_out.m_fs_vfs_readsuper.uid = root_va->va_uid;
35 fs_m_out.m_fs_vfs_readsuper.gid = root_va->va_gid;
36 fs_m_out.m_fs_vfs_readsuper.flags = RES_NOFLAGS;
38 return(OK);
42 /*===========================================================================*
43 * fs_mountpoint *
44 *===========================================================================*/
45 int fs_mountpoint(void)
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.m_vfs_fs_mountpoint.inode))
59 == NULL)
60 return(EINVAL);
63 if (pn->pn_mountpoint) r = EBUSY;
65 /* It may not be special. */
66 bits = pn->pn_va.va_mode & I_TYPE;
67 if(bits == I_BLOCK_SPECIAL || bits == I_CHAR_SPECIAL) r = ENOTDIR;
69 if (r == OK)
70 pn->pn_mountpoint = TRUE;
72 return(r);
76 /*===========================================================================*
77 * fs_unmount *
78 *===========================================================================*/
79 int fs_unmount(void)
81 int error;
83 /* XXX there is no information about flags, 0 should be safe enough */
84 error = global_pu->pu_ops.puffs_fs_unmount(global_pu, 0);
85 if (error) {
86 /* XXX we can't return any error to VFS */
87 lpuffs_debug("user handler failed to unmount filesystem!\
88 Force unmount!\n");
91 fs_sync();
93 /* Finish off the unmount. */
94 PU_SETSTATE(global_pu, PUFFS_STATE_UNMOUNTED);
95 unmountdone = TRUE;
96 global_pu->pu_pn_root->pn_count--;
98 return(OK);