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. */
27 if (label_len
> sizeof(fs_dev_label
))
30 r
= sys_safecopyfrom(fs_m_in
.m_source
, label_gid
, 0, (vir_bytes
)fs_dev_label
,
33 printf("ISOFS %s:%d safecopyfrom failed: %d\n", __FILE__
, __LINE__
, r
);
37 r
= ds_retrieve_label_num(fs_dev_label
, &tasknr
);
39 printf("ISOFS %s:%d ds_retrieve_label_num failed for '%s': %d\n",
40 __FILE__
, __LINE__
, fs_dev_label
, r
);
46 /* Map the driver endpoint for this major */
47 driver_endpoints
[(fs_dev
>> MAJOR
) & BYTE
].driver_e
= driver_e
;
49 /* Open the device the file system lives on */
50 if (dev_open(driver_e
, fs_dev
, driver_e
,
51 readonly
? R_BIT
: (R_BIT
|W_BIT
)) != OK
) {
55 /* Read the superblock */
56 r
= read_vds(&v_pri
, fs_dev
);
60 /* Return some root inode properties */
61 fs_m_out
.RES_INODE_NR
= ID_DIR_RECORD(v_pri
.dir_rec_root
);
62 fs_m_out
.RES_MODE
= v_pri
.dir_rec_root
->d_mode
;
63 fs_m_out
.RES_FILE_SIZE_LO
= v_pri
.dir_rec_root
->d_file_size
;
64 fs_m_out
.RES_UID
= SYS_UID
; /* Always root */
65 fs_m_out
.RES_GID
= SYS_GID
; /* operator */
71 /*===========================================================================*
73 *===========================================================================*/
74 PUBLIC
int fs_mountpoint() {
75 /* This function looks up the mount point, it checks the condition whether
76 * the partition can be mounted on the inode or not.
79 register struct dir_record
*rip
;
83 /* Temporarily open the file. */
84 if ((rip
= get_dir_record(fs_m_in
.REQ_INODE_NR
)) == NULL
)
87 if (rip
->d_mountpoint
)
90 /* If the inode is not a dir returns error */
91 if ((rip
->d_mode
& I_TYPE
) != I_DIRECTORY
)
94 release_dir_record(rip
);
97 rip
->d_mountpoint
= TRUE
;
103 /*===========================================================================*
105 *===========================================================================*/
106 PUBLIC
int fs_unmount(void) {
107 release_v_pri(&v_pri
); /* Release the super block */
108 dev_close(driver_endpoints
[(fs_dev
>> MAJOR
) & BYTE
].driver_e
, fs_dev
);