summaryrefslogtreecommitdiff
path: root/fs/udf/udfdecl.h
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2022-10-03 23:33:22 +0200
committerJan Kara <jack@suse.cz>2023-01-09 10:39:51 +0100
commitd16076d9b684b7c8d3ccbe9c33d5ea9fe8fcca09 (patch)
tree3163337d34a6aba157326bc30bdb09a1b0599de9 /fs/udf/udfdecl.h
parent3d2d7e61553dbcc8ba45201d8ae4f383742c8202 (diff)
udf: New directory iteration code
Add new support code for iterating directory entries. The code is also more carefully verifying validity of on-disk directory entries to avoid crashes on malicious media. Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf/udfdecl.h')
-rw-r--r--fs/udf/udfdecl.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index 7e258f15b8ef..22a8466e335c 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -86,6 +86,24 @@ extern const struct address_space_operations udf_aops;
extern const struct address_space_operations udf_adinicb_aops;
extern const struct address_space_operations udf_symlink_aops;
+struct udf_fileident_iter {
+ struct inode *dir; /* Directory we are working with */
+ loff_t pos; /* Logical position in a dir */
+ struct buffer_head *bh[2]; /* Buffer containing 'pos' and possibly
+ * next buffer if entry straddles
+ * blocks */
+ struct kernel_lb_addr eloc; /* Start of extent containing 'pos' */
+ uint32_t elen; /* Length of extent containing 'pos' */
+ sector_t loffset; /* Block offset of 'pos' within above
+ * extent */
+ struct extent_position epos; /* Position after the above extent */
+ struct fileIdentDesc fi; /* Copied directory entry */
+ uint8_t *name; /* Pointer to entry name */
+ uint8_t namebuf[UDF_NAME_LEN_CS0]; /* Storage for entry name in case
+ * the name is split between two blocks
+ */
+};
+
struct udf_fileident_bh {
struct buffer_head *sbh;
struct buffer_head *ebh;
@@ -243,6 +261,11 @@ extern udf_pblk_t udf_new_block(struct super_block *sb, struct inode *inode,
uint16_t partition, uint32_t goal, int *err);
/* directory.c */
+int udf_fiiter_init(struct udf_fileident_iter *iter, struct inode *dir,
+ loff_t pos);
+int udf_fiiter_advance(struct udf_fileident_iter *iter);
+void udf_fiiter_release(struct udf_fileident_iter *iter);
+void udf_fiiter_write_fi(struct udf_fileident_iter *iter, uint8_t *impuse);
extern struct fileIdentDesc *udf_fileident_read(struct inode *, loff_t *,
struct udf_fileident_bh *,
struct fileIdentDesc *,