1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 2021 LG Electronics.
5 * Author(s): Hyunchul Lee <hyc.lee@gmail.com>
13 struct exfat_dentry_loc;
16 struct exfat_de_iter {
18 struct exfat_inode *parent;
19 struct buffer_desc *buffer_desc;
21 unsigned int ra_begin_offset;
22 unsigned int ra_partial_size;
23 unsigned int read_size; /* cluster size */
24 unsigned int write_size; /* sector size */
26 off_t next_read_offset;
27 int max_skip_dentries;
28 #define INVALID_NAME_NUM_MAX 9999999
29 unsigned int invalid_name_num;
31 char *name_hash_bitmap; /* bitmap of children's name hashes */
34 struct exfat_lookup_filter {
38 /* return 0 if matched, return 1 if not matched,
39 * otherwise return errno
41 int (*filter)(struct exfat_de_iter *iter,
42 void *param, int *dentry_count);
46 struct exfat_dentry *dentry_set;
50 * If the dentry_set found:
51 * - device offset where the dentry_set locates.
52 * If the dentry_set not found:
53 * - device offset where the first empty dentry_set locates
54 * if in.dentry_count > 0 and there are enough empty dentry.
55 * - device offset where the last empty dentry_set locates
56 * if in.dentry_count = 0 or no enough empty dentry.
57 * - EOF if no empty dentry_set.
63 int exfat_de_iter_init(struct exfat_de_iter *iter, struct exfat *exfat,
64 struct exfat_inode *dir, struct buffer_desc *bd);
65 int exfat_de_iter_get(struct exfat_de_iter *iter,
66 int ith, struct exfat_dentry **dentry);
67 int exfat_de_iter_get_dirty(struct exfat_de_iter *iter,
68 int ith, struct exfat_dentry **dentry);
69 int exfat_de_iter_flush(struct exfat_de_iter *iter);
70 int exfat_de_iter_advance(struct exfat_de_iter *iter, int skip_dentries);
71 off_t exfat_de_iter_device_offset(struct exfat_de_iter *iter);
72 off_t exfat_de_iter_file_offset(struct exfat_de_iter *iter);
74 int exfat_lookup_dentry_set(struct exfat *exfat, struct exfat_inode *parent,
75 struct exfat_lookup_filter *filter);
76 int exfat_lookup_file(struct exfat *exfat, struct exfat_inode *parent,
77 const char *name, struct exfat_lookup_filter *filter_out);
78 int exfat_lookup_file_by_utf16name(struct exfat *exfat,
79 struct exfat_inode *parent,
81 struct exfat_lookup_filter *filter_out);
83 int exfat_create_file(struct exfat *exfat, struct exfat_inode *parent,
84 const char *name, unsigned short attr);
85 int exfat_update_file_dentry_set(struct exfat *exfat,
86 struct exfat_dentry *dset, int dcount,
88 clus_t start_clu, clus_t ccount);
89 int exfat_build_file_dentry_set(struct exfat *exfat, const char *name,
90 unsigned short attr, struct exfat_dentry **dentry_set,
92 int exfat_add_dentry_set(struct exfat *exfat, struct exfat_dentry_loc *loc,
93 struct exfat_dentry *dset, int dcount,
95 void exfat_calc_dentry_checksum(struct exfat_dentry *dentry,
96 uint16_t *checksum, bool primary);
97 uint16_t exfat_calc_name_hash(struct exfat *exfat,
98 __le16 *name, int len);