New upstream version 1.0.3
[sven/exfatprogs.git] / fsck / fsck.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  *  Copyright (C) 2020 Hyunchul Lee <hyc.lee@gmail.com>
4  */
5 #ifndef _FSCK_H
6 #define _FSCK_H
7
8 #include "list.h"
9
10 typedef __u32 clus_t;
11
12 struct exfat_inode {
13         struct exfat_inode      *parent;
14         struct list_head        children;
15         struct list_head        sibling;
16         struct list_head        list;
17         clus_t                  first_clus;
18         clus_t                  last_lclus;
19         clus_t                  last_pclus;
20         __u16                   attr;
21         uint64_t                size;
22         bool                    is_contiguous;
23         off_t                   dentry_file_offset;
24         __le16                  name[0];        /* only for directory */
25 };
26
27 #define EXFAT_NAME_MAX                  255
28 #define NAME_BUFFER_SIZE                ((EXFAT_NAME_MAX+1)*2)
29
30 struct exfat_de_iter {
31         struct exfat            *exfat;
32         struct exfat_inode      *parent;
33         unsigned char           *dentries;      /* cluster * 2 allocated */
34         unsigned int            read_size;      /* cluster size */
35         off_t                   de_file_offset; /* offset in dentries buffer */
36         off_t                   next_read_offset;
37         int                     max_skip_dentries;
38 };
39
40 enum fsck_ui_options {
41         FSCK_OPTS_REPAIR_ASK    = 0x01,
42         FSCK_OPTS_REPAIR_YES    = 0x02,
43         FSCK_OPTS_REPAIR_NO     = 0x04,
44         FSCK_OPTS_REPAIR        = 0x07,
45 };
46
47 struct exfat {
48         enum fsck_ui_options    options;
49         struct exfat_blk_dev    *blk_dev;
50         struct pbr              *bs;
51         char                    volume_label[VOLUME_LABEL_BUFFER_SIZE];
52         struct exfat_inode      *root;
53         struct list_head        dir_list;
54         struct exfat_de_iter    de_iter;
55         __u32                   *alloc_bitmap;
56         __u64                   bit_count;
57 };
58
59 #define EXFAT_CLUSTER_SIZE(pbr) (1 << ((pbr)->bsx.sect_size_bits +      \
60                                         (pbr)->bsx.sect_per_clus_bits))
61 #define EXFAT_SECTOR_SIZE(pbr) (1 << (pbr)->bsx.sect_size_bits)
62
63 #endif