]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - repair/dir.h
Update copyright/license notices to match SGI legal prefered boilerplate.
[thirdparty/xfsprogs-dev.git] / repair / dir.h
1 /*
2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #ifndef _XR_DIR_H
20 #define _XR_DIR_H
21
22 struct blkmap;
23
24 /* 1 bit per byte, max XFS blocksize == 64K bits / NBBY */
25 #define DA_BMAP_SIZE 8192
26
27 typedef unsigned char da_freemap_t;
28
29 /*
30 * the cursor gets passed up and down the da btree processing
31 * routines. The interior block processing routines use the
32 * cursor to determine if the pointers to and from the preceding
33 * and succeeding sibling blocks are ok and whether the values in
34 * the current block are consistent with the entries in the parent
35 * nodes. When a block is traversed, a parent-verification routine
36 * is called to verify if the next logical entry in the next level up
37 * is consistent with the greatest hashval in the next block of the
38 * current level. The verification routine is itself recursive and
39 * calls itself if it has to traverse an interior block to get
40 * the next logical entry. The routine recurses upwards through
41 * the tree until it finds a block where it can simply step to
42 * the next entry. The hashval in that entry should be equal to
43 * the hashval being passed to it (the greatest hashval in the block
44 * that the entry points to). If that isn't true, then the tree
45 * is blown and we need to trash it, salvage and trash it, or fix it.
46 * Currently, we just trash it.
47 */
48 typedef struct da_level_state {
49 xfs_buf_t *bp; /* block bp */
50 #ifdef XR_DIR_TRACE
51 xfs_da_intnode_t *n; /* bp data */
52 #endif
53 xfs_dablk_t bno; /* file block number */
54 xfs_dahash_t hashval; /* last verified hashval */
55 int index; /* current index in block */
56 int dirty; /* is buffer dirty ? (1 == yes) */
57 } da_level_state_t;
58
59 typedef struct da_bt_cursor {
60 int active; /* highest level in tree (# levels-1) */
61 int type; /* 0 if dir, 1 if attr */
62 xfs_ino_t ino;
63 xfs_dablk_t greatest_bno;
64 xfs_dinode_t *dip;
65 da_level_state_t level[XFS_DA_NODE_MAXDEPTH];
66 struct blkmap *blkmap;
67 } da_bt_cursor_t;
68
69
70 /* ROUTINES */
71
72 void
73 err_release_da_cursor(
74 xfs_mount_t *mp,
75 da_bt_cursor_t *cursor,
76 int prev_level);
77
78 xfs_dfsbno_t
79 get_first_dblock_fsbno(
80 xfs_mount_t *mp,
81 xfs_ino_t ino,
82 xfs_dinode_t *dino);
83
84 void
85 init_da_freemap(
86 da_freemap_t *dir_freemap);
87
88 int
89 namecheck(
90 char *name,
91 int length);
92
93 int
94 process_shortform_dir(
95 xfs_mount_t *mp,
96 xfs_ino_t ino,
97 xfs_dinode_t *dip,
98 int ino_discovery,
99 int *dino_dirty, /* is dinode buffer dirty? */
100 xfs_ino_t *parent, /* out - NULLFSINO if entry doesn't exist */
101 char *dirname, /* directory pathname */
102 int *repair); /* out - 1 if dir was fixed up */
103
104 int
105 process_dir(
106 xfs_mount_t *mp,
107 xfs_ino_t ino,
108 xfs_dinode_t *dip,
109 int ino_discovery,
110 int *dirty,
111 char *dirname,
112 xfs_ino_t *parent,
113 struct blkmap *blkmap);
114
115 void
116 release_da_cursor(
117 xfs_mount_t *mp,
118 da_bt_cursor_t *cursor,
119 int prev_level);
120
121 int
122 set_da_freemap(
123 xfs_mount_t *mp, da_freemap_t *map,
124 int start, int stop);
125
126 int
127 traverse_int_dablock(
128 xfs_mount_t *mp,
129 da_bt_cursor_t *da_cursor,
130 xfs_dablk_t *rbno,
131 int whichfork);
132
133 int
134 verify_da_path(
135 xfs_mount_t *mp,
136 da_bt_cursor_t *cursor,
137 const int p_level);
138
139 int
140 verify_final_da_path(
141 xfs_mount_t *mp,
142 da_bt_cursor_t *cursor,
143 const int p_level);
144
145
146 #endif /* _XR_DIR_H */