3 * Stäubli Faverges - <www.staubli.com>
4 * Pierre AUBERT p.aubert@staubli.com
6 * SPDX-License-Identifier: GPL-2.0+
17 /*-----------------------------------------------------------------------------
18 * fill_fs -- Read info on file system
19 *-----------------------------------------------------------------------------
21 static int fill_fs (BootSector_t *boot, Fs_t *fs)
24 fs -> fat_start = __le16_to_cpu (boot -> nrsvsect);
25 fs -> fat_len = __le16_to_cpu (boot -> fatlen);
26 fs -> nb_fat = boot -> nfat;
28 fs -> dir_start = fs -> fat_start + fs -> nb_fat * fs -> fat_len;
29 fs -> dir_len = __le16_to_cpu (boot -> dirents) * MDIR_SIZE / SZ_STD_SECTOR;
30 fs -> cluster_size = boot -> clsiz;
31 fs -> num_clus = (fs -> tot_sectors - fs -> dir_start - fs -> dir_len) / fs -> cluster_size;
36 /*-----------------------------------------------------------------------------
38 *-----------------------------------------------------------------------------
40 int fs_init (Fs_t *fs)
44 /* Initialize physical device */
45 if (dev_open () < 0) {
46 PRINTF ("Unable to initialize the fdc\n");
51 /* Allocate space for read the boot sector */
52 if ((boot = (BootSector_t *)malloc (sizeof (BootSector_t))) == NULL) {
53 PRINTF ("Unable to allocate space for boot sector\n");
57 /* read boot sector */
58 if (dev_read (boot, 0, 1)){
59 PRINTF ("Error during boot sector read\n");
64 /* we verify it'a a DOS diskette */
65 if (boot -> jump [0] != JUMP_0_1 && boot -> jump [0] != JUMP_0_2) {
66 PRINTF ("Not a DOS diskette\n");
71 if (boot -> descr < MEDIA_STD) {
72 /* We handle only recent medias (type F0) */
73 PRINTF ("unrecognized diskette type\n");
78 if (check_dev (boot, fs) < 0) {
79 PRINTF ("Bad diskette\n");
84 if (fill_fs (boot, fs) < 0) {
91 if (read_fat (boot, fs) < 0) {