iso9660fs: initialize buffer cache
[minix.git] / servers / iso9660fs / mount.c
blobaa23ebd6ae3227a3738fe24d4fd770f1551bc898
1 #include "inc.h"
2 #include <minix/vfsif.h>
3 #include <minix/bdev.h>
4 #include "const.h"
5 #include "glo.h"
8 /*===========================================================================*
9 * fs_readsuper *
10 *===========================================================================*/
11 int fs_readsuper() {
13 cp_grant_id_t label_gid;
14 size_t label_len;
15 int r = OK;
17 fs_dev = fs_m_in.REQ_DEV;
18 label_gid = fs_m_in.REQ_GRANT;
19 label_len = fs_m_in.REQ_PATH_LEN;
21 if (label_len > sizeof(fs_dev_label))
22 return(EINVAL);
24 r = sys_safecopyfrom(fs_m_in.m_source, label_gid, 0, (vir_bytes)fs_dev_label,
25 label_len);
26 if (r != OK) {
27 printf("ISOFS %s:%d safecopyfrom failed: %d\n", __FILE__, __LINE__, r);
28 return(EINVAL);
31 /* Map the driver label for this major */
32 bdev_driver(fs_dev, fs_dev_label);
34 /* Open the device the file system lives on in read only mode */
35 if (bdev_open(fs_dev, R_BIT) != OK) {
36 return(EINVAL);
39 /* Read the superblock */
40 r = read_vds(&v_pri, fs_dev);
41 if (r != OK) {
42 bdev_close(fs_dev);
43 return(r);
46 lmfs_set_blocksize(v_pri.logical_block_size_l, major(fs_dev));
48 /* Return some root inode properties */
49 fs_m_out.RES_INODE_NR = ID_DIR_RECORD(v_pri.dir_rec_root);
50 fs_m_out.RES_MODE = v_pri.dir_rec_root->d_mode;
51 fs_m_out.RES_FILE_SIZE_LO = v_pri.dir_rec_root->d_file_size;
52 fs_m_out.RES_UID = SYS_UID; /* Always root */
53 fs_m_out.RES_GID = SYS_GID; /* operator */
55 fs_m_out.RES_CONREQS = 1; /* We can handle only 1 request at a time */
57 return(r);
61 /*===========================================================================*
62 * fs_mountpoint *
63 *===========================================================================*/
64 int fs_mountpoint()
66 /* This function looks up the mount point, it checks the condition whether
67 * the partition can be mounted on the inode or not.
70 register struct dir_record *rip;
71 int r = OK;
73 /* Temporarily open the file. */
74 if ((rip = get_dir_record(fs_m_in.REQ_INODE_NR)) == NULL)
75 return(EINVAL);
77 if (rip->d_mountpoint)
78 r = EBUSY;
80 /* If the inode is not a dir returns error */
81 if ((rip->d_mode & I_TYPE) != I_DIRECTORY)
82 r = ENOTDIR;
84 release_dir_record(rip);
86 if (r == OK)
87 rip->d_mountpoint = TRUE;
89 return(r);
93 /*===========================================================================*
94 * fs_unmount *
95 *===========================================================================*/
96 int fs_unmount(void) {
97 release_v_pri(&v_pri); /* Release the super block */
98 bdev_close(fs_dev);
99 unmountdone = TRUE;
100 return(OK);