Fixed extern declaration from pointer to array
[minix.git] / servers / iso9660fs / mount.c
blob636fe1112b4e69d1ace54a7fe378701d8fc0df28
1 #include "inc.h"
2 #include <string.h>
3 #include <minix/com.h>
4 #include <minix/vfsif.h>
5 #include <minix/ds.h>
6 #include "const.h"
7 #include "glo.h"
10 /*===========================================================================*
11 * fs_readsuper *
12 *===========================================================================*/
13 PUBLIC int fs_readsuper() {
15 cp_grant_id_t label_gid;
16 size_t label_len;
17 int r = OK;
18 unsigned long tasknr;
19 endpoint_t driver_e;
20 int readonly, isroot;
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))
29 return(EINVAL);
31 r = sys_safecopyfrom(fs_m_in.m_source, label_gid, 0, (vir_bytes)fs_dev_label,
32 label_len, D);
33 if (r != OK) {
34 printf("ISOFS %s:%d safecopyfrom failed: %d\n", __FILE__, __LINE__, r);
35 return(EINVAL);
38 r = ds_retrieve_u32(fs_dev_label, &tasknr);
39 if (r != OK) {
40 printf("ISOFS %s:%d ds_retrieve_u32 failed for '%s': %d\n",
41 __FILE__, __LINE__, fs_dev_label, r);
42 return(EINVAL);
45 driver_e = tasknr;
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) {
53 return(EINVAL);
56 /* Read the superblock */
57 r = read_vds(&v_pri, fs_dev);
58 if (r != OK)
59 return(r);
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 */
68 return(r);
72 /*===========================================================================*
73 * fs_mountpoint *
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;
81 int r = OK;
82 mode_t bits;
84 /* Temporarily open the file. */
85 if ((rip = get_dir_record(fs_m_in.REQ_INODE_NR)) == NULL)
86 return(EINVAL);
88 if (rip->d_mountpoint)
89 r = EBUSY;
91 /* If the inode is not a dir returns error */
92 if ((rip->d_mode & I_TYPE) != I_DIRECTORY)
93 r = ENOTDIR;
95 release_dir_record(rip);
97 if (r == OK)
98 rip->d_mountpoint = TRUE;
100 return(r);
104 /*===========================================================================*
105 * fs_unmount *
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);
110 return(OK);