source: bootcd/isolinux/syslinux-6.03/libfat/libfat.h

Last change on this file was e16e8f2, checked in by Edwin Eefting <edwin@datux.nl>, 3 years ago

bootstuff

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/* ----------------------------------------------------------------------- *
2 *
3 *   Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
4 *
5 *   This program is free software; you can redistribute it and/or modify
6 *   it under the terms of the GNU General Public License as published by
7 *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 *   Boston MA 02111-1307, USA; either version 2 of the License, or
9 *   (at your option) any later version; incorporated herein by reference.
10 *
11 * ----------------------------------------------------------------------- */
12
13/*
14 * libfat.h
15 *
16 * Headers for the libfat library
17 */
18
19#ifndef LIBFAT_H
20#define LIBFAT_H
21
22#include <stddef.h>
23#include <inttypes.h>
24
25#define LIBFAT_SECTOR_SHIFT     9
26#define LIBFAT_SECTOR_SIZE      512
27#define LIBFAT_SECTOR_MASK      511
28
29typedef uint64_t libfat_sector_t;
30struct libfat_filesystem;
31
32struct libfat_direntry {
33    libfat_sector_t sector;
34    int offset;
35    unsigned char entry[32];
36};
37
38/*
39 * Open the filesystem.  The readfunc is the function to read
40 * sectors, in the format:
41 * int readfunc(intptr_t readptr, void *buf, size_t secsize,
42 *              libfat_sector_t secno)
43 *
44 * ... where readptr is a private argument.
45 *
46 * A return value of != secsize is treated as error.
47 */
48struct libfat_filesystem
49    *libfat_open(int (*readfunc) (intptr_t, void *, size_t, libfat_sector_t),
50                 intptr_t readptr);
51
52void libfat_close(struct libfat_filesystem *);
53
54/*
55 * Convert a cluster number (or 0 for the root directory) to a
56 * sector number.  Return -1 on failure.
57 */
58libfat_sector_t libfat_clustertosector(const struct libfat_filesystem *fs,
59                                       int32_t cluster);
60
61/*
62 * Get the next sector of either the root directory or a FAT chain.
63 * Returns 0 on end of file and -1 on error.
64 */
65libfat_sector_t libfat_nextsector(struct libfat_filesystem *fs,
66                                  libfat_sector_t s);
67
68/*
69 * Flush all cached sectors for this filesystem.
70 */
71void libfat_flush(struct libfat_filesystem *fs);
72
73/*
74 * Get a pointer to a specific sector.
75 */
76void *libfat_get_sector(struct libfat_filesystem *fs, libfat_sector_t n);
77
78/*
79 * Search a FAT directory for a particular pre-mangled filename.
80 * Copies the directory entry into direntry and returns 0 if found.
81 */
82int32_t libfat_searchdir(struct libfat_filesystem *fs, int32_t dirclust,
83                         const void *name, struct libfat_direntry *direntry);
84
85#endif /* LIBFAT_H */
Note: See TracBrowser for help on using the repository browser.