4 #include <minix/vfsif.h>
10 /*===========================================================================*
12 *===========================================================================*/
13 PUBLIC
int fs_readsuper() {
15 cp_grant_id_t label_gid
;
22 fs_dev
= fs_m_in
.REQ_DEV
;
23 label_gid
= fs_m_in
.REQ_GRANT
;
24 label_len
= fs_m_in
.REQ_PATH_LEN
;
25 readonly
= 1; /* Always mount devices read only. */
26 isroot
= (fs_m_in
.REQ_FLAGS
& REQ_ISROOT
) ? 1 : 0;
28 if (label_len
> sizeof(fs_dev_label
))
31 r
= sys_safecopyfrom(fs_m_in
.m_source
, label_gid
, 0, (vir_bytes
)fs_dev_label
,
34 printf("ISOFS %s:%d safecopyfrom failed: %d\n", __FILE__
, __LINE__
, r
);
38 r
= ds_retrieve_u32(fs_dev_label
, &tasknr
);
40 printf("ISOFS %s:%d ds_retrieve_u32 failed for '%s': %d\n",
41 __FILE__
, __LINE__
, fs_dev_label
, r
);
47 /* Map the driver endpoint for this major */
48 driver_endpoints
[(fs_dev
>> MAJOR
) & BYTE
].driver_e
= driver_e
;
50 /* Open the device the file system lives on */
51 if (dev_open(driver_e
, fs_dev
, driver_e
,
52 readonly
? R_BIT
: (R_BIT
|W_BIT
)) != OK
) {
56 /* Read the superblock */
57 r
= read_vds(&v_pri
, fs_dev
);
61 /* Return some root inode properties */
62 fs_m_out
.RES_INODE_NR
= ID_DIR_RECORD(v_pri
.dir_rec_root
);
63 fs_m_out
.RES_MODE
= v_pri
.dir_rec_root
->d_mode
;
64 fs_m_out
.RES_FILE_SIZE_LO
= v_pri
.dir_rec_root
->d_file_size
;
65 fs_m_out
.RES_UID
= SYS_UID
; /* Always root */
66 fs_m_out
.RES_GID
= SYS_GID
; /* operator */
72 /*===========================================================================*
74 *===========================================================================*/
75 PUBLIC
int fs_mountpoint() {
76 /* This function looks up the mount point, it checks the condition whether
77 * the partition can be mounted on the inode or not.
80 register struct dir_record
*rip
;
84 /* Temporarily open the file. */
85 if ((rip
= get_dir_record(fs_m_in
.REQ_INODE_NR
)) == NULL
)
88 if (rip
->d_mountpoint
)
91 /* If the inode is not a dir returns error */
92 if ((rip
->d_mode
& I_TYPE
) != I_DIRECTORY
)
95 release_dir_record(rip
);
98 rip
->d_mountpoint
= TRUE
;
104 /*===========================================================================*
106 *===========================================================================*/
107 PUBLIC
int fs_unmount(void) {
108 release_v_pri(&v_pri
); /* Release the super block */
109 dev_close(driver_endpoints
[(fs_dev
>> MAJOR
) & BYTE
].driver_e
, fs_dev
);