Fixed extern declaration from pointer to array
[minix.git] / servers / iso9660fs / super.c
blob7e56a26be5fdb697ee1f4946d6f2611fce8c51fa
1 /* Functions to manage the superblock of the filesystem. These functions are
2 * are called at the beginning and at the end of the server. */
4 #include "inc.h"
5 #include <string.h>
6 #include <minix/com.h>
7 #include <minix/u64.h>
9 /* This function is called when the filesystem is umounted. It releases the
10 * super block. */
11 PUBLIC int release_v_pri(v_pri)
12 register struct iso9660_vd_pri *v_pri;
14 /* Release the root dir record */
15 release_dir_record(v_pri->dir_rec_root);
16 v_pri->count = 0;
17 return OK;
20 /* This function fullfill the super block data structure using the information
21 * contained in the stream buf. Such stream is physically read from the device
22 * . */
23 PUBLIC int create_v_pri(v_pri,buf,address)
24 register struct iso9660_vd_pri *v_pri;
25 register char* buf;
26 register unsigned long address;
28 struct dir_record *dir;
30 v_pri->vd_type = buf[0];
31 memcpy(v_pri->standard_id,buf + 1,sizeof(v_pri->standard_id));
32 v_pri->vd_version = buf[6];
33 memcpy(v_pri->system_id,buf + 8,sizeof(v_pri->system_id));
34 memcpy(v_pri->volume_id,buf + 40,sizeof(v_pri->volume_id));
35 memcpy(&v_pri->volume_space_size_l,buf + 80,
36 sizeof(v_pri->volume_space_size_l));
37 memcpy(&v_pri->volume_space_size_m,buf + 84,
38 sizeof(v_pri->volume_space_size_m));
39 memcpy(&v_pri->volume_set_size,buf + 120,sizeof(v_pri->volume_set_size));
40 memcpy(&v_pri->volume_sequence_number,buf + 124,
41 sizeof(v_pri->volume_sequence_number));
42 memcpy(&v_pri->logical_block_size_l,buf + 128,
43 sizeof(v_pri->logical_block_size_l));
44 memcpy(&v_pri->logical_block_size_m,buf + 130,
45 sizeof(v_pri->logical_block_size_m));
46 memcpy(&v_pri->path_table_size_l,buf + 132,
47 sizeof(v_pri->path_table_size_l));
48 memcpy(&v_pri->path_table_size_m,buf + 136,
49 sizeof(v_pri->path_table_size_m));
50 memcpy(&v_pri->loc_l_occ_path_table,buf + 140,
51 sizeof(v_pri->loc_l_occ_path_table));
52 memcpy(&v_pri->loc_opt_l_occ_path_table,buf + 144,
53 sizeof(v_pri->loc_opt_l_occ_path_table));
54 memcpy(&v_pri->loc_m_occ_path_table, buf + 148,
55 sizeof(v_pri->loc_m_occ_path_table));
56 memcpy(&v_pri->loc_opt_m_occ_path_table,buf + 152,
57 sizeof(v_pri->loc_opt_m_occ_path_table));
59 dir = get_free_dir_record();
60 if (dir == NULL) return EINVAL;
61 create_dir_record(dir,buf + 156,(u32_t)(address + 156));
62 v_pri->dir_rec_root = dir;
63 dir->d_ino_nr = ROOT_INO_NR;
65 memcpy(v_pri->volume_set_id,buf + 190,sizeof(v_pri->volume_set_id));
66 memcpy(v_pri->publisher_id,buf + 318,sizeof(v_pri->publisher_id));
67 memcpy(v_pri->data_preparer_id,buf + 446,sizeof(v_pri->data_preparer_id));
68 memcpy(v_pri->application_id,buf + 574,sizeof(v_pri->application_id));
69 memcpy(v_pri->copyright_file_id,buf + 702,sizeof(v_pri->copyright_file_id));
70 memcpy(v_pri->abstract_file_id,buf + 739,sizeof(v_pri->abstract_file_id));
71 memcpy(v_pri->bibl_file_id,buf + 776,sizeof(v_pri->bibl_file_id));
72 memcpy(v_pri->volume_cre_date,buf + 813,sizeof(v_pri->volume_cre_date));
73 memcpy(v_pri->volume_mod_date,buf + 830,sizeof(v_pri->volume_mod_date));
74 memcpy(v_pri->volume_exp_date,buf + 847,sizeof(v_pri->volume_exp_date));
75 memcpy(v_pri->volume_eff_date,buf + 864,sizeof(v_pri->volume_eff_date));
76 v_pri->file_struct_ver = buf[881];
77 return OK;
80 /* This function reads from a ISO9660 filesystem (in the device dev) the
81 * super block and saves it in v_pri. */
82 PUBLIC int read_vds(v_pri,dev)
83 register struct iso9660_vd_pri *v_pri;
84 register dev_t dev;
86 u64_t offset;
87 int vol_ok = FALSE;
88 int r;
89 static char sbbuf[ISO9660_MIN_BLOCK_SIZE];
90 int i = 0;
92 offset = cvul64(ISO9660_SUPER_BLOCK_POSITION);
93 while (!vol_ok && i++<MAX_ATTEMPTS) {
95 /* Read the sector of the super block. */
96 r = block_dev_io(MFS_DEV_READ, dev, SELF_E, sbbuf, offset, ISO9660_MIN_BLOCK_SIZE, 0);
98 if (r != ISO9660_MIN_BLOCK_SIZE) /* Damaged sector or what? */
99 continue;
101 if ((sbbuf[0] & BYTE) == VD_PRIMARY) {
102 create_v_pri(v_pri,sbbuf,cv64ul(offset)); /* copy the buffer in the data structure. */
105 if ((sbbuf[0] & BYTE) == VD_SET_TERM)
106 /* I dont need to save anything about it */
107 vol_ok = TRUE;
109 offset = add64u(offset,ISO9660_MIN_BLOCK_SIZE);
112 if (vol_ok == FALSE)
113 return EINVAL; /* If no superblock was found... */
114 else
115 return OK; /* otherwise. */