Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * attrib.h - Defines for attribute handling in NTFS Linux kernel driver.
0004  *        Part of the Linux-NTFS project.
0005  *
0006  * Copyright (c) 2001-2005 Anton Altaparmakov
0007  * Copyright (c) 2002 Richard Russon
0008  */
0009 
0010 #ifndef _LINUX_NTFS_ATTRIB_H
0011 #define _LINUX_NTFS_ATTRIB_H
0012 
0013 #include "endian.h"
0014 #include "types.h"
0015 #include "layout.h"
0016 #include "inode.h"
0017 #include "runlist.h"
0018 #include "volume.h"
0019 
0020 /**
0021  * ntfs_attr_search_ctx - used in attribute search functions
0022  * @mrec:   buffer containing mft record to search
0023  * @attr:   attribute record in @mrec where to begin/continue search
0024  * @is_first:   if true ntfs_attr_lookup() begins search with @attr, else after
0025  *
0026  * Structure must be initialized to zero before the first call to one of the
0027  * attribute search functions. Initialize @mrec to point to the mft record to
0028  * search, and @attr to point to the first attribute within @mrec (not necessary
0029  * if calling the _first() functions), and set @is_first to 'true' (not necessary
0030  * if calling the _first() functions).
0031  *
0032  * If @is_first is 'true', the search begins with @attr. If @is_first is 'false',
0033  * the search begins after @attr. This is so that, after the first call to one
0034  * of the search attribute functions, we can call the function again, without
0035  * any modification of the search context, to automagically get the next
0036  * matching attribute.
0037  */
0038 typedef struct {
0039     MFT_RECORD *mrec;
0040     ATTR_RECORD *attr;
0041     bool is_first;
0042     ntfs_inode *ntfs_ino;
0043     ATTR_LIST_ENTRY *al_entry;
0044     ntfs_inode *base_ntfs_ino;
0045     MFT_RECORD *base_mrec;
0046     ATTR_RECORD *base_attr;
0047 } ntfs_attr_search_ctx;
0048 
0049 extern int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn,
0050         ntfs_attr_search_ctx *ctx);
0051 extern int ntfs_map_runlist(ntfs_inode *ni, VCN vcn);
0052 
0053 extern LCN ntfs_attr_vcn_to_lcn_nolock(ntfs_inode *ni, const VCN vcn,
0054         const bool write_locked);
0055 
0056 extern runlist_element *ntfs_attr_find_vcn_nolock(ntfs_inode *ni,
0057         const VCN vcn, ntfs_attr_search_ctx *ctx);
0058 
0059 int ntfs_attr_lookup(const ATTR_TYPE type, const ntfschar *name,
0060         const u32 name_len, const IGNORE_CASE_BOOL ic,
0061         const VCN lowest_vcn, const u8 *val, const u32 val_len,
0062         ntfs_attr_search_ctx *ctx);
0063 
0064 extern int load_attribute_list(ntfs_volume *vol, runlist *rl, u8 *al_start,
0065         const s64 size, const s64 initialized_size);
0066 
0067 static inline s64 ntfs_attr_size(const ATTR_RECORD *a)
0068 {
0069     if (!a->non_resident)
0070         return (s64)le32_to_cpu(a->data.resident.value_length);
0071     return sle64_to_cpu(a->data.non_resident.data_size);
0072 }
0073 
0074 extern void ntfs_attr_reinit_search_ctx(ntfs_attr_search_ctx *ctx);
0075 extern ntfs_attr_search_ctx *ntfs_attr_get_search_ctx(ntfs_inode *ni,
0076         MFT_RECORD *mrec);
0077 extern void ntfs_attr_put_search_ctx(ntfs_attr_search_ctx *ctx);
0078 
0079 #ifdef NTFS_RW
0080 
0081 extern int ntfs_attr_size_bounds_check(const ntfs_volume *vol,
0082         const ATTR_TYPE type, const s64 size);
0083 extern int ntfs_attr_can_be_non_resident(const ntfs_volume *vol,
0084         const ATTR_TYPE type);
0085 extern int ntfs_attr_can_be_resident(const ntfs_volume *vol,
0086         const ATTR_TYPE type);
0087 
0088 extern int ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size);
0089 extern int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a,
0090         const u32 new_size);
0091 
0092 extern int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size);
0093 
0094 extern s64 ntfs_attr_extend_allocation(ntfs_inode *ni, s64 new_alloc_size,
0095         const s64 new_data_size, const s64 data_start);
0096 
0097 extern int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt,
0098         const u8 val);
0099 
0100 #endif /* NTFS_RW */
0101 
0102 #endif /* _LINUX_NTFS_ATTRIB_H */