Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * inode.h - Defines for inode structures NTFS Linux kernel driver. Part of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *	     the Linux-NTFS project.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (c) 2001-2007 Anton Altaparmakov
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Copyright (c) 2002 Richard Russon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #ifndef _LINUX_NTFS_INODE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define _LINUX_NTFS_INODE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/atomic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include "layout.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include "volume.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include "types.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include "runlist.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include "debug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) typedef struct _ntfs_inode ntfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * The NTFS in-memory inode structure. It is just used as an extension to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * fields already provided in the VFS inode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) struct _ntfs_inode {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	rwlock_t size_lock;	/* Lock serializing access to inode sizes. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	s64 initialized_size;	/* Copy from the attribute record. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	s64 allocated_size;	/* Copy from the attribute record. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	unsigned long state;	/* NTFS specific flags describing this inode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 				   See ntfs_inode_state_bits below. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	unsigned long mft_no;	/* Number of the mft record / inode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	u16 seq_no;		/* Sequence number of the mft record. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	atomic_t count;		/* Inode reference count for book keeping. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	ntfs_volume *vol;	/* Pointer to the ntfs volume of this inode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	 * If NInoAttr() is true, the below fields describe the attribute which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	 * this fake inode belongs to. The actual inode of this attribute is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	 * pointed to by base_ntfs_ino and nr_extents is always set to -1 (see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	 * below). For real inodes, we also set the type (AT_DATA for files and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	 * AT_INDEX_ALLOCATION for directories), with the name = NULL and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	 * name_len = 0 for files and name = I30 (global constant) and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	 * name_len = 4 for directories.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	ATTR_TYPE type;	/* Attribute type of this fake inode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	ntfschar *name;		/* Attribute name of this fake inode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	u32 name_len;		/* Attribute name length of this fake inode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	runlist runlist;	/* If state has the NI_NonResident bit set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 				   the runlist of the unnamed data attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 				   (if a file) or of the index allocation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 				   attribute (directory) or of the attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 				   described by the fake inode (if NInoAttr()).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 				   If runlist.rl is NULL, the runlist has not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 				   been read in yet or has been unmapped. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 				   NI_NonResident is clear, the attribute is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 				   resident (file and fake inode) or there is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 				   no $I30 index allocation attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 				   (small directory). In the latter case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 				   runlist.rl is always NULL.*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	 * The following fields are only valid for real inodes and extent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	 * inodes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	struct mutex mrec_lock;	/* Lock for serializing access to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 				   mft record belonging to this inode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	struct page *page;	/* The page containing the mft record of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 				   inode. This should only be touched by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 				   (un)map_mft_record*() functions. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	int page_ofs;		/* Offset into the page at which the mft record
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 				   begins. This should only be touched by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 				   (un)map_mft_record*() functions. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	 * Attribute list support (only for use by the attribute lookup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	 * functions). Setup during read_inode for all inodes with attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	 * lists. Only valid if NI_AttrList is set in state, and attr_list_rl is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	 * further only valid if NI_AttrListNonResident is set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	u32 attr_list_size;	/* Length of attribute list value in bytes. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	u8 *attr_list;		/* Attribute list value itself. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	runlist attr_list_rl;	/* Run list for the attribute list value. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		struct { /* It is a directory, $MFT, or an index inode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 			u32 block_size;		/* Size of an index block. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			u32 vcn_size;		/* Size of a vcn in this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 						   index. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			COLLATION_RULE collation_rule; /* The collation rule
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 						   for the index. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 			u8 block_size_bits; 	/* Log2 of the above. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 			u8 vcn_size_bits;	/* Log2 of the above. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		} index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		struct { /* It is a compressed/sparse file/attribute inode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			s64 size;		/* Copy of compressed_size from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 						   $DATA. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			u32 block_size;		/* Size of a compression block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 						   (cb). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 			u8 block_size_bits;	/* Log2 of the size of a cb. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 			u8 block_clusters;	/* Number of clusters per cb. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		} compressed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	} itype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	struct mutex extent_lock;	/* Lock for accessing/modifying the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 					   below . */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	s32 nr_extents;	/* For a base mft record, the number of attached extent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 			   inodes (0 if none), for extent records and for fake
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 			   inodes describing an attribute this is -1. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	union {		/* This union is only used if nr_extents != 0. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		ntfs_inode **extent_ntfs_inos;	/* For nr_extents > 0, array of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 						   the ntfs inodes of the extent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 						   mft records belonging to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 						   this base inode which have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 						   been loaded. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		ntfs_inode *base_ntfs_ino;	/* For nr_extents == -1, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 						   ntfs inode of the base mft
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 						   record. For fake inodes, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 						   real (base) inode to which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 						   the attribute belongs. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	} ext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  * Defined bits for the state field in the ntfs_inode structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * (f) = files only, (d) = directories only, (a) = attributes/fake inodes only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) typedef enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	NI_Dirty,		/* 1: Mft record needs to be written to disk. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	NI_AttrList,		/* 1: Mft record contains an attribute list. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	NI_AttrListNonResident,	/* 1: Attribute list is non-resident. Implies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 				      NI_AttrList is set. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	NI_Attr,		/* 1: Fake inode for attribute i/o.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 				   0: Real inode or extent inode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	NI_MstProtected,	/* 1: Attribute is protected by MST fixups.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 				   0: Attribute is not protected by fixups. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	NI_NonResident,		/* 1: Unnamed data attr is non-resident (f).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 				   1: Attribute is non-resident (a). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	NI_IndexAllocPresent = NI_NonResident,	/* 1: $I30 index alloc attr is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 						   present (d). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	NI_Compressed,		/* 1: Unnamed data attr is compressed (f).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 				   1: Create compressed files by default (d).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 				   1: Attribute is compressed (a). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	NI_Encrypted,		/* 1: Unnamed data attr is encrypted (f).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 				   1: Create encrypted files by default (d).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 				   1: Attribute is encrypted (a). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	NI_Sparse,		/* 1: Unnamed data attr is sparse (f).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 				   1: Create sparse files by default (d).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 				   1: Attribute is sparse (a). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	NI_SparseDisabled,	/* 1: May not create sparse regions. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	NI_TruncateFailed,	/* 1: Last ntfs_truncate() call failed. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) } ntfs_inode_state_bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  * NOTE: We should be adding dirty mft records to a list somewhere and they
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  * should be independent of the (ntfs/vfs) inode structure so that an inode can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  * be removed but the record can be left dirty for syncing later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)  * Macro tricks to expand the NInoFoo(), NInoSetFoo(), and NInoClearFoo()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)  * functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) #define NINO_FNS(flag)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) static inline int NIno##flag(ntfs_inode *ni)		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) {							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	return test_bit(NI_##flag, &(ni)->state);	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) }							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) static inline void NInoSet##flag(ntfs_inode *ni)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) {							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	set_bit(NI_##flag, &(ni)->state);		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) }							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) static inline void NInoClear##flag(ntfs_inode *ni)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) {							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	clear_bit(NI_##flag, &(ni)->state);		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  * As above for NInoTestSetFoo() and NInoTestClearFoo().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) #define TAS_NINO_FNS(flag)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) static inline int NInoTestSet##flag(ntfs_inode *ni)		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	return test_and_set_bit(NI_##flag, &(ni)->state);	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) static inline int NInoTestClear##flag(ntfs_inode *ni)		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) {								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	return test_and_clear_bit(NI_##flag, &(ni)->state);	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) /* Emit the ntfs inode bitops functions. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) NINO_FNS(Dirty)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) TAS_NINO_FNS(Dirty)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) NINO_FNS(AttrList)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) NINO_FNS(AttrListNonResident)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) NINO_FNS(Attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) NINO_FNS(MstProtected)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) NINO_FNS(NonResident)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) NINO_FNS(IndexAllocPresent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) NINO_FNS(Compressed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) NINO_FNS(Encrypted)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) NINO_FNS(Sparse)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) NINO_FNS(SparseDisabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) NINO_FNS(TruncateFailed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)  * The full structure containing a ntfs_inode and a vfs struct inode. Used for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)  * all real and fake inodes but not for extent inodes which lack the vfs struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  * inode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	ntfs_inode ntfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	struct inode vfs_inode;		/* The vfs inode structure. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) } big_ntfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)  * NTFS_I - return the ntfs inode given a vfs inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)  * @inode:	VFS inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)  * NTFS_I() returns the ntfs inode associated with the VFS @inode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) static inline ntfs_inode *NTFS_I(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	return (ntfs_inode *)container_of(inode, big_ntfs_inode, vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) static inline struct inode *VFS_I(ntfs_inode *ni)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	return &((big_ntfs_inode *)ni)->vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)  * ntfs_attr - ntfs in memory attribute structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)  * @mft_no:	mft record number of the base mft record of this attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)  * @name:	Unicode name of the attribute (NULL if unnamed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)  * @name_len:	length of @name in Unicode characters (0 if unnamed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)  * @type:	attribute type (see layout.h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)  * This structure exists only to provide a small structure for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)  * ntfs_{attr_}iget()/ntfs_test_inode()/ntfs_init_locked_inode() mechanism.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)  * NOTE: Elements are ordered by size to make the structure as compact as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)  * possible on all architectures.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	unsigned long mft_no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	ntfschar *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	u32 name_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	ATTR_TYPE type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) } ntfs_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) extern int ntfs_test_inode(struct inode *vi, void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) extern struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) extern struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPE type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		ntfschar *name, u32 name_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) extern struct inode *ntfs_index_iget(struct inode *base_vi, ntfschar *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		u32 name_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) extern struct inode *ntfs_alloc_big_inode(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) extern void ntfs_free_big_inode(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) extern void ntfs_evict_big_inode(struct inode *vi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) extern void __ntfs_init_inode(struct super_block *sb, ntfs_inode *ni);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) static inline void ntfs_init_big_inode(struct inode *vi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	ntfs_inode *ni = NTFS_I(vi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	ntfs_debug("Entering.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	__ntfs_init_inode(vi->i_sb, ni);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	ni->mft_no = vi->i_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) extern ntfs_inode *ntfs_new_extent_inode(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 		unsigned long mft_no);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) extern void ntfs_clear_extent_inode(ntfs_inode *ni);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) extern int ntfs_read_inode_mount(struct inode *vi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) extern int ntfs_show_options(struct seq_file *sf, struct dentry *root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) #ifdef NTFS_RW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) extern int ntfs_truncate(struct inode *vi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) extern void ntfs_truncate_vfs(struct inode *vi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) extern int ntfs_setattr(struct dentry *dentry, struct iattr *attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) extern int __ntfs_write_inode(struct inode *vi, int sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) static inline void ntfs_commit_inode(struct inode *vi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	if (!is_bad_inode(vi))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		__ntfs_write_inode(vi, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) static inline void ntfs_truncate_vfs(struct inode *vi) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) #endif /* NTFS_RW */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) #endif /* _LINUX_NTFS_INODE_H */