MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / fs / ntfs / attrib.h
blob92899f4ff571df2e84d899fa620d5c66a135b764
1 /*
2 * attrib.h - Defines for attribute handling in NTFS Linux kernel driver.
3 * Part of the Linux-NTFS project.
5 * Copyright (c) 2001-2004 Anton Altaparmakov
6 * Copyright (c) 2002 Richard Russon
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.
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.
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
24 #ifndef _LINUX_NTFS_ATTRIB_H
25 #define _LINUX_NTFS_ATTRIB_H
27 #include <linux/fs.h>
29 #include "endian.h"
30 #include "types.h"
31 #include "layout.h"
33 static inline void init_runlist(runlist *rl)
35 rl->rl = NULL;
36 init_rwsem(&rl->lock);
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_SPECIAL_VALUES;
45 /**
46 * ntfs_attr_search_ctx - used in attribute search functions
47 * @mrec: buffer containing mft record to search
48 * @attr: attribute record in @mrec where to begin/continue search
49 * @is_first: if true ntfs_attr_lookup() begins search with @attr, else after
51 * Structure must be initialized to zero before the first call to one of the
52 * attribute search functions. Initialize @mrec to point to the mft record to
53 * search, and @attr to point to the first attribute within @mrec (not necessary
54 * if calling the _first() functions), and set @is_first to TRUE (not necessary
55 * if calling the _first() functions).
57 * If @is_first is TRUE, the search begins with @attr. If @is_first is FALSE,
58 * the search begins after @attr. This is so that, after the first call to one
59 * of the search attribute functions, we can call the function again, without
60 * any modification of the search context, to automagically get the next
61 * matching attribute.
63 typedef struct {
64 MFT_RECORD *mrec;
65 ATTR_RECORD *attr;
66 BOOL is_first;
67 ntfs_inode *ntfs_ino;
68 ATTR_LIST_ENTRY *al_entry;
69 ntfs_inode *base_ntfs_ino;
70 MFT_RECORD *base_mrec;
71 ATTR_RECORD *base_attr;
72 } ntfs_attr_search_ctx;
74 extern runlist_element *decompress_mapping_pairs(const ntfs_volume *vol,
75 const ATTR_RECORD *attr, runlist_element *old_rl);
77 extern int ntfs_map_runlist(ntfs_inode *ni, VCN vcn);
79 extern LCN ntfs_vcn_to_lcn(const runlist_element *rl, const VCN vcn);
81 extern runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn,
82 const BOOL need_write);
84 int ntfs_attr_lookup(const ATTR_TYPE type, const ntfschar *name,
85 const u32 name_len, const IGNORE_CASE_BOOL ic,
86 const VCN lowest_vcn, const u8 *val, const u32 val_len,
87 ntfs_attr_search_ctx *ctx);
89 extern int load_attribute_list(ntfs_volume *vol, runlist *rl, u8 *al_start,
90 const s64 size, const s64 initialized_size);
92 static inline s64 ntfs_attr_size(const ATTR_RECORD *a)
94 if (!a->non_resident)
95 return (s64)le32_to_cpu(a->data.resident.value_length);
96 return sle64_to_cpu(a->data.non_resident.data_size);
99 extern void ntfs_attr_reinit_search_ctx(ntfs_attr_search_ctx *ctx);
100 extern ntfs_attr_search_ctx *ntfs_attr_get_search_ctx(ntfs_inode *ni,
101 MFT_RECORD *mrec);
102 extern void ntfs_attr_put_search_ctx(ntfs_attr_search_ctx *ctx);
104 #endif /* _LINUX_NTFS_ATTRIB_H */