blob: 2d8fe9d13d206133aec5a784983a4882b46e53e4 [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 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
wdenk2262cfe2002-11-18 00:14:45 +00007 */
8
9#ifndef _FDOS_H_
10#define _FDOS_H_
11
12
13#undef FDOS_DEBUG
14
15#ifdef FDOS_DEBUG
16#define PRINTF(fmt,args...) printf (fmt ,##args)
17#else
18#define PRINTF(fmt,args...)
19#endif
20
21/* Data structure describing media */
22typedef struct fs
23{
24 unsigned long tot_sectors;
25
26 int cluster_size;
27 int num_clus;
wdenk8bde7f72003-06-27 21:31:46 +000028
wdenk2262cfe2002-11-18 00:14:45 +000029 int fat_start;
30 int fat_len;
31 int nb_fat;
32 int num_fat;
wdenk8bde7f72003-06-27 21:31:46 +000033
wdenk2262cfe2002-11-18 00:14:45 +000034 int dir_start;
35 int dir_len;
36
37 unsigned char *fat_buf;
wdenk8bde7f72003-06-27 21:31:46 +000038
wdenk2262cfe2002-11-18 00:14:45 +000039} Fs_t;
40
41/* Data structure describing one file system slot */
42typedef struct slot {
43 int (*map) (struct fs *fs,
wdenk8bde7f72003-06-27 21:31:46 +000044 struct slot *file,
45 int where,
46 int *len);
wdenk2262cfe2002-11-18 00:14:45 +000047 unsigned long FileSize;
48
49 unsigned short int FirstAbsCluNr;
50 unsigned short int PreviousAbsCluNr;
51 unsigned short int PreviousRelCluNr;
52
53 Directory_t dir;
54} Slot_t;
55
56typedef struct file {
57 char *name;
58 int Case;
59 Fs_t *fs;
60 Slot_t subdir;
61 Slot_t file;
62} File_t;
63
64
65/* dev.c */
66int dev_read (void *buffer, int where, int len);
67int dev_open (void);
68int check_dev (BootSector_t *boot, Fs_t *fs);
69
70/* fat.c */
71unsigned int fat_decode (Fs_t *fs, unsigned int num);
72int read_fat (BootSector_t *boot, Fs_t *fs);
73
74/* vfat.c */
75int vfat_lookup (Slot_t *dir,
wdenk8bde7f72003-06-27 21:31:46 +000076 Fs_t *fs,
77 Directory_t *dirent,
78 int *entry,
79 int *vfat_start,
80 char *filename,
81 int flags,
82 char *outname,
83 Slot_t *file);
wdenk2262cfe2002-11-18 00:14:45 +000084
85/* subdir.c */
86char *basename (char *name);
87int open_subdir (File_t *desc);
88int open_file (Slot_t *file, Directory_t *dir);
89int read_file (Fs_t *fs,
wdenk8bde7f72003-06-27 21:31:46 +000090 Slot_t *file,
91 char *buf,
92 int where,
93 int len);
wdenk2262cfe2002-11-18 00:14:45 +000094void init_subdir (void);
95
96/* fs.c */
97int fs_init (Fs_t *fs);
98
99
100#endif