1N/A * attrib.h - Exports for attribute handling. Part of the Linux-NTFS project. 1N/A * Copyright (c) 2000-2004 Anton Altaparmakov 1N/A * Copyright (c) 2004-2007 Yura Pakhuchiy 1N/A * modify it under the terms of the GNU General Public License as published 1N/A * by the Free Software Foundation; either version 2 of the License, or 1N/A * (at your option) any later version. 1N/A * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 1N/A * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1N/A * GNU General Public License for more details. 1N/A * You should have received a copy of the GNU General Public License 1N/A * along with this program (in the main directory of the Linux-NTFS 1N/A * distribution in the file COPYING); if not, write to the Free Software 1N/A * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 1N/A/* Forward declarations */ 1N/A * enum ntfs_lcn_special_values - special return values for ntfs_*_vcn_to_lcn() 1N/A * Special return values for ntfs_rl_vcn_to_lcn() and ntfs_attr_vcn_to_lcn(). 1N/A * TODO: Describe them. 1N/A LCN_HOLE = -
1,
/* Keep this as highest value or die! */ 1N/A * struct ntfs_attr_search_ctx - search context used in attribute search functions 1N/A * @mrec: buffer containing mft record to search 1N/A * @is_first: if true lookup_attr() begins search with @attr, else after @attr 1N/A * Structure must be initialized to zero before the first call to one of the 1N/A * attribute search functions. Initialize @mrec to point to the mft record to 1N/A * search, and @attr to point to the first attribute within @mrec (not necessary 1N/A * if calling the _first() functions), and set @is_first to TRUE (not necessary 1N/A * if calling the _first() functions). 1N/A * If @is_first is TRUE, the search begins with @attr. If @is_first is FALSE, 1N/A * the search begins after @attr. This is so that, after the first call to one 1N/A * of the search attribute functions, we can call the function again, without 1N/A * any modification of the search context, to automagically get the next 1N/A * matching attribute. 1N/A * ntfs_attrs_walk - syntactic sugar for walking all attributes in an inode 1N/A * @ctx: initialised attribute search context 1N/A * Syntactic sugar for walking attributes in an inode. 1N/A * Return 0 on success and -1 on error with errno set to the error code from 1N/A * ntfs_attr_lookup(). 1N/A * Example: When you want to enumerate all attributes in an open ntfs inode 1N/A * @ni, you can simply do: 1N/A * ntfs_attr_search_ctx *ctx = ntfs_attr_get_search_ctx(ni, NULL); 1N/A * // Error code is in errno. Handle this case. 1N/A * while (!(err = ntfs_attrs_walk(ctx))) { 1N/A * ATTR_RECORD *attr = ctx->attr; 1N/A * // attr now contains the next attribute. Do whatever you want 1N/A * // with it and then just continue with the while loop. 1N/A * if (err && errno != ENOENT) 1N/A * // Ooops. An error occurred! You should handle this case. 1N/A * // Now finished with all attributes in the inode. 1N/A * struct ntfs_attr - ntfs in memory non-resident attribute structure 1N/A * @rl: if not NULL, the decompressed runlist 1N/A * @ni: base ntfs inode to which this attribute belongs 1N/A * @type: attribute type 1N/A * @name: Unicode name of the attribute 1N/A * @name_len: length of @name in Unicode characters 1N/A * @state: NTFS attribute specific flags describing this attribute 1N/A * @allocated_size: copy from the attribute record 1N/A * @data_size: copy from the attribute record 1N/A * @initialized_size: copy from the attribute record 1N/A * @compressed_size: copy from the attribute record 1N/A * @compression_block_size: size of a compression block (cb) 1N/A * @compression_block_size_bits: log2 of the size of a cb 1N/A * @compression_block_clusters: number of clusters per cb 1N/A * @crypto: (valid only for encrypted) see description below 1N/A * This structure exists purely to provide a mechanism of caching the runlist 1N/A * of an attribute. If you want to operate on a particular attribute extent, 1N/A * you should not be using this structure at all. If you want to work with a 1N/A * resident attribute, you should not be using this structure at all. As a 1N/A * fail-safe check make sure to test NAttrNonResident() and if it is false, you 1N/A * know you shouldn't be using this structure. 1N/A * If you want to work on a resident attribute or on a specific attribute 1N/A * extent, you should use ntfs_lookup_attr() to retrieve the attribute (extent) 1N/A * record, edit that, and then write back the mft record (or set the 1N/A * corresponding ntfs inode dirty for delayed write back). 1N/A * @rl is the decompressed runlist of the attribute described by this 1N/A * structure. Obviously this only makes sense if the attribute is not resident, 1N/A * i.e. NAttrNonResident() is true. If the runlist hasn't been decompressed yet 1N/A * @rl is NULL, so be prepared to cope with @rl == NULL. 1N/A * @ni is the base ntfs inode of the attribute described by this structure. 1N/A * @type is the attribute type (see layout.h for the definition of ATTR_TYPES), 1N/A * @name and @name_len are the little endian Unicode name and the name length 1N/A * in Unicode characters of the attribute, respectively. 1N/A * @state contains NTFS attribute specific flags describing this attribute 1N/A * structure. See ntfs_attr_state_bits above. 1N/A * @crypto points to private structure of crypto code. You should not access 1N/A * fields of this structure, but you can check whether it is NULL or not. If it 1N/A * is not NULL, then we successfully obtained FEK (File Encryption Key) and 1N/A * ntfs_attr_p{read,write} calls probably would succeed. If it is NULL, then we 1N/A * failed to obtain FEK (do not have corresponding PFX file, wrong password, 1N/A * etc..) or library was compiled without crypto support. Attribute size can be 1N/A * changed without knowledge of FEK, so you can use ntfs_attr_truncate in any 1N/A * NOTE: This field valid only if attribute encrypted (eg., NAttrEncrypted 1N/A * returns non-zero). 1N/A * enum ntfs_attr_state_bits - bits for the state field in the ntfs_attr 1N/A "unnamed data attribute.\n"); \
1N/A * union attr_val - Union of all known attribute values 1N/A * For convenience. Used in the attr structure. 1N/A a_val without specifying any of the below. */ 1N/A// FIXME / TODO: Above here the file is cleaned up. (AIA) 1N/A * get_attribute_value_length - return the length of the value of an attribute 1N/A * @a: pointer to a buffer containing the attribute record 1N/A * Return the byte size of the attribute value of the attribute @a (as it 1N/A * would be after eventual decompression and filling in of holes if sparse). 1N/A * If we return 0, check errno. If errno is 0 the actual length was 0, 1N/A * otherwise errno describes the error. 1N/A * FIXME: Describe possible errnos. 1N/A * get_attribute_value - return the attribute value of an attribute 1N/A * @vol: volume on which the attribute is present 1N/A * @a: attribute to get the value of 1N/A * @b: destination buffer for the attribute value 1N/A * Make a copy of the attribute value of the attribute @a into the destination 1N/A * buffer @b. Note, that the size of @b has to be at least equal to the value 1N/A * returned by get_attribute_value_length(@a). 1N/A * Return number of bytes copied. If this is zero check errno. If errno is 0 1N/A * then nothing was read due to a zero-length attribute value, otherwise 1N/A * errno describes the error. 1N/A#
endif /* defined _NTFS_ATTRIB_H */