Annotation of dmsdos/src/lib_interface.h, revision 1.1.1.2

1.1       root        1: /*
                      2: lib_interface.h
                      3: 
                      4: DMSDOS library: headers for interface functions, hacks, dummies, and fakes.
                      5: 
                      6: ******************************************************************************
                      7: DMSDOS (compressed MSDOS filesystem support) for Linux
                      8: written 1995-1998 by Frank Gockel and Pavel Pisa
                      9: 
                     10:     (C) Copyright 1995-1998 by Frank Gockel
                     11:     (C) Copyright 1996-1998 by Pavel Pisa
                     12: 
                     13: Some code of dmsdos has been copied from the msdos filesystem
                     14: so there are the following additional copyrights:
                     15: 
                     16:     (C) Copyright 1992,1993 by Werner Almesberger (msdos filesystem)
                     17:     (C) Copyright 1994,1995 by Jacques Gelinas (mmap code)
                     18:     (C) Copyright 1992-1995 by Linus Torvalds
                     19: 
                     20: DMSDOS was inspired by the THS filesystem (a simple doublespace
                     21: DS-0-2 compressed read-only filesystem) written 1994 by Thomas Scheuermann.
                     22: 
                     23: The DMSDOS code is distributed under the Gnu General Public Licence.
                     24: See file COPYING for details.
                     25: ******************************************************************************
                     26: 
                     27: */
                     28: 
                     29: /* These are copied from the kernel include files in order to avoid
                     30:    including those files. They are not 100% identical to the kernel types.
                     31:    Most of them needn't be the same as in the kernel.
                     32:    This has been done for libc6 support.
                     33: */
                     34: 
1.1.1.2 ! root       35: /* machine and system dependent hacks */
        !            36: 
        !            37: /* Linux section -- no problems here... :)) */
        !            38: #ifdef __linux__
1.1       root       39: /* this defines machine-dependent __u8, __s8 etc. types */
                     40: #include<asm/types.h>
1.1.1.2 ! root       41: /* this defines get_unaligned and put_unaligned */
        !            42: #include<asm/unaligned.h>
        !            43: /* this defines cpu_to_le16 etc. in 2.1 kernels - a kind of nop for 2.0 */
        !            44: #include<asm/byteorder.h> 
        !            45: 
        !            46: /* Other systems usually do not have the asm include files */
        !            47: #else
        !            48: /* emulate asm/types.h */
        !            49: typedef unsigned char __u8;
        !            50: typedef signed char __s8;
        !            51: typedef unsigned short int __u16;
        !            52: typedef signed short int __s16;
        !            53: typedef unsigned int __u32;
        !            54: typedef signed int __s32;
        !            55: /* emulate asm/unaligned.h */
        !            56: /* edit these lines if your system cannot do unaligned access */
        !            57: #define get_unaligned(ptr) (*(ptr))
        !            58: #define put_unaligned(val, ptr) ((void)( *(ptr) = (val) ))
        !            59: /* emulate asm/byteorder.h */
        !            60: /* edit these lines if your system is non-linux and big endian */
        !            61: /* the examples are commented out; they are valid for a little endian cpu */
        !            62: /* #define cpu_to_le16(v) (v) */
        !            63: /* #define cpu_to_be16(v) ( (((v)&0xff)<<8) | (((v)&0xff00)>>8) ) */
        !            64: /* #define cpu_to_le32(v) (v) */
        !            65: /* hack: sometimes NULL is missing */
        !            66: #ifndef NULL
        !            67: #define NULL ((void*)0)
        !            68: #endif
        !            69: #endif
1.1       root       70: 
                     71: int printk(const char *fmt, ...);
                     72: void panic(const char * fmt, ...);
                     73: 
                     74: #define MOD_INC_USE_COUNT
                     75: #define MOD_DEC_USE_COUNT
                     76: 
                     77: #define SECTOR_SIZE 512
                     78: #define SECTOR_BITS 9
                     79: #define MSDOS_DPB       (MSDOS_DPS) /* dir entries per block */
                     80: #define MSDOS_DPB_BITS  4 /* log2(MSDOS_DPB) */
                     81: #define MSDOS_DPS       (SECTOR_SIZE/sizeof(struct msdos_dir_entry))
                     82: #define MSDOS_DPS_BITS  4 /* log2(MSDOS_DPS) */
                     83: #define MSDOS_DIR_BITS  5 /* log2(sizeof(struct msdos_dir_entry)) */
                     84: 
                     85: #define MSDOS_SUPER_MAGIC 0x4d44 /* MD */
                     86: 
                     87: #define MSDOS_MAX_EXTRA 3 /* tolerate up to that number of clusters which are
                     88:                              inaccessible because the FAT is too short */
                     89: 
                     90: #define KERN_EMERG      "<0>"   /* system is unusable                   */
                     91: #define KERN_ALERT      "<1>"   /* action must be taken immediately     */
                     92: #define KERN_CRIT       "<2>"   /* critical conditions                  */
                     93: #define KERN_ERR        "<3>"   /* error conditions                     */
                     94: #define KERN_WARNING    "<4>"   /* warning conditions                   */
                     95: #define KERN_NOTICE     "<5>"   /* normal but significant condition     */
                     96: #define KERN_INFO       "<6>"   /* informational                        */
                     97: #define KERN_DEBUG      "<7>"   /* debug-level messages                 */
                     98: 
                     99: struct buffer_head {
                    100:         unsigned long b_blocknr;        /* block number */
                    101:         char * b_data;                  /* pointer to data block */
                    102: };
                    103: 
                    104: #define MS_RDONLY   1      /* Mount read-only */
                    105: #define MSDOS_SB(s) (&((s)->u.msdos_sb))
                    106: 
