Subversion Repositories HelenOS

Rev

Rev 2644 | Rev 2793 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2644 Rev 2789
Line 1... Line 1...
1
/*
1
/*
2
 * Copyright (c) 2007 Jakub Jermar
2
 * Copyright (c) 2008 Jakub Jermar
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
Line 36... Line 36...
36
#include <ipc/ipc.h>
36
#include <ipc/ipc.h>
37
#include <libfs.h>
37
#include <libfs.h>
38
#include <atomic.h>
38
#include <atomic.h>
39
#include <sys/types.h>
39
#include <sys/types.h>
40
#include <bool.h>
40
#include <bool.h>
-
 
41
#include "../../vfs/vfs.h"
41
 
42
 
42
#define dprintf(...)    printf(__VA_ARGS__)
43
#define dprintf(...)    printf(__VA_ARGS__)
43
 
44
 
44
typedef struct {
45
typedef struct {
45
    uint8_t     ji[3];      /**< Jump instruction. */
46
    uint8_t     ji[3];      /**< Jump instruction. */
46
    uint8_t     oem_name[8];
47
    uint8_t     oem_name[8];
47
    /* BIOS Parameter Block */
48
    /* BIOS Parameter Block */
48
    uint16_t    bps;        /**< Bytes per sector. */
49
    uint16_t    bps;        /**< Bytes per sector. */
49
    uint8_t     spc;        /**< Sectors per cluster. */
50
    uint8_t     spc;        /**< Sectors per cluster. */
50
    uint16_t    rsc;        /**< Reserved sector count. */
51
    uint16_t    rscnt;      /**< Reserved sector count. */
51
    uint8_t     fatcnt;     /**< Number of FATs. */
52
    uint8_t     fatcnt;     /**< Number of FATs. */
52
    uint16_t    root_ent_max;   /**< Maximum number of root directory
53
    uint16_t    root_ent_max;   /**< Maximum number of root directory
53
                         entries. */
54
                         entries. */
54
    uint16_t    totsec;     /**< Total sectors. */
55
    uint16_t    totsec16;   /**< Total sectors. 16-bit version. */
55
    uint8_t     mdesc;      /**< Media descriptor. */
56
    uint8_t     mdesc;      /**< Media descriptor. */
56
    uint16_t    sec_per_fat;    /**< Sectors per FAT12/FAT16. */
57
    uint16_t    sec_per_fat;    /**< Sectors per FAT12/FAT16. */
57
    uint16_t    sec_per_track;  /**< Sectors per track. */
58
    uint16_t    sec_per_track;  /**< Sectors per track. */
58
    uint16_t    headcnt;    /**< Number of heads. */
59
    uint16_t    headcnt;    /**< Number of heads. */
59
    uint32_t    hidden_sec; /**< Hidden sectors. */
60
    uint32_t    hidden_sec; /**< Hidden sectors. */
60
    uint32_t    total_sec;  /**< Total sectors. */
61
    uint32_t    totseci32;  /**< Total sectors. 32-bit version. */
61
 
62
 
62
    union {
63
    union {
63
        struct {
64
        struct {
64
            /* FAT12/FAT16 only: Extended BIOS Parameter Block */
65
            /* FAT12/FAT16 only: Extended BIOS Parameter Block */
65
            /** Physical drive number. */
66
            /** Physical drive number. */
Line 99... Line 100...
99
            /** Extended boot signature. */
100
            /** Extended boot signature. */
100
            uint8_t     ebs;
101
            uint8_t     ebs;
101
            /** Serial number. */
102
            /** Serial number. */
102
            uint32_t    id;
103
            uint32_t    id;
103
            /** Volume label. */
104
            /** Volume label. */
104
            uint8_t     label;
105
            uint8_t     label[11];
105
            /** FAT type. */
106
            /** FAT type. */
106
            uint8_t     type[8];
107
            uint8_t     type[8];
107
            /** Boot code. */
108
            /** Boot code. */
108
            uint8_t     boot_code[420];
109
            uint8_t     boot_code[420];
109
            /** Signature. */
110
            /** Signature. */
Line 132... Line 133...
132
        uint16_t    firstc_lo;  /* FAT32 */
133
        uint16_t    firstc_lo;  /* FAT32 */
133
    };
134
    };
134
    uint32_t    size;
135
    uint32_t    size;
135
} __attribute__ ((packed)) fat_dentry_t;
136
} __attribute__ ((packed)) fat_dentry_t;
136
 
137
 
-
 
138
typedef enum {
-
 
139
    FAT_DIRECTORY,
-
 
140
    FAT_FILE
-
 
141
} fat_node_type_t;
-
 
142
 
-
 
143
/** FAT in-core node. */
-
 
144
typedef struct {
-
 
145
    fat_node_type_t     type;
-
 
146
    /** VFS index is the node's first allocated cluster. */
-
 
147
    fs_index_t      index;
-
 
148
    dev_handle_t        dev_handle;
-
 
149
    /** FAT in-core node hash table link. */
-
 
150
    link_t          fin_link;
-
 
151
    size_t          size;
-
 
152
    unsigned        lnkcnt;
-
 
153
} fat_node_t;
-
 
154
 
137
extern fs_reg_t fat_reg;
155
extern fs_reg_t fat_reg;
138
 
156
 
139
extern void fat_lookup(ipc_callid_t, ipc_call_t *);
157
extern void fat_lookup(ipc_callid_t, ipc_call_t *);
140
 
158
 
141
#endif
159
#endif