blob: 0d2351a6a10e2d0d6e69230cf8d92abd21c0645a [file] [log] [blame]
wdenk2262cfe2002-11-18 00:14:45 +00001/*
2 * (C) Copyright 2002
Albert ARIBAUDfa82f872011-08-04 18:45:45 +02003 * Stäubli Faverges - <www.staubli.com>
wdenk2262cfe2002-11-18 00:14:45 +00004 * Pierre AUBERT p.aubert@staubli.com
5 *
6 * See file CREDITS for list of people who contributed to this
7 * project.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA
23 */
24
25#ifndef _FDOS_H_
26#define _FDOS_H_
27
28
29#undef FDOS_DEBUG
30
31#ifdef FDOS_DEBUG
32#define PRINTF(fmt,args...) printf (fmt ,##args)
33#else
34#define PRINTF(fmt,args...)
35#endif
36
37/* Data structure describing media */
38typedef struct fs
39{
40 unsigned long tot_sectors;
41
42 int cluster_size;
43 int num_clus;
wdenk8bde7f72003-06-27 21:31:46 +000044
wdenk2262cfe2002-11-18 00:14:45 +000045 int fat_start;
46 int fat_len;
47 int nb_fat;
48 int num_fat;
wdenk8bde7f72003-06-27 21:31:46 +000049
wdenk2262cfe2002-11-18 00:14:45 +000050 int dir_start;
51 int dir_len;
52
53 unsigned char *fat_buf;
wdenk8bde7f72003-06-27 21:31:46 +000054
wdenk2262cfe2002-11-18 00:14:45 +000055} Fs_t;
56
57/* Data structure describing one file system slot */
58typedef struct slot {
59 int (*map) (struct fs *fs,
wdenk8bde7f72003-06-27 21:31:46 +000060 struct slot *file,
61 int where,
62 int *len);
wdenk2262cfe2002-11-18 00:14:45 +000063 unsigned long FileSize;
64
65 unsigned short int FirstAbsCluNr;
66 unsigned short int PreviousAbsCluNr;
67 unsigned short int PreviousRelCluNr;
68
69 Directory_t dir;
70} Slot_t;
71
72typedef struct file {
73 char *name;
74 int Case;
75 Fs_t *fs;
76 Slot_t subdir;
77 Slot_t file;
78} File_t;
79
80
81/* dev.c */
82int dev_read (void *buffer, int where, int len);
83int dev_open (void);
84int check_dev (BootSector_t *boot, Fs_t *fs);
85
86/* fat.c */
87unsigned int fat_decode (Fs_t *fs, unsigned int num);
88int read_fat (BootSector_t *boot, Fs_t *fs);
89
90/* vfat.c */
91int vfat_lookup (Slot_t *dir,
wdenk8bde7f72003-06-27 21:31:46 +000092 Fs_t *fs,
93 Directory_t *dirent,
94 int *entry,
95 int *vfat_start,
96 char *filename,
97 int flags,
98 char *outname,
99 Slot_t *file);
wdenk2262cfe2002-11-18 00:14:45 +0000100
101/* subdir.c */
102char *basename (char *name);
103int open_subdir (File_t *desc);
104int open_file (Slot_t *file, Directory_t *dir);
105int read_file (Fs_t *fs,
wdenk8bde7f72003-06-27 21:31:46 +0000106 Slot_t *file,
107 char *buf,
108 int where,
109 int len);
wdenk2262cfe2002-11-18 00:14:45 +0000110void init_subdir (void);
111
112/* fs.c */
113int fs_init (Fs_t *fs);
114
115
116#endif