1.1.1.2 ! root      107: struct msdos_dir_entry {
        !           108:         __s8    name[8],ext[3]; /* name and extension */
        !           109:         __u8    attr;           /* attribute bits */
        !           110:         __u8    lcase;          /* Case for base and extension */
        !           111:         __u8    ctime_ms;       /* Creation time, milliseconds */
        !           112:         __u16   ctime;          /* Creation time */
        !           113:         __u16   cdate;          /* Creation date */
        !           114:         __u16   adate;          /* Last access date */
        !           115:         __u16   starthi;        /* High 16 bits of cluster in FAT32 */
        !           116:         __u16   time,date,start;/* time, date and first cluster */
        !           117:         __u32   size;           /* file size (in bytes) */
        !           118: };
        !           119: 
1.1       root      120: struct msdos_sb_info {
                    121:         unsigned short cluster_size; /* sectors/cluster */
                    122:         unsigned char fats,fat_bits; /* number of FATs, FAT bits (12 or 16) */
                    123:         unsigned short fat_start,fat_length; /* FAT start & length (sec.) */
                    124:         unsigned short dir_start,dir_entries; /* root dir start & entries */
                    125:         unsigned short data_start;   /* first data sector */
                    126:         unsigned long clusters;      /* number of clusters */
                    127:         unsigned long root_cluster;  /* first cluster of the root directory */
                    128:         unsigned long fsinfo_offset; /* FAT32 fsinfo offset from start of disk */
                    129:         void *fat_wait;
                    130:         int fat_lock;
                    131:         int prev_free;               /* previously returned free cluster number */
                    132:         int free_clusters;           /* -1 if undefined */
                    133:         /*struct fat_mount_options options;*/
                    134:         struct nls_table *nls_disk;  /* Codepage used on disk */
                    135:         struct nls_table *nls_io;    /* Charset used for input and display */
                    136:         struct cvf_format* cvf_format;
                    137:         void* private_data;
                    138: };
                    139: 
                    140: struct super_block {
                    141:         int s_dev;
                    142:         unsigned long s_blocksize;
                    143:         unsigned char s_blocksize_bits;
                    144:         unsigned long s_flags;
                    145:         unsigned long s_magic;
1.1.1.2 ! root      146:         unsigned long* directlist;
        !           147:         unsigned long* directlen;
        !           148:         unsigned long directsize;
1.1       root      149:         union {
                    150:                 struct msdos_sb_info msdos_sb;
                    151:         } u;
                    152: 
                    153: };
                    154: 
                    155: struct fat_boot_sector {
                    156:         __s8    ignored[3];     /* Boot strap short or near jump */
                    157:         __s8    system_id[8];   /* Name - can be used to special case
                    158:                                    partition manager volumes */
                    159:         __u8    sector_size[2]; /* bytes per logical sector */
                    160:         __u8    cluster_size;   /* sectors/cluster */
                    161:         __u16   reserved;       /* reserved sectors */
                    162:         __u8    fats;           /* number of FATs */
                    163:         __u8    dir_entries[2]; /* root directory entries */
                    164:         __u8    sectors[2];     /* number of sectors */
                    165:         __u8    media;          /* media code (unused) */
                    166:         __u16   fat_length;     /* sectors/FAT */
                    167:         __u16   secs_track;     /* sectors per track */
                    168:         __u16   heads;          /* number of heads */
                    169:         __u32   hidden;         /* hidden sectors (unused) */
                    170:         __u32   total_sect;     /* number of sectors (if sectors == 0) */
                    171:         /* The following fields are only used by FAT32 */
                    172:         __u32   fat32_length;   /* sectors/FAT */
                    173:         __u16   flags;          /* bit 8: fat mirroring, low 4: active fat */
                    174:         __u8    version[2];     /* major, minor filesystem version */
                    175:         __u32   root_cluster;   /* first cluster in root directory */
                    176:         __u16   info_sector;    /* filesystem info sector */
                    177:         __u16   backup_boot;    /* backup boot sector */
                    178:         __u16   reserved2[6];   /* Unused */
                    179: };
                    180: 
                    181: #define MALLOC malloc
                    182: #define FREE free
                    183: #define kmalloc(x,y) malloc(x)
                    184: #define kfree free
                    185: #define CURRENT_TIME time(NULL)
                    186: #define vmalloc malloc
                    187: #define vfree free
1.1.1.2 ! root      188: 
        !           189: #define MAXFRAGMENT 300

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.