| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * attrib.h - Defines for attribute handling in NTFS Linux kernel driver. | 
|  | 3 | *	      Part of the Linux-NTFS project. | 
|  | 4 | * | 
| Anton Altaparmakov | 271849a | 2005-03-07 21:36:18 +0000 | [diff] [blame] | 5 | * Copyright (c) 2001-2005 Anton Altaparmakov | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * Copyright (c) 2002 Richard Russon | 
|  | 7 | * | 
|  | 8 | * This program/include file is free software; you can redistribute it and/or | 
|  | 9 | * modify it under the terms of the GNU General Public License as published | 
|  | 10 | * by the Free Software Foundation; either version 2 of the License, or | 
|  | 11 | * (at your option) any later version. | 
|  | 12 | * | 
|  | 13 | * This program/include file is distributed in the hope that it will be | 
|  | 14 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty | 
|  | 15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 16 | * GNU General Public License for more details. | 
|  | 17 | * | 
|  | 18 | * You should have received a copy of the GNU General Public License | 
|  | 19 | * along with this program (in the main directory of the Linux-NTFS | 
|  | 20 | * distribution in the file COPYING); if not, write to the Free Software | 
|  | 21 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
|  | 22 | */ | 
|  | 23 |  | 
|  | 24 | #ifndef _LINUX_NTFS_ATTRIB_H | 
|  | 25 | #define _LINUX_NTFS_ATTRIB_H | 
|  | 26 |  | 
|  | 27 | #include "endian.h" | 
|  | 28 | #include "types.h" | 
|  | 29 | #include "layout.h" | 
|  | 30 | #include "inode.h" | 
|  | 31 | #include "runlist.h" | 
|  | 32 | #include "volume.h" | 
|  | 33 |  | 
|  | 34 | /** | 
|  | 35 | * ntfs_attr_search_ctx - used in attribute search functions | 
|  | 36 | * @mrec:	buffer containing mft record to search | 
|  | 37 | * @attr:	attribute record in @mrec where to begin/continue search | 
|  | 38 | * @is_first:	if true ntfs_attr_lookup() begins search with @attr, else after | 
|  | 39 | * | 
|  | 40 | * Structure must be initialized to zero before the first call to one of the | 
|  | 41 | * attribute search functions. Initialize @mrec to point to the mft record to | 
|  | 42 | * search, and @attr to point to the first attribute within @mrec (not necessary | 
|  | 43 | * if calling the _first() functions), and set @is_first to TRUE (not necessary | 
|  | 44 | * if calling the _first() functions). | 
|  | 45 | * | 
|  | 46 | * If @is_first is TRUE, the search begins with @attr. If @is_first is FALSE, | 
|  | 47 | * the search begins after @attr. This is so that, after the first call to one | 
|  | 48 | * of the search attribute functions, we can call the function again, without | 
|  | 49 | * any modification of the search context, to automagically get the next | 
|  | 50 | * matching attribute. | 
|  | 51 | */ | 
|  | 52 | typedef struct { | 
|  | 53 | MFT_RECORD *mrec; | 
|  | 54 | ATTR_RECORD *attr; | 
|  | 55 | BOOL is_first; | 
|  | 56 | ntfs_inode *ntfs_ino; | 
|  | 57 | ATTR_LIST_ENTRY *al_entry; | 
|  | 58 | ntfs_inode *base_ntfs_ino; | 
|  | 59 | MFT_RECORD *base_mrec; | 
|  | 60 | ATTR_RECORD *base_attr; | 
|  | 61 | } ntfs_attr_search_ctx; | 
|  | 62 |  | 
| Anton Altaparmakov | fd9d636 | 2005-10-04 13:44:48 +0100 | [diff] [blame] | 63 | extern int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn, | 
|  | 64 | ntfs_attr_search_ctx *ctx); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | extern int ntfs_map_runlist(ntfs_inode *ni, VCN vcn); | 
|  | 66 |  | 
| Anton Altaparmakov | 271849a | 2005-03-07 21:36:18 +0000 | [diff] [blame] | 67 | extern LCN ntfs_attr_vcn_to_lcn_nolock(ntfs_inode *ni, const VCN vcn, | 
|  | 68 | const BOOL write_locked); | 
|  | 69 |  | 
| Anton Altaparmakov | c0c1cc0 | 2005-03-07 21:43:38 +0000 | [diff] [blame] | 70 | extern runlist_element *ntfs_attr_find_vcn_nolock(ntfs_inode *ni, | 
| Anton Altaparmakov | 69b41e3 | 2005-10-04 14:01:14 +0100 | [diff] [blame] | 71 | const VCN vcn, ntfs_attr_search_ctx *ctx); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 |  | 
|  | 73 | int ntfs_attr_lookup(const ATTR_TYPE type, const ntfschar *name, | 
|  | 74 | const u32 name_len, const IGNORE_CASE_BOOL ic, | 
|  | 75 | const VCN lowest_vcn, const u8 *val, const u32 val_len, | 
|  | 76 | ntfs_attr_search_ctx *ctx); | 
|  | 77 |  | 
|  | 78 | extern int load_attribute_list(ntfs_volume *vol, runlist *rl, u8 *al_start, | 
|  | 79 | const s64 size, const s64 initialized_size); | 
|  | 80 |  | 
|  | 81 | static inline s64 ntfs_attr_size(const ATTR_RECORD *a) | 
|  | 82 | { | 
|  | 83 | if (!a->non_resident) | 
|  | 84 | return (s64)le32_to_cpu(a->data.resident.value_length); | 
|  | 85 | return sle64_to_cpu(a->data.non_resident.data_size); | 
|  | 86 | } | 
|  | 87 |  | 
|  | 88 | extern void ntfs_attr_reinit_search_ctx(ntfs_attr_search_ctx *ctx); | 
|  | 89 | extern ntfs_attr_search_ctx *ntfs_attr_get_search_ctx(ntfs_inode *ni, | 
|  | 90 | MFT_RECORD *mrec); | 
|  | 91 | extern void ntfs_attr_put_search_ctx(ntfs_attr_search_ctx *ctx); | 
|  | 92 |  | 
| Anton Altaparmakov | 53d59aa | 2005-03-17 10:51:33 +0000 | [diff] [blame] | 93 | #ifdef NTFS_RW | 
|  | 94 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | extern int ntfs_attr_size_bounds_check(const ntfs_volume *vol, | 
|  | 96 | const ATTR_TYPE type, const s64 size); | 
|  | 97 | extern int ntfs_attr_can_be_non_resident(const ntfs_volume *vol, | 
|  | 98 | const ATTR_TYPE type); | 
|  | 99 | extern int ntfs_attr_can_be_resident(const ntfs_volume *vol, | 
|  | 100 | const ATTR_TYPE type); | 
|  | 101 |  | 
|  | 102 | extern int ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size); | 
| Anton Altaparmakov | 0aaccea | 2005-09-08 20:40:32 +0100 | [diff] [blame] | 103 | extern int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a, | 
|  | 104 | const u32 new_size); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 |  | 
| Anton Altaparmakov | 8925d4f | 2005-10-04 14:48:20 +0100 | [diff] [blame] | 106 | extern int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size); | 
| Anton Altaparmakov | 2bfb4ff | 2005-03-09 15:15:06 +0000 | [diff] [blame] | 107 |  | 
| Anton Altaparmakov | 2d86829 | 2005-10-04 15:18:56 +0100 | [diff] [blame] | 108 | extern s64 ntfs_attr_extend_allocation(ntfs_inode *ni, s64 new_alloc_size, | 
|  | 109 | const s64 new_data_size, const s64 data_start); | 
|  | 110 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | extern int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt, | 
|  | 112 | const u8 val); | 
|  | 113 |  | 
| Anton Altaparmakov | 53d59aa | 2005-03-17 10:51:33 +0000 | [diff] [blame] | 114 | #endif /* NTFS_RW */ | 
|  | 115 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | #endif /* _LINUX_NTFS_ATTRIB_H */ |