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