remove whitespace from end of lines
[reactos.git] / reactos / drivers / fs / ntfs / linux-ntfs / attrib.h
1 /*
2 * attrib.h - Defines for attribute handling in NTFS Linux kernel driver.
3 * Part of the Linux-NTFS project.
4 *
5 * Copyright (c) 2001-2003 Anton Altaparmakov
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 <linux/fs.h>
28
29 #include "endian.h"
30 #include "types.h"
31 #include "layout.h"
32
33 static inline void init_run_list(run_list *rl)
34 {
35 rl->rl = NULL;
36 init_rwsem(&rl->lock);
37 }
38
39 typedef enum {
40 LCN_HOLE = -1, /* Keep this as highest value or die! */
41 LCN_RL_NOT_MAPPED = -2,
42 LCN_ENOENT = -3,
43 LCN_EINVAL = -4,
44 } LCN_SPECIAL_VALUES;
45
46 /**
47 * attr_search_context - used in attribute search functions
48 * @mrec: buffer containing mft record to search
49 * @attr: attribute record in @mrec where to begin/continue search
50 * @is_first: if true lookup_attr() begins search with @attr, else after @attr
51 *
52 * Structure must be initialized to zero before the first call to one of the
53 * attribute search functions. Initialize @mrec to point to the mft record to
54 * search, and @attr to point to the first attribute within @mrec (not necessary
55 * if calling the _first() functions), and set @is_first to TRUE (not necessary
56 * if calling the _first() functions).
57 *
58 * If @is_first is TRUE, the search begins with @attr. If @is_first is FALSE,
59 * the search begins after @attr. This is so that, after the first call to one
60 * of the search attribute functions, we can call the function again, without
61 * any modification of the search context, to automagically get the next
62 * matching attribute.
63 */
64 typedef struct {
65 MFT_RECORD *mrec;
66 ATTR_RECORD *attr;
67 BOOL is_first;
68 ntfs_inode *ntfs_ino;
69 ATTR_LIST_ENTRY *al_entry;
70 ntfs_inode *base_ntfs_ino;
71 MFT_RECORD *base_mrec;
72 ATTR_RECORD *base_attr;
73 } attr_search_context;
74
75 extern run_list_element *decompress_mapping_pairs(const ntfs_volume *vol,
76 const ATTR_RECORD *attr, run_list_element *old_rl);
77
78 extern int map_run_list(ntfs_inode *ni, VCN vcn);
79
80 extern LCN vcn_to_lcn(const run_list_element *rl, const VCN vcn);
81
82 extern BOOL find_attr(const ATTR_TYPES type, const uchar_t *name,
83 const u32 name_len, const IGNORE_CASE_BOOL ic, const u8 *val,
84 const u32 val_len, attr_search_context *ctx);
85
86 BOOL lookup_attr(const ATTR_TYPES type, const uchar_t *name, const u32 name_len,
87 const IGNORE_CASE_BOOL ic, const VCN lowest_vcn, const u8 *val,
88 const u32 val_len, attr_search_context *ctx);
89
90 extern int load_attribute_list(ntfs_volume *vol, run_list *rl, u8 *al_start,
91 const s64 size, const s64 initialized_size);
92
93 static inline s64 attribute_value_length(const ATTR_RECORD *a)
94 {
95 if (!a->non_resident)
96 return (s64)le32_to_cpu(a->data.resident.value_length);
97 return sle64_to_cpu(a->data.non_resident.data_size);
98 }
99
100 extern void reinit_attr_search_ctx(attr_search_context *ctx);
101 extern attr_search_context *get_attr_search_ctx(ntfs_inode *ni,
102 MFT_RECORD *mrec);
103 extern void put_attr_search_ctx(attr_search_context *ctx);
104
105 #endif /* _LINUX_NTFS_ATTRIB_H */
106