1a7ce5b29Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 2a7ce5b29Sopenharmony_ci/* 3a7ce5b29Sopenharmony_ci * Copyright (C) 2021 LG Electronics. 4a7ce5b29Sopenharmony_ci * 5a7ce5b29Sopenharmony_ci * Author(s): Hyunchul Lee <hyc.lee@gmail.com> 6a7ce5b29Sopenharmony_ci */ 7a7ce5b29Sopenharmony_ci 8a7ce5b29Sopenharmony_ci#ifndef _DIR_H_ 9a7ce5b29Sopenharmony_ci#define _DIR_H_ 10a7ce5b29Sopenharmony_ci 11a7ce5b29Sopenharmony_cistruct exfat; 12a7ce5b29Sopenharmony_cistruct exfat_inode; 13a7ce5b29Sopenharmony_cistruct exfat_dentry_loc; 14a7ce5b29Sopenharmony_cistruct buffer_desc; 15a7ce5b29Sopenharmony_ci 16a7ce5b29Sopenharmony_cistruct exfat_de_iter { 17a7ce5b29Sopenharmony_ci struct exfat *exfat; 18a7ce5b29Sopenharmony_ci struct exfat_inode *parent; 19a7ce5b29Sopenharmony_ci struct buffer_desc *buffer_desc; /* cluster * 2 */ 20a7ce5b29Sopenharmony_ci __u32 ra_next_clus; 21a7ce5b29Sopenharmony_ci unsigned int ra_begin_offset; 22a7ce5b29Sopenharmony_ci unsigned int ra_partial_size; 23a7ce5b29Sopenharmony_ci unsigned int read_size; /* cluster size */ 24a7ce5b29Sopenharmony_ci unsigned int write_size; /* sector size */ 25a7ce5b29Sopenharmony_ci off_t de_file_offset; 26a7ce5b29Sopenharmony_ci off_t next_read_offset; 27a7ce5b29Sopenharmony_ci int max_skip_dentries; 28a7ce5b29Sopenharmony_ci#define DOT_NAME_NUM_MAX 9999999 29a7ce5b29Sopenharmony_ci unsigned int dot_name_num; 30a7ce5b29Sopenharmony_ci}; 31a7ce5b29Sopenharmony_ci 32a7ce5b29Sopenharmony_cistruct exfat_lookup_filter { 33a7ce5b29Sopenharmony_ci struct { 34a7ce5b29Sopenharmony_ci uint8_t type; 35a7ce5b29Sopenharmony_ci /* return 0 if matched, return 1 if not matched, 36a7ce5b29Sopenharmony_ci * otherwise return errno 37a7ce5b29Sopenharmony_ci */ 38a7ce5b29Sopenharmony_ci int (*filter)(struct exfat_de_iter *iter, 39a7ce5b29Sopenharmony_ci void *param, int *dentry_count); 40a7ce5b29Sopenharmony_ci void *param; 41a7ce5b29Sopenharmony_ci } in; 42a7ce5b29Sopenharmony_ci struct { 43a7ce5b29Sopenharmony_ci struct exfat_dentry *dentry_set; 44a7ce5b29Sopenharmony_ci int dentry_count; 45a7ce5b29Sopenharmony_ci off_t file_offset; 46a7ce5b29Sopenharmony_ci /* device offset where the dentry_set locates, or 47a7ce5b29Sopenharmony_ci * the empty slot locates or EOF if not found. 48a7ce5b29Sopenharmony_ci */ 49a7ce5b29Sopenharmony_ci off_t dev_offset; 50a7ce5b29Sopenharmony_ci } out; 51a7ce5b29Sopenharmony_ci}; 52a7ce5b29Sopenharmony_ci 53a7ce5b29Sopenharmony_ciint exfat_de_iter_init(struct exfat_de_iter *iter, struct exfat *exfat, 54a7ce5b29Sopenharmony_ci struct exfat_inode *dir, struct buffer_desc *bd); 55a7ce5b29Sopenharmony_ciint exfat_de_iter_get(struct exfat_de_iter *iter, 56a7ce5b29Sopenharmony_ci int ith, struct exfat_dentry **dentry); 57a7ce5b29Sopenharmony_ciint exfat_de_iter_get_dirty(struct exfat_de_iter *iter, 58a7ce5b29Sopenharmony_ci int ith, struct exfat_dentry **dentry); 59a7ce5b29Sopenharmony_ciint exfat_de_iter_flush(struct exfat_de_iter *iter); 60a7ce5b29Sopenharmony_ciint exfat_de_iter_advance(struct exfat_de_iter *iter, int skip_dentries); 61a7ce5b29Sopenharmony_cioff_t exfat_de_iter_device_offset(struct exfat_de_iter *iter); 62a7ce5b29Sopenharmony_cioff_t exfat_de_iter_file_offset(struct exfat_de_iter *iter); 63a7ce5b29Sopenharmony_ci 64a7ce5b29Sopenharmony_ciint exfat_lookup_dentry_set(struct exfat *exfat, struct exfat_inode *parent, 65a7ce5b29Sopenharmony_ci struct exfat_lookup_filter *filter); 66a7ce5b29Sopenharmony_ciint exfat_lookup_file(struct exfat *exfat, struct exfat_inode *parent, 67a7ce5b29Sopenharmony_ci const char *name, struct exfat_lookup_filter *filter_out); 68a7ce5b29Sopenharmony_ci 69a7ce5b29Sopenharmony_ciint exfat_create_file(struct exfat *exfat, struct exfat_inode *parent, 70a7ce5b29Sopenharmony_ci const char *name, unsigned short attr); 71a7ce5b29Sopenharmony_ciint exfat_update_file_dentry_set(struct exfat *exfat, 72a7ce5b29Sopenharmony_ci struct exfat_dentry *dset, int dcount, 73a7ce5b29Sopenharmony_ci const char *name, 74a7ce5b29Sopenharmony_ci clus_t start_clu, clus_t ccount); 75a7ce5b29Sopenharmony_ciint exfat_build_file_dentry_set(struct exfat *exfat, const char *name, 76a7ce5b29Sopenharmony_ci unsigned short attr, struct exfat_dentry **dentry_set, 77a7ce5b29Sopenharmony_ci int *dentry_count); 78a7ce5b29Sopenharmony_ciint exfat_add_dentry_set(struct exfat *exfat, struct exfat_dentry_loc *loc, 79a7ce5b29Sopenharmony_ci struct exfat_dentry *dset, int dcount, 80a7ce5b29Sopenharmony_ci bool need_next_loc); 81a7ce5b29Sopenharmony_civoid exfat_calc_dentry_checksum(struct exfat_dentry *dentry, 82a7ce5b29Sopenharmony_ci uint16_t *checksum, bool primary); 83a7ce5b29Sopenharmony_ciuint16_t exfat_calc_name_hash(struct exfat *exfat, 84a7ce5b29Sopenharmony_ci __le16 *name, int len); 85a7ce5b29Sopenharmony_ci 86a7ce5b29Sopenharmony_ci#endif 87