"Fossies" - the Fresh Open Source Software Archive

Member "dosfstools-4.2/src/fat.h" (31 Jan 2021, 3119 Bytes) of package /linux/misc/dosfstools-4.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "fat.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 4.1_vs_4.2.

    1 /* fat.h - Read/write access to the FAT
    2 
    3    Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
    4    Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
    5 
    6    This program is free software: you can redistribute it and/or modify
    7    it under the terms of the GNU General Public License as published by
    8    the Free Software Foundation, either version 3 of the License, or
    9    (at your option) any later version.
   10 
   11    This program is distributed in the hope that it will be useful,
   12    but WITHOUT ANY WARRANTY; without even the implied warranty of
   13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   14    GNU General Public License for more details.
   15 
   16    You should have received a copy of the GNU General Public License
   17    along with this program. If not, see <http://www.gnu.org/licenses/>.
   18 
   19    THe complete text of the GNU General Public License
   20    can be found in /usr/share/common-licenses/GPL-3 file.
   21 */
   22 
   23 #ifndef _FAT_H
   24 #define _FAT_H
   25 
   26 void read_fat(DOS_FS * fs, int mode);
   27 
   28 /* Loads the FAT of the filesystem described by FS. Initializes the FAT,
   29    replaces broken FATs and rejects invalid cluster entries. */
   30 
   31 void release_fat(DOS_FS * fs);
   32 
   33 /* Release the FAT of the filesystem described by FS and free allocated memory.
   34    Call it after finish work with FAT. */
   35 
   36 void get_fat(FAT_ENTRY * entry, void *fat, uint32_t cluster, DOS_FS * fs);
   37 
   38 /* Retrieve the FAT entry (next chained cluster) for CLUSTER. */
   39 
   40 void set_fat(DOS_FS * fs, uint32_t cluster, int32_t new);
   41 
   42 /* Changes the value of the CLUSTERth cluster of the FAT of FS to NEW. Special
   43    values of NEW are -1 (EOF, 0xff8 or 0xfff8) and -2 (bad sector, 0xff7 or
   44    0xfff7) */
   45 
   46 int bad_cluster(DOS_FS * fs, uint32_t cluster);
   47 
   48 /* Returns a non-zero integer if the CLUSTERth cluster is marked as bad or zero
   49    otherwise. */
   50 
   51 uint32_t next_cluster(DOS_FS * fs, uint32_t cluster);
   52 
   53 /* Returns the number of the cluster following CLUSTER, or -1 if this is the
   54    last cluster of the respective cluster chain. CLUSTER must not be a bad
   55    cluster. */
   56 
   57 off_t cluster_start(DOS_FS * fs, uint32_t cluster);
   58 
   59 /* Returns the byte offset of CLUSTER, relative to the respective device. */
   60 
   61 void set_owner(DOS_FS * fs, uint32_t cluster, DOS_FILE * owner);
   62 
   63 /* Sets the owner pointer of the respective cluster to OWNER. If OWNER was NULL
   64    before, it can be set to NULL or any non-NULL value. Otherwise, only NULL is
   65    accepted as the new value. */
   66 
   67 DOS_FILE *get_owner(DOS_FS * fs, uint32_t cluster);
   68 
   69 /* Returns the owner of the repective cluster or NULL if the cluster has no
   70    owner. */
   71 
   72 void fix_bad(DOS_FS * fs);
   73 
   74 /* Scans the disk for currently unused bad clusters and marks them as bad. */
   75 
   76 void reclaim_free(DOS_FS * fs);
   77 
   78 /* Marks all allocated, but unused clusters as free. */
   79 
   80 void reclaim_file(DOS_FS * fs);
   81 
   82 /* Scans the FAT for chains of allocated, but unused clusters and creates files
   83    for them in the root directory. Also tries to fix all inconsistencies (e.g.
   84    loops, shared clusters, etc.) in the process. */
   85 
   86 uint32_t update_free(DOS_FS * fs);
   87 
   88 /* Updates free cluster count in FSINFO sector. */
   89 
   90 #endif