struct direct -> struct lfs_direct struct dirtemplate -> struct lfs_dirtemplate struct odirtemplate -> struct lfs_odirtemplate DT_* -> LFS_DT_*diff -r1.28 -r1.29 src/sbin/fsck_lfs/dir.c
(dholland)
--- src/sbin/fsck_lfs/dir.c 2013/06/08 02:11:11 1.28
+++ src/sbin/fsck_lfs/dir.c 2013/06/08 02:12:56 1.29
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dir.c,v 1.28 2013/06/08 02:11:11 dholland Exp $ */ | 1 | /* $NetBSD: dir.c,v 1.29 2013/06/08 02:12:56 dholland Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1980, 1986, 1993 | 4 | * Copyright (c) 1980, 1986, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -45,56 +45,56 @@ | @@ -45,56 +45,56 @@ | |||
45 | #include <stdlib.h> | 45 | #include <stdlib.h> | |
46 | #include <string.h> | 46 | #include <string.h> | |
47 | 47 | |||
48 | #include "bufcache.h" | 48 | #include "bufcache.h" | |
49 | #include "vnode.h" | 49 | #include "vnode.h" | |
50 | #include "lfs_user.h" | 50 | #include "lfs_user.h" | |
51 | 51 | |||
52 | #include "fsck.h" | 52 | #include "fsck.h" | |
53 | #include "fsutil.h" | 53 | #include "fsutil.h" | |
54 | #include "extern.h" | 54 | #include "extern.h" | |
55 | 55 | |||
56 | const char *lfname = "lost+found"; | 56 | const char *lfname = "lost+found"; | |
57 | int lfmode = 01700; | 57 | int lfmode = 01700; | |
58 | struct dirtemplate emptydir = { | 58 | struct lfs_dirtemplate emptydir = { | |
59 | .dot_ino = 0, | 59 | .dot_ino = 0, | |
60 | .dot_reclen = DIRBLKSIZ, | 60 | .dot_reclen = DIRBLKSIZ, | |
61 | }; | 61 | }; | |
62 | struct dirtemplate dirhead = { | 62 | struct lfs_dirtemplate dirhead = { | |
63 | .dot_ino = 0, | 63 | .dot_ino = 0, | |
64 | .dot_reclen = 12, | 64 | .dot_reclen = 12, | |
65 | .dot_type = DT_DIR, | 65 | .dot_type = LFS_DT_DIR, | |
66 | .dot_namlen = 1, | 66 | .dot_namlen = 1, | |
67 | .dot_name = ".", | 67 | .dot_name = ".", | |
68 | .dotdot_ino = 0, | 68 | .dotdot_ino = 0, | |
69 | .dotdot_reclen = DIRBLKSIZ - 12, | 69 | .dotdot_reclen = DIRBLKSIZ - 12, | |
70 | .dotdot_type = DT_DIR, | 70 | .dotdot_type = LFS_DT_DIR, | |
71 | .dotdot_namlen = 2, | 71 | .dotdot_namlen = 2, | |
72 | .dotdot_name = ".." | 72 | .dotdot_name = ".." | |
73 | }; | 73 | }; | |
74 | struct odirtemplate odirhead = { | 74 | struct lfs_odirtemplate odirhead = { | |
75 | .dot_ino = 0, | 75 | .dot_ino = 0, | |
76 | .dot_reclen = 12, | 76 | .dot_reclen = 12, | |
77 | .dot_namlen = 1, | 77 | .dot_namlen = 1, | |
78 | .dot_name = ".", | 78 | .dot_name = ".", | |
79 | .dotdot_ino = 0, | 79 | .dotdot_ino = 0, | |
80 | .dotdot_reclen = DIRBLKSIZ - 12, | 80 | .dotdot_reclen = DIRBLKSIZ - 12, | |
81 | .dotdot_namlen = 2, | 81 | .dotdot_namlen = 2, | |
82 | .dotdot_name = ".." | 82 | .dotdot_name = ".." | |
83 | }; | 83 | }; | |
84 | 84 | |||
85 | static int expanddir(struct uvnode *, struct ulfs1_dinode *, char *); | 85 | static int expanddir(struct uvnode *, struct ulfs1_dinode *, char *); | |
86 | static void freedir(ino_t, ino_t); | 86 | static void freedir(ino_t, ino_t); | |
87 | static struct direct *fsck_readdir(struct uvnode *, struct inodesc *); | 87 | static struct lfs_direct *fsck_readdir(struct uvnode *, struct inodesc *); | |
88 | static int lftempname(char *, ino_t); | 88 | static int lftempname(char *, ino_t); | |
89 | static int mkentry(struct inodesc *); | 89 | static int mkentry(struct inodesc *); | |
90 | static int chgino(struct inodesc *); | 90 | static int chgino(struct inodesc *); | |
91 | 91 | |||
92 | /* | 92 | /* | |
93 | * Propagate connected state through the tree. | 93 | * Propagate connected state through the tree. | |
94 | */ | 94 | */ | |
95 | void | 95 | void | |
96 | propagate(void) | 96 | propagate(void) | |
97 | { | 97 | { | |
98 | struct inoinfo **inpp, *inp, *pinp; | 98 | struct inoinfo **inpp, *inp, *pinp; | |
99 | struct inoinfo **inpend; | 99 | struct inoinfo **inpend; | |
100 | 100 | |||
@@ -121,142 +121,142 @@ propagate(void) | @@ -121,142 +121,142 @@ propagate(void) | |||
121 | else if (inp->i_sibling) | 121 | else if (inp->i_sibling) | |
122 | inp = inp->i_sibling; | 122 | inp = inp->i_sibling; | |
123 | else | 123 | else | |
124 | inp = inp->i_parentp; | 124 | inp = inp->i_parentp; | |
125 | } | 125 | } | |
126 | } | 126 | } | |
127 | 127 | |||
128 | /* | 128 | /* | |
129 | * Scan each entry in a directory block. | 129 | * Scan each entry in a directory block. | |
130 | */ | 130 | */ | |
131 | int | 131 | int | |
132 | dirscan(struct inodesc *idesc) | 132 | dirscan(struct inodesc *idesc) | |
133 | { | 133 | { | |
134 | struct direct *dp; | 134 | struct lfs_direct *dp; | |
135 | struct ubuf *bp; | 135 | struct ubuf *bp; | |
136 | int dsize, n; | 136 | int dsize, n; | |
137 | long blksiz; | 137 | long blksiz; | |
138 | char dbuf[DIRBLKSIZ]; | 138 | char dbuf[DIRBLKSIZ]; | |
139 | struct uvnode *vp; | 139 | struct uvnode *vp; | |
140 | 140 | |||
141 | if (idesc->id_type != DATA) | 141 | if (idesc->id_type != DATA) | |
142 | errexit("wrong type to dirscan %d", idesc->id_type); | 142 | errexit("wrong type to dirscan %d", idesc->id_type); | |
143 | if (idesc->id_entryno == 0 && | 143 | if (idesc->id_entryno == 0 && | |
144 | (idesc->id_filesize & (DIRBLKSIZ - 1)) != 0) | 144 | (idesc->id_filesize & (DIRBLKSIZ - 1)) != 0) | |
145 | idesc->id_filesize = roundup(idesc->id_filesize, DIRBLKSIZ); | 145 | idesc->id_filesize = roundup(idesc->id_filesize, DIRBLKSIZ); | |
146 | blksiz = idesc->id_numfrags * fs->lfs_fsize; | 146 | blksiz = idesc->id_numfrags * fs->lfs_fsize; | |
147 | if (chkrange(idesc->id_blkno, idesc->id_numfrags)) { | 147 | if (chkrange(idesc->id_blkno, idesc->id_numfrags)) { | |
148 | idesc->id_filesize -= blksiz; | 148 | idesc->id_filesize -= blksiz; | |
149 | return (SKIP); | 149 | return (SKIP); | |
150 | } | 150 | } | |
151 | idesc->id_loc = 0; | 151 | idesc->id_loc = 0; | |
152 | 152 | |||
153 | vp = vget(fs, idesc->id_number); | 153 | vp = vget(fs, idesc->id_number); | |
154 | for (dp = fsck_readdir(vp, idesc); dp != NULL; | 154 | for (dp = fsck_readdir(vp, idesc); dp != NULL; | |
155 | dp = fsck_readdir(vp, idesc)) { | 155 | dp = fsck_readdir(vp, idesc)) { | |
156 | dsize = dp->d_reclen; | 156 | dsize = dp->d_reclen; | |
157 | memcpy(dbuf, dp, (size_t) dsize); | 157 | memcpy(dbuf, dp, (size_t) dsize); | |
158 | idesc->id_dirp = (struct direct *) dbuf; | 158 | idesc->id_dirp = (struct lfs_direct *) dbuf; | |
159 | if ((n = (*idesc->id_func) (idesc)) & ALTERED) { | 159 | if ((n = (*idesc->id_func) (idesc)) & ALTERED) { | |
160 | bread(vp, idesc->id_lblkno, blksiz, NOCRED, 0, &bp); | 160 | bread(vp, idesc->id_lblkno, blksiz, NOCRED, 0, &bp); | |
161 | memcpy(bp->b_data + idesc->id_loc - dsize, dbuf, | 161 | memcpy(bp->b_data + idesc->id_loc - dsize, dbuf, | |
162 | (size_t) dsize); | 162 | (size_t) dsize); | |
163 | VOP_BWRITE(bp); | 163 | VOP_BWRITE(bp); | |
164 | sbdirty(); | 164 | sbdirty(); | |
165 | } | 165 | } | |
166 | if (n & STOP) | 166 | if (n & STOP) | |
167 | return (n); | 167 | return (n); | |
168 | } | 168 | } | |
169 | return (idesc->id_filesize > 0 ? KEEPON : STOP); | 169 | return (idesc->id_filesize > 0 ? KEEPON : STOP); | |
170 | } | 170 | } | |
171 | 171 | |||
172 | /* | 172 | /* | |
173 | * get next entry in a directory. | 173 | * get next entry in a directory. | |
174 | */ | 174 | */ | |
175 | static struct direct * | 175 | static struct lfs_direct * | |
176 | fsck_readdir(struct uvnode *vp, struct inodesc *idesc) | 176 | fsck_readdir(struct uvnode *vp, struct inodesc *idesc) | |
177 | { | 177 | { | |
178 | struct direct *dp, *ndp; | 178 | struct lfs_direct *dp, *ndp; | |
179 | struct ubuf *bp; | 179 | struct ubuf *bp; | |
180 | long size, blksiz, fix, dploc; | 180 | long size, blksiz, fix, dploc; | |
181 | 181 | |||
182 | blksiz = idesc->id_numfrags * fs->lfs_fsize; | 182 | blksiz = idesc->id_numfrags * fs->lfs_fsize; | |
183 | bread(vp, idesc->id_lblkno, blksiz, NOCRED, 0, &bp); | 183 | bread(vp, idesc->id_lblkno, blksiz, NOCRED, 0, &bp); | |
184 | if (idesc->id_loc % DIRBLKSIZ == 0 && idesc->id_filesize > 0 && | 184 | if (idesc->id_loc % DIRBLKSIZ == 0 && idesc->id_filesize > 0 && | |
185 | idesc->id_loc < blksiz) { | 185 | idesc->id_loc < blksiz) { | |
186 | dp = (struct direct *) (bp->b_data + idesc->id_loc); | 186 | dp = (struct lfs_direct *) (bp->b_data + idesc->id_loc); | |
187 | if (dircheck(idesc, dp)) | 187 | if (dircheck(idesc, dp)) | |
188 | goto dpok; | 188 | goto dpok; | |
189 | brelse(bp, 0); | 189 | brelse(bp, 0); | |
190 | if (idesc->id_fix == IGNORE) | 190 | if (idesc->id_fix == IGNORE) | |
191 | return (0); | 191 | return (0); | |
192 | fix = dofix(idesc, "DIRECTORY CORRUPTED"); | 192 | fix = dofix(idesc, "DIRECTORY CORRUPTED"); | |
193 | bread(vp, idesc->id_lblkno, blksiz, NOCRED, 0, &bp); | 193 | bread(vp, idesc->id_lblkno, blksiz, NOCRED, 0, &bp); | |
194 | dp = (struct direct *) (bp->b_data + idesc->id_loc); | 194 | dp = (struct lfs_direct *) (bp->b_data + idesc->id_loc); | |
195 | dp->d_reclen = DIRBLKSIZ; | 195 | dp->d_reclen = DIRBLKSIZ; | |
196 | dp->d_ino = 0; | 196 | dp->d_ino = 0; | |
197 | dp->d_type = 0; | 197 | dp->d_type = 0; | |
198 | dp->d_namlen = 0; | 198 | dp->d_namlen = 0; | |
199 | dp->d_name[0] = '\0'; | 199 | dp->d_name[0] = '\0'; | |
200 | if (fix) | 200 | if (fix) | |
201 | VOP_BWRITE(bp); | 201 | VOP_BWRITE(bp); | |
202 | else | 202 | else | |
203 | brelse(bp, 0); | 203 | brelse(bp, 0); | |
204 | idesc->id_loc += DIRBLKSIZ; | 204 | idesc->id_loc += DIRBLKSIZ; | |
205 | idesc->id_filesize -= DIRBLKSIZ; | 205 | idesc->id_filesize -= DIRBLKSIZ; | |
206 | return (dp); | 206 | return (dp); | |
207 | } | 207 | } | |
208 | dpok: | 208 | dpok: | |
209 | if (idesc->id_filesize <= 0 || idesc->id_loc >= blksiz) { | 209 | if (idesc->id_filesize <= 0 || idesc->id_loc >= blksiz) { | |
210 | brelse(bp, 0); | 210 | brelse(bp, 0); | |
211 | return NULL; | 211 | return NULL; | |
212 | } | 212 | } | |
213 | dploc = idesc->id_loc; | 213 | dploc = idesc->id_loc; | |
214 | dp = (struct direct *) (bp->b_data + dploc); | 214 | dp = (struct lfs_direct *) (bp->b_data + dploc); | |
215 | idesc->id_loc += dp->d_reclen; | 215 | idesc->id_loc += dp->d_reclen; | |
216 | idesc->id_filesize -= dp->d_reclen; | 216 | idesc->id_filesize -= dp->d_reclen; | |
217 | if ((idesc->id_loc % DIRBLKSIZ) == 0) { | 217 | if ((idesc->id_loc % DIRBLKSIZ) == 0) { | |
218 | brelse(bp, 0); | 218 | brelse(bp, 0); | |
219 | return dp; | 219 | return dp; | |
220 | } | 220 | } | |
221 | ndp = (struct direct *) (bp->b_data + idesc->id_loc); | 221 | ndp = (struct lfs_direct *) (bp->b_data + idesc->id_loc); | |
222 | if (idesc->id_loc < blksiz && idesc->id_filesize > 0 && | 222 | if (idesc->id_loc < blksiz && idesc->id_filesize > 0 && | |
223 | dircheck(idesc, ndp) == 0) { | 223 | dircheck(idesc, ndp) == 0) { | |
224 | brelse(bp, 0); | 224 | brelse(bp, 0); | |
225 | size = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ); | 225 | size = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ); | |
226 | idesc->id_loc += size; | 226 | idesc->id_loc += size; | |
227 | idesc->id_filesize -= size; | 227 | idesc->id_filesize -= size; | |
228 | if (idesc->id_fix == IGNORE) | 228 | if (idesc->id_fix == IGNORE) | |
229 | return 0; | 229 | return 0; | |
230 | fix = dofix(idesc, "DIRECTORY CORRUPTED"); | 230 | fix = dofix(idesc, "DIRECTORY CORRUPTED"); | |
231 | bread(vp, idesc->id_lblkno, blksiz, NOCRED, 0, &bp); | 231 | bread(vp, idesc->id_lblkno, blksiz, NOCRED, 0, &bp); | |
232 | dp = (struct direct *) (bp->b_data + dploc); | 232 | dp = (struct lfs_direct *) (bp->b_data + dploc); | |
233 | dp->d_reclen += size; | 233 | dp->d_reclen += size; | |
234 | if (fix) | 234 | if (fix) | |
235 | VOP_BWRITE(bp); | 235 | VOP_BWRITE(bp); | |
236 | else | 236 | else | |
237 | brelse(bp, 0); | 237 | brelse(bp, 0); | |
238 | } else | 238 | } else | |
239 | brelse(bp, 0); | 239 | brelse(bp, 0); | |
240 | 240 | |||
241 | return (dp); | 241 | return (dp); | |
242 | } | 242 | } | |
243 | 243 | |||
244 | /* | 244 | /* | |
245 | * Verify that a directory entry is valid. | 245 | * Verify that a directory entry is valid. | |
246 | * This is a superset of the checks made in the kernel. | 246 | * This is a superset of the checks made in the kernel. | |
247 | */ | 247 | */ | |
248 | int | 248 | int | |
249 | dircheck(struct inodesc *idesc, struct direct *dp) | 249 | dircheck(struct inodesc *idesc, struct lfs_direct *dp) | |
250 | { | 250 | { | |
251 | int size; | 251 | int size; | |
252 | char *cp; | 252 | char *cp; | |
253 | u_char namlen, type; | 253 | u_char namlen, type; | |
254 | int spaceleft; | 254 | int spaceleft; | |
255 | 255 | |||
256 | spaceleft = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ); | 256 | spaceleft = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ); | |
257 | if (dp->d_ino >= maxino || | 257 | if (dp->d_ino >= maxino || | |
258 | dp->d_reclen == 0 || | 258 | dp->d_reclen == 0 || | |
259 | dp->d_reclen > spaceleft || | 259 | dp->d_reclen > spaceleft || | |
260 | (dp->d_reclen & 0x3) != 0) { | 260 | (dp->d_reclen & 0x3) != 0) { | |
261 | pwarn("ino too large, reclen=0, reclen>space, or reclen&3!=0\n"); | 261 | pwarn("ino too large, reclen=0, reclen>space, or reclen&3!=0\n"); | |
262 | pwarn("dp->d_ino = 0x%x\tdp->d_reclen = 0x%x\n", | 262 | pwarn("dp->d_ino = 0x%x\tdp->d_reclen = 0x%x\n", | |
@@ -348,53 +348,53 @@ adjust(struct inodesc *idesc, short lcnt | @@ -348,53 +348,53 @@ adjust(struct inodesc *idesc, short lcnt | |||
348 | } | 348 | } | |
349 | printf(" (ADJUSTED)\n"); | 349 | printf(" (ADJUSTED)\n"); | |
350 | } | 350 | } | |
351 | if (preen || reply("ADJUST") == 1) { | 351 | if (preen || reply("ADJUST") == 1) { | |
352 | dp->di_nlink -= lcnt; | 352 | dp->di_nlink -= lcnt; | |
353 | inodirty(VTOI(vp)); | 353 | inodirty(VTOI(vp)); | |
354 | } | 354 | } | |
355 | } | 355 | } | |
356 | } | 356 | } | |
357 | 357 | |||
358 | static int | 358 | static int | |
359 | mkentry(struct inodesc *idesc) | 359 | mkentry(struct inodesc *idesc) | |
360 | { | 360 | { | |
361 | struct direct *dirp = idesc->id_dirp; | 361 | struct lfs_direct *dirp = idesc->id_dirp; | |
362 | struct direct newent; | 362 | struct lfs_direct newent; | |
363 | int newlen, oldlen; | 363 | int newlen, oldlen; | |
364 | 364 | |||
365 | newent.d_namlen = strlen(idesc->id_name); | 365 | newent.d_namlen = strlen(idesc->id_name); | |
366 | newlen = DIRSIZ(0, &newent, 0); | 366 | newlen = DIRSIZ(0, &newent, 0); | |
367 | if (dirp->d_ino != 0) | 367 | if (dirp->d_ino != 0) | |
368 | oldlen = DIRSIZ(0, dirp, 0); | 368 | oldlen = DIRSIZ(0, dirp, 0); | |
369 | else | 369 | else | |
370 | oldlen = 0; | 370 | oldlen = 0; | |
371 | if (dirp->d_reclen - oldlen < newlen) | 371 | if (dirp->d_reclen - oldlen < newlen) | |
372 | return (KEEPON); | 372 | return (KEEPON); | |
373 | newent.d_reclen = dirp->d_reclen - oldlen; | 373 | newent.d_reclen = dirp->d_reclen - oldlen; | |
374 | dirp->d_reclen = oldlen; | 374 | dirp->d_reclen = oldlen; | |
375 | dirp = (struct direct *) (((char *) dirp) + oldlen); | 375 | dirp = (struct lfs_direct *) (((char *) dirp) + oldlen); | |
376 | dirp->d_ino = idesc->id_parent; /* ino to be entered is in id_parent */ | 376 | dirp->d_ino = idesc->id_parent; /* ino to be entered is in id_parent */ | |
377 | dirp->d_reclen = newent.d_reclen; | 377 | dirp->d_reclen = newent.d_reclen; | |
378 | dirp->d_type = typemap[idesc->id_parent]; | 378 | dirp->d_type = typemap[idesc->id_parent]; | |
379 | dirp->d_namlen = newent.d_namlen; | 379 | dirp->d_namlen = newent.d_namlen; | |
380 | memcpy(dirp->d_name, idesc->id_name, (size_t) dirp->d_namlen + 1); | 380 | memcpy(dirp->d_name, idesc->id_name, (size_t) dirp->d_namlen + 1); | |
381 | return (ALTERED | STOP); | 381 | return (ALTERED | STOP); | |
382 | } | 382 | } | |
383 | 383 | |||
384 | static int | 384 | static int | |
385 | chgino(struct inodesc *idesc) | 385 | chgino(struct inodesc *idesc) | |
386 | { | 386 | { | |
387 | struct direct *dirp = idesc->id_dirp; | 387 | struct lfs_direct *dirp = idesc->id_dirp; | |
388 | 388 | |||
389 | if (memcmp(dirp->d_name, idesc->id_name, (int) dirp->d_namlen + 1)) | 389 | if (memcmp(dirp->d_name, idesc->id_name, (int) dirp->d_namlen + 1)) | |
390 | return (KEEPON); | 390 | return (KEEPON); | |
391 | dirp->d_ino = idesc->id_parent; | 391 | dirp->d_ino = idesc->id_parent; | |
392 | dirp->d_type = typemap[idesc->id_parent]; | 392 | dirp->d_type = typemap[idesc->id_parent]; | |
393 | return (ALTERED | STOP); | 393 | return (ALTERED | STOP); | |
394 | } | 394 | } | |
395 | 395 | |||
396 | int | 396 | int | |
397 | linkup(ino_t orphan, ino_t parentdir) | 397 | linkup(ino_t orphan, ino_t parentdir) | |
398 | { | 398 | { | |
399 | struct ulfs1_dinode *dp; | 399 | struct ulfs1_dinode *dp; | |
400 | int lostdir; | 400 | int lostdir; | |
@@ -609,42 +609,42 @@ bad: | @@ -609,42 +609,42 @@ bad: | |||
609 | return (0); | 609 | return (0); | |
610 | } | 610 | } | |
611 | 611 | |||
612 | /* | 612 | /* | |
613 | * allocate a new directory | 613 | * allocate a new directory | |
614 | */ | 614 | */ | |
615 | int | 615 | int | |
616 | allocdir(ino_t parent, ino_t request, int mode) | 616 | allocdir(ino_t parent, ino_t request, int mode) | |
617 | { | 617 | { | |
618 | ino_t ino; | 618 | ino_t ino; | |
619 | char *cp; | 619 | char *cp; | |
620 | struct ulfs1_dinode *dp; | 620 | struct ulfs1_dinode *dp; | |
621 | struct ubuf *bp; | 621 | struct ubuf *bp; | |
622 | struct dirtemplate *dirp; | 622 | struct lfs_dirtemplate *dirp; | |
623 | struct uvnode *vp; | 623 | struct uvnode *vp; | |
624 | 624 | |||
625 | ino = allocino(request, LFS_IFDIR | mode); | 625 | ino = allocino(request, LFS_IFDIR | mode); | |
626 | dirp = &dirhead; | 626 | dirp = &dirhead; | |
627 | dirp->dot_ino = ino; | 627 | dirp->dot_ino = ino; | |
628 | dirp->dotdot_ino = parent; | 628 | dirp->dotdot_ino = parent; | |
629 | vp = vget(fs, ino); | 629 | vp = vget(fs, ino); | |
630 | dp = VTOD(vp); | 630 | dp = VTOD(vp); | |
631 | bread(vp, dp->di_db[0], fs->lfs_fsize, NOCRED, 0, &bp); | 631 | bread(vp, dp->di_db[0], fs->lfs_fsize, NOCRED, 0, &bp); | |
632 | if (bp->b_flags & B_ERROR) { | 632 | if (bp->b_flags & B_ERROR) { | |
633 | brelse(bp, 0); | 633 | brelse(bp, 0); | |
634 | freeino(ino); | 634 | freeino(ino); | |
635 | return (0); | 635 | return (0); | |
636 | } | 636 | } | |
637 | memcpy(bp->b_data, dirp, sizeof(struct dirtemplate)); | 637 | memcpy(bp->b_data, dirp, sizeof(struct lfs_dirtemplate)); | |
638 | for (cp = &bp->b_data[DIRBLKSIZ]; | 638 | for (cp = &bp->b_data[DIRBLKSIZ]; | |
639 | cp < &bp->b_data[fs->lfs_fsize]; | 639 | cp < &bp->b_data[fs->lfs_fsize]; | |
640 | cp += DIRBLKSIZ) | 640 | cp += DIRBLKSIZ) | |
641 | memcpy(cp, &emptydir, sizeof emptydir); | 641 | memcpy(cp, &emptydir, sizeof emptydir); | |
642 | VOP_BWRITE(bp); | 642 | VOP_BWRITE(bp); | |
643 | dp->di_nlink = 2; | 643 | dp->di_nlink = 2; | |
644 | inodirty(VTOI(vp)); | 644 | inodirty(VTOI(vp)); | |
645 | if (ino == ULFS_ROOTINO) { | 645 | if (ino == ULFS_ROOTINO) { | |
646 | lncntp[ino] = dp->di_nlink; | 646 | lncntp[ino] = dp->di_nlink; | |
647 | cacheino(dp, ino); | 647 | cacheino(dp, ino); | |
648 | return (ino); | 648 | return (ino); | |
649 | } | 649 | } | |
650 | if (statemap[parent] != DSTATE && statemap[parent] != DFOUND) { | 650 | if (statemap[parent] != DSTATE && statemap[parent] != DFOUND) { |
--- src/sbin/fsck_lfs/extern.h 2013/06/06 00:52:50 1.10
+++ src/sbin/fsck_lfs/extern.h 2013/06/08 02:12:56 1.11
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: extern.h,v 1.10 2013/06/06 00:52:50 dholland Exp $ */ | 1 | /* $NetBSD: extern.h,v 1.11 2013/06/08 02:12:56 dholland Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1994 James A. Jegers | 4 | * Copyright (c) 1994 James A. Jegers | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. The name of the author may not be used to endorse or promote products | 12 | * 2. The name of the author may not be used to endorse or promote products | |
13 | * derived from this software without specific prior written permission | 13 | * derived from this software without specific prior written permission | |
14 | * | 14 | * | |
@@ -26,27 +26,27 @@ | @@ -26,27 +26,27 @@ | |||
26 | 26 | |||
27 | void adjust(struct inodesc *, short); | 27 | void adjust(struct inodesc *, short); | |
28 | int allocblk(long); | 28 | int allocblk(long); | |
29 | int allocdir(ino_t, ino_t, int); | 29 | int allocdir(ino_t, ino_t, int); | |
30 | void blkerror(ino_t, const char *, daddr_t); | 30 | void blkerror(ino_t, const char *, daddr_t); | |
31 | void cacheino(struct ulfs1_dinode *, ino_t); | 31 | void cacheino(struct ulfs1_dinode *, ino_t); | |
32 | int changeino(ino_t, const char *, ino_t); | 32 | int changeino(ino_t, const char *, ino_t); | |
33 | struct fstab; | 33 | struct fstab; | |
34 | void checkinode(ino_t, struct inodesc *); | 34 | void checkinode(ino_t, struct inodesc *); | |
35 | int chkrange(daddr_t, int); | 35 | int chkrange(daddr_t, int); | |
36 | void ckfini(int); | 36 | void ckfini(int); | |
37 | int ckinode(struct ulfs1_dinode *, struct inodesc *); | 37 | int ckinode(struct ulfs1_dinode *, struct inodesc *); | |
38 | void clri(struct inodesc *, const char *, int); | 38 | void clri(struct inodesc *, const char *, int); | |
39 | int dircheck(struct inodesc *, struct direct *); | 39 | int dircheck(struct inodesc *, struct lfs_direct *); | |
40 | void direrror(ino_t, const char *); | 40 | void direrror(ino_t, const char *); | |
41 | int dirscan(struct inodesc *); | 41 | int dirscan(struct inodesc *); | |
42 | int dofix(struct inodesc *, const char *); | 42 | int dofix(struct inodesc *, const char *); | |
43 | void fileerror(ino_t, ino_t, const char *); | 43 | void fileerror(ino_t, ino_t, const char *); | |
44 | int findino(struct inodesc *); | 44 | int findino(struct inodesc *); | |
45 | int findname(struct inodesc *); | 45 | int findname(struct inodesc *); | |
46 | void flush(int, struct ubufarea *); | 46 | void flush(int, struct ubufarea *); | |
47 | void freeblk(daddr_t, long); | 47 | void freeblk(daddr_t, long); | |
48 | void freeino(ino_t); | 48 | void freeino(ino_t); | |
49 | void freeinodebuf(void); | 49 | void freeinodebuf(void); | |
50 | int ftypeok(struct ulfs1_dinode *); | 50 | int ftypeok(struct ulfs1_dinode *); | |
51 | void getpathname(char *, size_t, ino_t, ino_t); | 51 | void getpathname(char *, size_t, ino_t, ino_t); | |
52 | void inocleanup(void); | 52 | void inocleanup(void); |
--- src/sbin/fsck_lfs/fsck.h 2013/06/06 00:52:50 1.19
+++ src/sbin/fsck_lfs/fsck.h 2013/06/08 02:12:56 1.20
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: fsck.h,v 1.19 2013/06/06 00:52:50 dholland Exp $ */ | 1 | /* $NetBSD: fsck.h,v 1.20 2013/06/08 02:12:56 dholland Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1997 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1997 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Konrad E. Schroder <perseant@hhhh.org>. | 8 | * by Konrad E. Schroder <perseant@hhhh.org>. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -121,27 +121,27 @@ enum fixstate { | @@ -121,27 +121,27 @@ enum fixstate { | |||
121 | 121 | |||
122 | struct inodesc { | 122 | struct inodesc { | |
123 | enum fixstate id_fix; /* policy on fixing errors */ | 123 | enum fixstate id_fix; /* policy on fixing errors */ | |
124 | int (*id_func) (struct inodesc *); /* function to be applied to | 124 | int (*id_func) (struct inodesc *); /* function to be applied to | |
125 | * blocks of inode */ | 125 | * blocks of inode */ | |
126 | ino_t id_number; /* inode number described */ | 126 | ino_t id_number; /* inode number described */ | |
127 | ino_t id_parent; /* for DATA nodes, their parent */ | 127 | ino_t id_parent; /* for DATA nodes, their parent */ | |
128 | daddr_t id_blkno; /* current block number being examined */ | 128 | daddr_t id_blkno; /* current block number being examined */ | |
129 | daddr_t id_lblkno; /* current logical block number */ | 129 | daddr_t id_lblkno; /* current logical block number */ | |
130 | int id_numfrags; /* number of frags contained in block */ | 130 | int id_numfrags; /* number of frags contained in block */ | |
131 | quad_t id_filesize; /* for DATA nodes, the size of the directory */ | 131 | quad_t id_filesize; /* for DATA nodes, the size of the directory */ | |
132 | int id_loc; /* for DATA nodes, current location in dir */ | 132 | int id_loc; /* for DATA nodes, current location in dir */ | |
133 | int id_entryno; /* for DATA nodes, current entry number */ | 133 | int id_entryno; /* for DATA nodes, current entry number */ | |
134 | struct direct *id_dirp; /* for DATA nodes, ptr to current entry */ | 134 | struct lfs_direct *id_dirp; /* for DATA nodes, ptr to current entry */ | |
135 | const char *id_name; /* for DATA nodes, name to find or enter */ | 135 | const char *id_name; /* for DATA nodes, name to find or enter */ | |
136 | char id_type; /* type of descriptor, DATA or ADDR */ | 136 | char id_type; /* type of descriptor, DATA or ADDR */ | |
137 | }; | 137 | }; | |
138 | /* file types */ | 138 | /* file types */ | |
139 | #define DATA 1 | 139 | #define DATA 1 | |
140 | #define ADDR 2 | 140 | #define ADDR 2 | |
141 | 141 | |||
142 | /* | 142 | /* | |
143 | * Linked list of duplicate blocks. | 143 | * Linked list of duplicate blocks. | |
144 | * | 144 | * | |
145 | * The list is composed of two parts. The first part of the | 145 | * The list is composed of two parts. The first part of the | |
146 | * list (from duplist through the node pointed to by muldup) | 146 | * list (from duplist through the node pointed to by muldup) | |
147 | * contains a single copy of each duplicate block that has been | 147 | * contains a single copy of each duplicate block that has been |
--- src/sbin/fsck_lfs/inode.c 2013/06/08 02:11:11 1.47
+++ src/sbin/fsck_lfs/inode.c 2013/06/08 02:12:56 1.48
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: inode.c,v 1.47 2013/06/08 02:11:11 dholland Exp $ */ | 1 | /* $NetBSD: inode.c,v 1.48 2013/06/08 02:12:56 dholland Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Konrad E. Schroder <perseant@hhhh.org>. | 8 | * by Konrad E. Schroder <perseant@hhhh.org>. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -476,46 +476,46 @@ clearinode(ino_t inumber) | @@ -476,46 +476,46 @@ clearinode(ino_t inumber) | |||
476 | SEGUSE *sup; | 476 | SEGUSE *sup; | |
477 | u_int32_t oldsn = dtosn(fs, daddr); | 477 | u_int32_t oldsn = dtosn(fs, daddr); | |
478 | 478 | |||
479 | seg_table[oldsn].su_nbytes -= LFS_DINODE1_SIZE; | 479 | seg_table[oldsn].su_nbytes -= LFS_DINODE1_SIZE; | |
480 | LFS_SEGENTRY(sup, fs, oldsn, bp); | 480 | LFS_SEGENTRY(sup, fs, oldsn, bp); | |
481 | sup->su_nbytes -= LFS_DINODE1_SIZE; | 481 | sup->su_nbytes -= LFS_DINODE1_SIZE; | |
482 | LFS_WRITESEGENTRY(sup, fs, oldsn, bp); /* Ifile */ | 482 | LFS_WRITESEGENTRY(sup, fs, oldsn, bp); /* Ifile */ | |
483 | } | 483 | } | |
484 | } | 484 | } | |
485 | 485 | |||
486 | int | 486 | int | |
487 | findname(struct inodesc * idesc) | 487 | findname(struct inodesc * idesc) | |
488 | { | 488 | { | |
489 | struct direct *dirp = idesc->id_dirp; | 489 | struct lfs_direct *dirp = idesc->id_dirp; | |
490 | size_t len; | 490 | size_t len; | |
491 | char *buf; | 491 | char *buf; | |
492 | 492 | |||
493 | if (dirp->d_ino != idesc->id_parent) | 493 | if (dirp->d_ino != idesc->id_parent) | |
494 | return (KEEPON); | 494 | return (KEEPON); | |
495 | if ((len = dirp->d_namlen + 1) > MAXPATHLEN) { | 495 | if ((len = dirp->d_namlen + 1) > MAXPATHLEN) { | |
496 | /* Truncate it but don't overflow the buffer */ | 496 | /* Truncate it but don't overflow the buffer */ | |
497 | len = MAXPATHLEN; | 497 | len = MAXPATHLEN; | |
498 | } | 498 | } | |
499 | /* this is namebuf with utils.h */ | 499 | /* this is namebuf with utils.h */ | |
500 | buf = __UNCONST(idesc->id_name); | 500 | buf = __UNCONST(idesc->id_name); | |
501 | (void)memcpy(buf, dirp->d_name, len); | 501 | (void)memcpy(buf, dirp->d_name, len); | |
502 | return (STOP | FOUND); | 502 | return (STOP | FOUND); | |
503 | } | 503 | } | |
504 | 504 | |||
505 | int | 505 | int | |
506 | findino(struct inodesc * idesc) | 506 | findino(struct inodesc * idesc) | |
507 | { | 507 | { | |
508 | struct direct *dirp = idesc->id_dirp; | 508 | struct lfs_direct *dirp = idesc->id_dirp; | |
509 | 509 | |||
510 | if (dirp->d_ino == 0) | 510 | if (dirp->d_ino == 0) | |
511 | return (KEEPON); | 511 | return (KEEPON); | |
512 | if (strcmp(dirp->d_name, idesc->id_name) == 0 && | 512 | if (strcmp(dirp->d_name, idesc->id_name) == 0 && | |
513 | dirp->d_ino >= ULFS_ROOTINO && dirp->d_ino < maxino) { | 513 | dirp->d_ino >= ULFS_ROOTINO && dirp->d_ino < maxino) { | |
514 | idesc->id_parent = dirp->d_ino; | 514 | idesc->id_parent = dirp->d_ino; | |
515 | return (STOP | FOUND); | 515 | return (STOP | FOUND); | |
516 | } | 516 | } | |
517 | return (KEEPON); | 517 | return (KEEPON); | |
518 | } | 518 | } | |
519 | 519 | |||
520 | void | 520 | void | |
521 | pinode(ino_t ino) | 521 | pinode(ino_t ino) |
--- src/sbin/fsck_lfs/pass2.c 2013/06/08 02:11:11 1.20
+++ src/sbin/fsck_lfs/pass2.c 2013/06/08 02:12:56 1.21
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: pass2.c,v 1.20 2013/06/08 02:11:11 dholland Exp $ */ | 1 | /* $NetBSD: pass2.c,v 1.21 2013/06/08 02:12:56 dholland Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1980, 1986, 1993 | 4 | * Copyright (c) 1980, 1986, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -42,27 +42,27 @@ | @@ -42,27 +42,27 @@ | |||
42 | #include <err.h> | 42 | #include <err.h> | |
43 | #include <stdio.h> | 43 | #include <stdio.h> | |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> | |
45 | #include <string.h> | 45 | #include <string.h> | |
46 | 46 | |||
47 | #include "bufcache.h" | 47 | #include "bufcache.h" | |
48 | #include "vnode.h" | 48 | #include "vnode.h" | |
49 | #include "lfs_user.h" | 49 | #include "lfs_user.h" | |
50 | 50 | |||
51 | #include "fsck.h" | 51 | #include "fsck.h" | |
52 | #include "fsutil.h" | 52 | #include "fsutil.h" | |
53 | #include "extern.h" | 53 | #include "extern.h" | |
54 | 54 | |||
55 | #define MINDIRSIZE (sizeof (struct dirtemplate)) | 55 | #define MINDIRSIZE (sizeof (struct lfs_dirtemplate)) | |
56 | 56 | |||
57 | static int pass2check(struct inodesc *); | 57 | static int pass2check(struct inodesc *); | |
58 | static int blksort(const void *, const void *); | 58 | static int blksort(const void *, const void *); | |
59 | 59 | |||
60 | void | 60 | void | |
61 | pass2(void) | 61 | pass2(void) | |
62 | { | 62 | { | |
63 | struct ulfs1_dinode *dp; | 63 | struct ulfs1_dinode *dp; | |
64 | struct uvnode *vp; | 64 | struct uvnode *vp; | |
65 | struct inoinfo **inpp, *inp; | 65 | struct inoinfo **inpp, *inp; | |
66 | struct inoinfo **inpend; | 66 | struct inoinfo **inpend; | |
67 | struct inodesc curino; | 67 | struct inodesc curino; | |
68 | struct ulfs1_dinode dino; | 68 | struct ulfs1_dinode dino; | |
@@ -105,27 +105,27 @@ pass2(void) | @@ -105,27 +105,27 @@ pass2(void) | |||
105 | dp = VTOD(vp); | 105 | dp = VTOD(vp); | |
106 | dp->di_mode &= ~LFS_IFMT; | 106 | dp->di_mode &= ~LFS_IFMT; | |
107 | dp->di_mode |= LFS_IFDIR; | 107 | dp->di_mode |= LFS_IFDIR; | |
108 | inodirty(VTOI(vp)); | 108 | inodirty(VTOI(vp)); | |
109 | break; | 109 | break; | |
110 | 110 | |||
111 | case DSTATE: | 111 | case DSTATE: | |
112 | break; | 112 | break; | |
113 | 113 | |||
114 | default: | 114 | default: | |
115 | errx(EEXIT, "BAD STATE %d FOR ROOT INODE\n", statemap[ULFS_ROOTINO]); | 115 | errx(EEXIT, "BAD STATE %d FOR ROOT INODE\n", statemap[ULFS_ROOTINO]); | |
116 | } | 116 | } | |
117 | statemap[ULFS_WINO] = FSTATE; | 117 | statemap[ULFS_WINO] = FSTATE; | |
118 | typemap[ULFS_WINO] = DT_WHT; | 118 | typemap[ULFS_WINO] = LFS_DT_WHT; | |
119 | /* | 119 | /* | |
120 | * Sort the directory list into disk block order. | 120 | * Sort the directory list into disk block order. | |
121 | */ | 121 | */ | |
122 | qsort((char *) inpsort, (size_t) inplast, sizeof *inpsort, blksort); | 122 | qsort((char *) inpsort, (size_t) inplast, sizeof *inpsort, blksort); | |
123 | /* | 123 | /* | |
124 | * Check the integrity of each directory. | 124 | * Check the integrity of each directory. | |
125 | */ | 125 | */ | |
126 | memset(&curino, 0, sizeof(struct inodesc)); | 126 | memset(&curino, 0, sizeof(struct inodesc)); | |
127 | curino.id_type = DATA; | 127 | curino.id_type = DATA; | |
128 | curino.id_func = pass2check; | 128 | curino.id_func = pass2check; | |
129 | inpend = &inpsort[inplast]; | 129 | inpend = &inpsort[inplast]; | |
130 | for (inpp = inpsort; inpp < inpend; inpp++) { | 130 | for (inpp = inpsort; inpp < inpend; inpp++) { | |
131 | inp = *inpp; | 131 | inp = *inpp; | |
@@ -191,109 +191,109 @@ pass2(void) | @@ -191,109 +191,109 @@ pass2(void) | |||
191 | lncntp[inp->i_parent]--; | 191 | lncntp[inp->i_parent]--; | |
192 | inp->i_dotdot = inp->i_parent; | 192 | inp->i_dotdot = inp->i_parent; | |
193 | (void) changeino(inp->i_number, "..", inp->i_parent); | 193 | (void) changeino(inp->i_number, "..", inp->i_parent); | |
194 | } | 194 | } | |
195 | /* | 195 | /* | |
196 | * Mark all the directories that can be found from the root. | 196 | * Mark all the directories that can be found from the root. | |
197 | */ | 197 | */ | |
198 | propagate(); | 198 | propagate(); | |
199 | } | 199 | } | |
200 | 200 | |||
201 | static int | 201 | static int | |
202 | pass2check(struct inodesc * idesc) | 202 | pass2check(struct inodesc * idesc) | |
203 | { | 203 | { | |
204 | struct direct *dirp = idesc->id_dirp; | 204 | struct lfs_direct *dirp = idesc->id_dirp; | |
205 | struct inoinfo *inp; | 205 | struct inoinfo *inp; | |
206 | int n, entrysize, ret = 0; | 206 | int n, entrysize, ret = 0; | |
207 | struct ulfs1_dinode *dp; | 207 | struct ulfs1_dinode *dp; | |
208 | const char *errmsg; | 208 | const char *errmsg; | |
209 | struct direct proto; | 209 | struct lfs_direct proto; | |
210 | char namebuf[MAXPATHLEN + 1]; | 210 | char namebuf[MAXPATHLEN + 1]; | |
211 | char pathbuf[MAXPATHLEN + 1]; | 211 | char pathbuf[MAXPATHLEN + 1]; | |
212 | 212 | |||
213 | /* | 213 | /* | |
214 | * check for "." | 214 | * check for "." | |
215 | */ | 215 | */ | |
216 | if (idesc->id_entryno != 0) | 216 | if (idesc->id_entryno != 0) | |
217 | goto chk1; | 217 | goto chk1; | |
218 | if (dirp->d_ino != 0 && strcmp(dirp->d_name, ".") == 0) { | 218 | if (dirp->d_ino != 0 && strcmp(dirp->d_name, ".") == 0) { | |
219 | if (dirp->d_ino != idesc->id_number) { | 219 | if (dirp->d_ino != idesc->id_number) { | |
220 | direrror(idesc->id_number, "BAD INODE NUMBER FOR '.'"); | 220 | direrror(idesc->id_number, "BAD INODE NUMBER FOR '.'"); | |
221 | dirp->d_ino = idesc->id_number; | 221 | dirp->d_ino = idesc->id_number; | |
222 | if (reply("FIX") == 1) | 222 | if (reply("FIX") == 1) | |
223 | ret |= ALTERED; | 223 | ret |= ALTERED; | |
224 | } | 224 | } | |
225 | if (dirp->d_type != DT_DIR) { | 225 | if (dirp->d_type != LFS_DT_DIR) { | |
226 | direrror(idesc->id_number, "BAD TYPE VALUE FOR '.'"); | 226 | direrror(idesc->id_number, "BAD TYPE VALUE FOR '.'"); | |
227 | dirp->d_type = DT_DIR; | 227 | dirp->d_type = LFS_DT_DIR; | |
228 | if (reply("FIX") == 1) | 228 | if (reply("FIX") == 1) | |
229 | ret |= ALTERED; | 229 | ret |= ALTERED; | |
230 | } | 230 | } | |
231 | goto chk1; | 231 | goto chk1; | |
232 | } | 232 | } | |
233 | direrror(idesc->id_number, "MISSING '.'"); | 233 | direrror(idesc->id_number, "MISSING '.'"); | |
234 | proto.d_ino = idesc->id_number; | 234 | proto.d_ino = idesc->id_number; | |
235 | proto.d_type = DT_DIR; | 235 | proto.d_type = LFS_DT_DIR; | |
236 | proto.d_namlen = 1; | 236 | proto.d_namlen = 1; | |
237 | (void) strlcpy(proto.d_name, ".", sizeof(proto.d_name)); | 237 | (void) strlcpy(proto.d_name, ".", sizeof(proto.d_name)); | |
238 | entrysize = DIRSIZ(0, &proto, 0); | 238 | entrysize = DIRSIZ(0, &proto, 0); | |
239 | if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") != 0) { | 239 | if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") != 0) { | |
240 | pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n", | 240 | pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n", | |
241 | dirp->d_name); | 241 | dirp->d_name); | |
242 | } else if (dirp->d_reclen < entrysize) { | 242 | } else if (dirp->d_reclen < entrysize) { | |
243 | pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '.'\n"); | 243 | pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '.'\n"); | |
244 | } else if (dirp->d_reclen < 2 * entrysize) { | 244 | } else if (dirp->d_reclen < 2 * entrysize) { | |
245 | proto.d_reclen = dirp->d_reclen; | 245 | proto.d_reclen = dirp->d_reclen; | |
246 | memcpy(dirp, &proto, (size_t) entrysize); | 246 | memcpy(dirp, &proto, (size_t) entrysize); | |
247 | if (reply("FIX") == 1) | 247 | if (reply("FIX") == 1) | |
248 | ret |= ALTERED; | 248 | ret |= ALTERED; | |
249 | } else { | 249 | } else { | |
250 | n = dirp->d_reclen - entrysize; | 250 | n = dirp->d_reclen - entrysize; | |
251 | proto.d_reclen = entrysize; | 251 | proto.d_reclen = entrysize; | |
252 | memcpy(dirp, &proto, (size_t) entrysize); | 252 | memcpy(dirp, &proto, (size_t) entrysize); | |
253 | idesc->id_entryno++; | 253 | idesc->id_entryno++; | |
254 | lncntp[dirp->d_ino]--; | 254 | lncntp[dirp->d_ino]--; | |
255 | dirp = (struct direct *) ((char *) (dirp) + entrysize); | 255 | dirp = (struct lfs_direct *) ((char *) (dirp) + entrysize); | |
256 | memset(dirp, 0, (size_t) n); | 256 | memset(dirp, 0, (size_t) n); | |
257 | dirp->d_reclen = n; | 257 | dirp->d_reclen = n; | |
258 | if (reply("FIX") == 1) | 258 | if (reply("FIX") == 1) | |
259 | ret |= ALTERED; | 259 | ret |= ALTERED; | |
260 | } | 260 | } | |
261 | chk1: | 261 | chk1: | |
262 | if (idesc->id_entryno > 1) | 262 | if (idesc->id_entryno > 1) | |
263 | goto chk2; | 263 | goto chk2; | |
264 | inp = getinoinfo(idesc->id_number); | 264 | inp = getinoinfo(idesc->id_number); | |
265 | proto.d_ino = inp->i_parent; | 265 | proto.d_ino = inp->i_parent; | |
266 | proto.d_type = DT_DIR; | 266 | proto.d_type = LFS_DT_DIR; | |
267 | proto.d_namlen = 2; | 267 | proto.d_namlen = 2; | |
268 | (void) strlcpy(proto.d_name, "..", sizeof(proto.d_name)); | 268 | (void) strlcpy(proto.d_name, "..", sizeof(proto.d_name)); | |
269 | entrysize = DIRSIZ(0, &proto, 0); | 269 | entrysize = DIRSIZ(0, &proto, 0); | |
270 | if (idesc->id_entryno == 0) { | 270 | if (idesc->id_entryno == 0) { | |
271 | n = DIRSIZ(0, dirp, 0); | 271 | n = DIRSIZ(0, dirp, 0); | |
272 | if (dirp->d_reclen < n + entrysize) | 272 | if (dirp->d_reclen < n + entrysize) | |
273 | goto chk2; | 273 | goto chk2; | |
274 | proto.d_reclen = dirp->d_reclen - n; | 274 | proto.d_reclen = dirp->d_reclen - n; | |
275 | dirp->d_reclen = n; | 275 | dirp->d_reclen = n; | |
276 | idesc->id_entryno++; | 276 | idesc->id_entryno++; | |
277 | lncntp[dirp->d_ino]--; | 277 | lncntp[dirp->d_ino]--; | |
278 | dirp = (struct direct *) ((char *) (dirp) + n); | 278 | dirp = (struct lfs_direct *) ((char *) (dirp) + n); | |
279 | memset(dirp, 0, (size_t) proto.d_reclen); | 279 | memset(dirp, 0, (size_t) proto.d_reclen); | |
280 | dirp->d_reclen = proto.d_reclen; | 280 | dirp->d_reclen = proto.d_reclen; | |
281 | } | 281 | } | |
282 | if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") == 0) { | 282 | if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") == 0) { | |
283 | inp->i_dotdot = dirp->d_ino; | 283 | inp->i_dotdot = dirp->d_ino; | |
284 | if (dirp->d_type != DT_DIR) { | 284 | if (dirp->d_type != LFS_DT_DIR) { | |
285 | direrror(idesc->id_number, "BAD TYPE VALUE FOR '..'"); | 285 | direrror(idesc->id_number, "BAD TYPE VALUE FOR '..'"); | |
286 | dirp->d_type = DT_DIR; | 286 | dirp->d_type = LFS_DT_DIR; | |
287 | if (reply("FIX") == 1) | 287 | if (reply("FIX") == 1) | |
288 | ret |= ALTERED; | 288 | ret |= ALTERED; | |
289 | } | 289 | } | |
290 | goto chk2; | 290 | goto chk2; | |
291 | } | 291 | } | |
292 | if (dirp->d_ino != 0 && strcmp(dirp->d_name, ".") != 0) { | 292 | if (dirp->d_ino != 0 && strcmp(dirp->d_name, ".") != 0) { | |
293 | fileerror(inp->i_parent, idesc->id_number, "MISSING '..'"); | 293 | fileerror(inp->i_parent, idesc->id_number, "MISSING '..'"); | |
294 | pfatal("CANNOT FIX, SECOND ENTRY IN DIRECTORY CONTAINS %s\n", | 294 | pfatal("CANNOT FIX, SECOND ENTRY IN DIRECTORY CONTAINS %s\n", | |
295 | dirp->d_name); | 295 | dirp->d_name); | |
296 | inp->i_dotdot = (ino_t) - 1; | 296 | inp->i_dotdot = (ino_t) - 1; | |
297 | } else if (dirp->d_reclen < entrysize) { | 297 | } else if (dirp->d_reclen < entrysize) { | |
298 | fileerror(inp->i_parent, idesc->id_number, "MISSING '..'"); | 298 | fileerror(inp->i_parent, idesc->id_number, "MISSING '..'"); | |
299 | pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '..'\n"); | 299 | pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '..'\n"); | |
@@ -331,38 +331,38 @@ chk2: | @@ -331,38 +331,38 @@ chk2: | |||
331 | dirp->d_ino = 0; | 331 | dirp->d_ino = 0; | |
332 | if (reply("FIX") == 1) | 332 | if (reply("FIX") == 1) | |
333 | ret |= ALTERED; | 333 | ret |= ALTERED; | |
334 | return (KEEPON | ret); | 334 | return (KEEPON | ret); | |
335 | } | 335 | } | |
336 | } | 336 | } | |
337 | idesc->id_entryno++; | 337 | idesc->id_entryno++; | |
338 | n = 0; | 338 | n = 0; | |
339 | if (dirp->d_ino >= maxino) { | 339 | if (dirp->d_ino >= maxino) { | |
340 | fileerror(idesc->id_number, dirp->d_ino, "I OUT OF RANGE"); | 340 | fileerror(idesc->id_number, dirp->d_ino, "I OUT OF RANGE"); | |
341 | n = reply("REMOVE"); | 341 | n = reply("REMOVE"); | |
342 | } else if (dirp->d_ino == LFS_IFILE_INUM && | 342 | } else if (dirp->d_ino == LFS_IFILE_INUM && | |
343 | idesc->id_number == ULFS_ROOTINO) { | 343 | idesc->id_number == ULFS_ROOTINO) { | |
344 | if (dirp->d_type != DT_REG) { | 344 | if (dirp->d_type != LFS_DT_REG) { | |
345 | fileerror(idesc->id_number, dirp->d_ino, | 345 | fileerror(idesc->id_number, dirp->d_ino, | |
346 | "BAD TYPE FOR IFILE"); | 346 | "BAD TYPE FOR IFILE"); | |
347 | dirp->d_type = DT_REG; | 347 | dirp->d_type = LFS_DT_REG; | |
348 | if (reply("FIX") == 1) | 348 | if (reply("FIX") == 1) | |
349 | ret |= ALTERED; | 349 | ret |= ALTERED; | |
350 | } | 350 | } | |
351 | } else if (((dirp->d_ino == ULFS_WINO && (dirp->d_type != DT_WHT)) || | 351 | } else if (((dirp->d_ino == ULFS_WINO && (dirp->d_type != LFS_DT_WHT)) || | |
352 | (dirp->d_ino != ULFS_WINO && dirp->d_type == DT_WHT))) { | 352 | (dirp->d_ino != ULFS_WINO && dirp->d_type == LFS_DT_WHT))) { | |
353 | fileerror(idesc->id_number, dirp->d_ino, "BAD WHITEOUT ENTRY"); | 353 | fileerror(idesc->id_number, dirp->d_ino, "BAD WHITEOUT ENTRY"); | |
354 | dirp->d_ino = ULFS_WINO; | 354 | dirp->d_ino = ULFS_WINO; | |
355 | dirp->d_type = DT_WHT; | 355 | dirp->d_type = LFS_DT_WHT; | |
356 | if (reply("FIX") == 1) | 356 | if (reply("FIX") == 1) | |
357 | ret |= ALTERED; | 357 | ret |= ALTERED; | |
358 | } else { | 358 | } else { | |
359 | again: | 359 | again: | |
360 | switch (statemap[dirp->d_ino]) { | 360 | switch (statemap[dirp->d_ino]) { | |
361 | case USTATE: | 361 | case USTATE: | |
362 | if (idesc->id_entryno <= 2) | 362 | if (idesc->id_entryno <= 2) | |
363 | break; | 363 | break; | |
364 | fileerror(idesc->id_number, dirp->d_ino, "UNALLOCATED"); | 364 | fileerror(idesc->id_number, dirp->d_ino, "UNALLOCATED"); | |
365 | n = reply("REMOVE"); | 365 | n = reply("REMOVE"); | |
366 | break; | 366 | break; | |
367 | 367 | |||
368 | case DCLEAR: | 368 | case DCLEAR: |
--- src/sbin/newfs_lfs/make_lfs.c 2013/06/08 02:11:11 1.24
+++ src/sbin/newfs_lfs/make_lfs.c 2013/06/08 02:12:56 1.25
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: make_lfs.c,v 1.24 2013/06/08 02:11:11 dholland Exp $ */ | 1 | /* $NetBSD: make_lfs.c,v 1.25 2013/06/08 02:12:56 dholland Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2003 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2003 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Konrad E. Schroder <perseant@hhhh.org>. | 8 | * by Konrad E. Schroder <perseant@hhhh.org>. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -52,27 +52,27 @@ | @@ -52,27 +52,27 @@ | |||
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
53 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 53 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
54 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 54 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
55 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 55 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
56 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 56 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
57 | * SUCH DAMAGE. | 57 | * SUCH DAMAGE. | |
58 | */ | 58 | */ | |
59 | 59 | |||
60 | #include <sys/cdefs.h> | 60 | #include <sys/cdefs.h> | |
61 | #ifndef lint | 61 | #ifndef lint | |
62 | #if 0 | 62 | #if 0 | |
63 | static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95"; | 63 | static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95"; | |
64 | #else | 64 | #else | |
65 | __RCSID("$NetBSD: make_lfs.c,v 1.24 2013/06/08 02:11:11 dholland Exp $"); | 65 | __RCSID("$NetBSD: make_lfs.c,v 1.25 2013/06/08 02:12:56 dholland Exp $"); | |
66 | #endif | 66 | #endif | |
67 | #endif /* not lint */ | 67 | #endif /* not lint */ | |
68 | 68 | |||
69 | #include <sys/param.h> | 69 | #include <sys/param.h> | |
70 | #include <sys/disk.h> | 70 | #include <sys/disk.h> | |
71 | #include <sys/time.h> | 71 | #include <sys/time.h> | |
72 | #include <sys/mount.h> | 72 | #include <sys/mount.h> | |
73 | #include <sys/stat.h> | 73 | #include <sys/stat.h> | |
74 | 74 | |||
75 | /* Override certain things to make <ufs/lfs/lfs.h> work */ | 75 | /* Override certain things to make <ufs/lfs/lfs.h> work */ | |
76 | #define _SYS_VNODE_H_ /* XXX */ | 76 | #define _SYS_VNODE_H_ /* XXX */ | |
77 | # undef simple_lock | 77 | # undef simple_lock | |
78 | # define simple_lock(x) | 78 | # define simple_lock(x) | |
@@ -171,45 +171,45 @@ static struct lfs lfs_default = { | @@ -171,45 +171,45 @@ static struct lfs lfs_default = { | |||
171 | /* dlfs_inodefmt */ LFS_44INODEFMT, | 171 | /* dlfs_inodefmt */ LFS_44INODEFMT, | |
172 | /* dlfs_interleave */ 0, | 172 | /* dlfs_interleave */ 0, | |
173 | /* dlfs_ident */ 0, | 173 | /* dlfs_ident */ 0, | |
174 | /* dlfs_fsbtodb */ 0, | 174 | /* dlfs_fsbtodb */ 0, | |
175 | /* dlfs_resvseg */ 0, | 175 | /* dlfs_resvseg */ 0, | |
176 | 176 | |||
177 | /* dlfs_pad */ { 0 }, | 177 | /* dlfs_pad */ { 0 }, | |
178 | /* dlfs_cksum */ 0 | 178 | /* dlfs_cksum */ 0 | |
179 | }, | 179 | }, | |
180 | }; | 180 | }; | |
181 | 181 | |||
182 | #define UMASK 0755 | 182 | #define UMASK 0755 | |
183 | 183 | |||
184 | struct direct lfs_root_dir[] = { | 184 | struct lfs_direct lfs_root_dir[] = { | |
185 | { ULFS_ROOTINO, sizeof(struct direct), DT_DIR, 1, "."}, | 185 | { ULFS_ROOTINO, sizeof(struct lfs_direct), LFS_DT_DIR, 1, "."}, | |
186 | { ULFS_ROOTINO, sizeof(struct direct), DT_DIR, 2, ".."}, | 186 | { ULFS_ROOTINO, sizeof(struct lfs_direct), LFS_DT_DIR, 2, ".."}, | |
187 | /* { LFS_IFILE_INUM, sizeof(struct direct), DT_REG, 5, "ifile"}, */ | 187 | /* { LFS_IFILE_INUM, sizeof(struct lfs_direct), LFS_DT_REG, 5, "ifile"}, */ | |
188 | #ifdef MAKE_LF_DIR | 188 | #ifdef MAKE_LF_DIR | |
189 | { LOSTFOUNDINO, sizeof(struct direct), DT_DIR, 10, "lost+found"}, | 189 | { LOSTFOUNDINO, sizeof(struct lfs_direct), LFS_DT_DIR, 10, "lost+found"}, | |
190 | #endif | 190 | #endif | |
191 | }; | 191 | }; | |
192 | 192 | |||
193 | #ifdef MAKE_LF_DIR | 193 | #ifdef MAKE_LF_DIR | |
194 | struct direct lfs_lf_dir[] = { | 194 | struct lfs_direct lfs_lf_dir[] = { | |
195 | { LOSTFOUNDINO, sizeof(struct direct), DT_DIR, 1, "." }, | 195 | { LOSTFOUNDINO, sizeof(struct lfs_direct), LFS_DT_DIR, 1, "." }, | |
196 | { ULFS_ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." }, | 196 | { ULFS_ROOTINO, sizeof(struct lfs_direct), LFS_DT_DIR, 2, ".." }, | |
197 | }; | 197 | }; | |
198 | #endif | 198 | #endif | |
199 | 199 | |||
200 | void pwarn(const char *, ...); | 200 | void pwarn(const char *, ...); | |
201 | static void make_dinode(ino_t, struct ulfs1_dinode *, int, struct lfs *); | 201 | static void make_dinode(ino_t, struct ulfs1_dinode *, int, struct lfs *); | |
202 | static void make_dir( void *, struct direct *, int); | 202 | static void make_dir( void *, struct lfs_direct *, int); | |
203 | static uint64_t maxfilesize(int); | 203 | static uint64_t maxfilesize(int); | |
204 | 204 | |||
205 | /* | 205 | /* | |
206 | * calculate the maximum file size allowed with the specified block shift. | 206 | * calculate the maximum file size allowed with the specified block shift. | |
207 | */ | 207 | */ | |
208 | static uint64_t | 208 | static uint64_t | |
209 | maxfilesize(int bshift) | 209 | maxfilesize(int bshift) | |
210 | { | 210 | { | |
211 | uint64_t nptr; /* number of block pointers per block */ | 211 | uint64_t nptr; /* number of block pointers per block */ | |
212 | uint64_t maxblock; | 212 | uint64_t maxblock; | |
213 | 213 | |||
214 | nptr = (1 << bshift) / sizeof(uint32_t); | 214 | nptr = (1 << bshift) / sizeof(uint32_t); | |
215 | maxblock = ULFS_NDADDR + nptr + nptr * nptr + nptr * nptr * nptr; | 215 | maxblock = ULFS_NDADDR + nptr + nptr * nptr + nptr * nptr * nptr; | |
@@ -270,27 +270,27 @@ make_dinode(ino_t ino, struct ulfs1_dino | @@ -270,27 +270,27 @@ make_dinode(ino_t ino, struct ulfs1_dino | |||
270 | --bb; | 270 | --bb; | |
271 | factor *= NINDIR(fs); | 271 | factor *= NINDIR(fs); | |
272 | base -= factor; | 272 | base -= factor; | |
273 | ++lvl; | 273 | ++lvl; | |
274 | } | 274 | } | |
275 | } | 275 | } | |
276 | } | 276 | } | |
277 | 277 | |||
278 | /* | 278 | /* | |
279 | * Construct a set of directory entries in "bufp". We assume that all the | 279 | * Construct a set of directory entries in "bufp". We assume that all the | |
280 | * entries in protodir fir in the first DIRBLKSIZ. | 280 | * entries in protodir fir in the first DIRBLKSIZ. | |
281 | */ | 281 | */ | |
282 | static void | 282 | static void | |
283 | make_dir(void *bufp, struct direct *protodir, int entries) | 283 | make_dir(void *bufp, struct lfs_direct *protodir, int entries) | |
284 | { | 284 | { | |
285 | char *cp; | 285 | char *cp; | |
286 | int i, spcleft; | 286 | int i, spcleft; | |
287 | 287 | |||
288 | spcleft = DIRBLKSIZ; | 288 | spcleft = DIRBLKSIZ; | |
289 | for (cp = bufp, i = 0; i < entries - 1; i++) { | 289 | for (cp = bufp, i = 0; i < entries - 1; i++) { | |
290 | protodir[i].d_reclen = DIRSIZ(NEWDIRFMT, &protodir[i], 0); | 290 | protodir[i].d_reclen = DIRSIZ(NEWDIRFMT, &protodir[i], 0); | |
291 | memmove(cp, &protodir[i], protodir[i].d_reclen); | 291 | memmove(cp, &protodir[i], protodir[i].d_reclen); | |
292 | cp += protodir[i].d_reclen; | 292 | cp += protodir[i].d_reclen; | |
293 | if ((spcleft -= protodir[i].d_reclen) < 0) | 293 | if ((spcleft -= protodir[i].d_reclen) < 0) | |
294 | fatal("%s: %s", special, "directory too big"); | 294 | fatal("%s: %s", special, "directory too big"); | |
295 | } | 295 | } | |
296 | protodir[i].d_reclen = spcleft; | 296 | protodir[i].d_reclen = spcleft; | |
@@ -686,47 +686,47 @@ make_lfs(int devfd, uint secsize, struct | @@ -686,47 +686,47 @@ make_lfs(int devfd, uint secsize, struct | |||
686 | VTOI(vp)->i_nlink = dip->di_nlink = 3; | 686 | VTOI(vp)->i_nlink = dip->di_nlink = 3; | |
687 | #else | 687 | #else | |
688 | VTOI(vp)->i_nlink = dip->di_nlink = 2; | 688 | VTOI(vp)->i_nlink = dip->di_nlink = 2; | |
689 | #endif | 689 | #endif | |
690 | VTOI(vp)->i_lfs_effnblks = dip->di_blocks = | 690 | VTOI(vp)->i_lfs_effnblks = dip->di_blocks = | |
691 | btofsb(fs, roundup(DIRBLKSIZ,fs->lfs_fsize)); | 691 | btofsb(fs, roundup(DIRBLKSIZ,fs->lfs_fsize)); | |
692 | for (i = 0; i < ULFS_NDADDR && i < howmany(DIRBLKSIZ, fs->lfs_bsize); i++) | 692 | for (i = 0; i < ULFS_NDADDR && i < howmany(DIRBLKSIZ, fs->lfs_bsize); i++) | |
693 | VTOI(vp)->i_lfs_fragsize[i] = fs->lfs_bsize; | 693 | VTOI(vp)->i_lfs_fragsize[i] = fs->lfs_bsize; | |
694 | if (DIRBLKSIZ < fs->lfs_bsize) | 694 | if (DIRBLKSIZ < fs->lfs_bsize) | |
695 | VTOI(vp)->i_lfs_fragsize[i - 1] = | 695 | VTOI(vp)->i_lfs_fragsize[i - 1] = | |
696 | roundup(DIRBLKSIZ,fs->lfs_fsize); | 696 | roundup(DIRBLKSIZ,fs->lfs_fsize); | |
697 | bread(vp, 0, fs->lfs_fsize, NOCRED, 0, &bp); | 697 | bread(vp, 0, fs->lfs_fsize, NOCRED, 0, &bp); | |
698 | make_dir(bp->b_data, lfs_root_dir, | 698 | make_dir(bp->b_data, lfs_root_dir, | |
699 | sizeof(lfs_root_dir) / sizeof(struct direct)); | 699 | sizeof(lfs_root_dir) / sizeof(struct lfs_direct)); | |
700 | VOP_BWRITE(bp); | 700 | VOP_BWRITE(bp); | |
701 | 701 | |||
702 | #ifdef MAKE_LF_DIR | 702 | #ifdef MAKE_LF_DIR | |
703 | /* Initialize lost+found directory */ | 703 | /* Initialize lost+found directory */ | |
704 | vp = lfs_raw_vget(fs, LOSTFOUNDINO, devfd, 0x0); | 704 | vp = lfs_raw_vget(fs, LOSTFOUNDINO, devfd, 0x0); | |
705 | dip = VTOI(vp)->i_din.ffs1_din; | 705 | dip = VTOI(vp)->i_din.ffs1_din; | |
706 | make_dinode(LOSTFOUNDINO, dip, howmany(DIRBLKSIZ,fs->lfs_fsize), fs); | 706 | make_dinode(LOSTFOUNDINO, dip, howmany(DIRBLKSIZ,fs->lfs_fsize), fs); | |
707 | dip->di_mode = IFDIR | UMASK; | 707 | dip->di_mode = IFDIR | UMASK; | |
708 | VTOI(vp)->i_lfs_osize = dip->di_size = DIRBLKSIZ; | 708 | VTOI(vp)->i_lfs_osize = dip->di_size = DIRBLKSIZ; | |
709 | VTOI(vp)->i_nlink = dip->di_nlink = 2; | 709 | VTOI(vp)->i_nlink = dip->di_nlink = 2; | |
710 | VTOI(vp)->i_lfs_effnblks = dip->di_blocks = | 710 | VTOI(vp)->i_lfs_effnblks = dip->di_blocks = | |
711 | btofsb(fs, roundup(DIRBLKSIZ,fs->lfs_fsize)); | 711 | btofsb(fs, roundup(DIRBLKSIZ,fs->lfs_fsize)); | |
712 | for (i = 0; i < ULFS_NDADDR && i < howmany(DIRBLKSIZ, fs->lfs_bsize); i++) | 712 | for (i = 0; i < ULFS_NDADDR && i < howmany(DIRBLKSIZ, fs->lfs_bsize); i++) | |
713 | VTOI(vp)->i_lfs_fragsize[i] = fs->lfs_bsize; | 713 | VTOI(vp)->i_lfs_fragsize[i] = fs->lfs_bsize; | |
714 | if (DIRBLKSIZ < fs->lfs_bsize) | 714 | if (DIRBLKSIZ < fs->lfs_bsize) | |
715 | VTOI(vp)->i_lfs_fragsize[i - 1] = | 715 | VTOI(vp)->i_lfs_fragsize[i - 1] = | |
716 | roundup(DIRBLKSIZ,fs->lfs_fsize); | 716 | roundup(DIRBLKSIZ,fs->lfs_fsize); | |
717 | bread(vp, 0, fs->lfs_fsize, NOCRED, 0, &bp); | 717 | bread(vp, 0, fs->lfs_fsize, NOCRED, 0, &bp); | |
718 | make_dir(bp->b_data, lfs_lf_dir, | 718 | make_dir(bp->b_data, lfs_lf_dir, | |
719 | sizeof(lfs_lf_dir) / sizeof(struct direct)); | 719 | sizeof(lfs_lf_dir) / sizeof(struct lfs_direct)); | |
720 | VOP_BWRITE(bp); | 720 | VOP_BWRITE(bp); | |
721 | #endif /* MAKE_LF_DIR */ | 721 | #endif /* MAKE_LF_DIR */ | |
722 | 722 | |||
723 | /* Set their IFILE entry version numbers to 1 */ | 723 | /* Set their IFILE entry version numbers to 1 */ | |
724 | LFS_IENTRY(ip, fs, 1, bp); | 724 | LFS_IENTRY(ip, fs, 1, bp); | |
725 | if (version == 1) { | 725 | if (version == 1) { | |
726 | ip_v1 = (IFILE_V1 *)ip; | 726 | ip_v1 = (IFILE_V1 *)ip; | |
727 | for (i = LFS_IFILE_INUM; i <= HIGHEST_USED_INO; i++) { | 727 | for (i = LFS_IFILE_INUM; i <= HIGHEST_USED_INO; i++) { | |
728 | ip_v1->if_version = 1; | 728 | ip_v1->if_version = 1; | |
729 | ip_v1->if_daddr = 0x0; | 729 | ip_v1->if_daddr = 0x0; | |
730 | ip_v1->if_nextfree = 0; | 730 | ip_v1->if_nextfree = 0; | |
731 | ++ip_v1; | 731 | ++ip_v1; | |
732 | } | 732 | } |
--- src/sys/ufs/lfs/ulfs_dinode.h 2013/06/08 02:11:49 1.7
+++ src/sys/ufs/lfs/ulfs_dinode.h 2013/06/08 02:12:56 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ulfs_dinode.h,v 1.7 2013/06/08 02:11:49 dholland Exp $ */ | 1 | /* $NetBSD: ulfs_dinode.h,v 1.8 2013/06/08 02:12:56 dholland Exp $ */ | |
2 | /* from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp */ | 2 | /* from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 2002 Networks Associates Technology, Inc. | 5 | * Copyright (c) 2002 Networks Associates Technology, Inc. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * This software was developed for the FreeBSD Project by Marshall | 8 | * This software was developed for the FreeBSD Project by Marshall | |
9 | * Kirk McKusick and Network Associates Laboratories, the Security | 9 | * Kirk McKusick and Network Associates Laboratories, the Security | |
10 | * Research Division of Network Associates, Inc. under DARPA/SPAWAR | 10 | * Research Division of Network Associates, Inc. under DARPA/SPAWAR | |
11 | * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS | 11 | * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS | |
12 | * research program | 12 | * research program | |
13 | * | 13 | * | |
14 | * Copyright (c) 1982, 1989, 1993 | 14 | * Copyright (c) 1982, 1989, 1993 | |
@@ -56,27 +56,27 @@ | @@ -56,27 +56,27 @@ | |||
56 | #include <ufs/lfs/lfs.h> | 56 | #include <ufs/lfs/lfs.h> | |
57 | 57 | |||
58 | /* | 58 | /* | |
59 | * The root inode is the root of the file system. Inode 0 can't be used for | 59 | * The root inode is the root of the file system. Inode 0 can't be used for | |
60 | * normal purposes and historically bad blocks were linked to inode 1, thus | 60 | * normal purposes and historically bad blocks were linked to inode 1, thus | |
61 | * the root inode is 2. (Inode 1 is no longer used for this purpose, however | 61 | * the root inode is 2. (Inode 1 is no longer used for this purpose, however | |
62 | * numerous dump tapes make this assumption, so we are stuck with it). | 62 | * numerous dump tapes make this assumption, so we are stuck with it). | |
63 | */ | 63 | */ | |
64 | #define ULFS_ROOTINO ((ino_t)2) | 64 | #define ULFS_ROOTINO ((ino_t)2) | |
65 | 65 | |||
66 | /* | 66 | /* | |
67 | * The Whiteout inode# is a dummy non-zero inode number which will | 67 | * The Whiteout inode# is a dummy non-zero inode number which will | |
68 | * never be allocated to a real file. It is used as a place holder | 68 | * never be allocated to a real file. It is used as a place holder | |
69 | * in the directory entry which has been tagged as a DT_W entry. | 69 | * in the directory entry which has been tagged as a LFS_DT_WHT entry. | |
70 | * See the comments about ULFS_ROOTINO above. | 70 | * See the comments about ULFS_ROOTINO above. | |
71 | */ | 71 | */ | |
72 | #define ULFS_WINO ((ino_t)1) | 72 | #define ULFS_WINO ((ino_t)1) | |
73 | 73 | |||
74 | /* | 74 | /* | |
75 | * Maximum length of a symlink that can be stored within the inode. | 75 | * Maximum length of a symlink that can be stored within the inode. | |
76 | */ | 76 | */ | |
77 | #define ULFS1_MAXSYMLINKLEN ((ULFS_NDADDR + ULFS_NIADDR) * sizeof(int32_t)) | 77 | #define ULFS1_MAXSYMLINKLEN ((ULFS_NDADDR + ULFS_NIADDR) * sizeof(int32_t)) | |
78 | #define ULFS2_MAXSYMLINKLEN ((ULFS_NDADDR + ULFS_NIADDR) * sizeof(int64_t)) | 78 | #define ULFS2_MAXSYMLINKLEN ((ULFS_NDADDR + ULFS_NIADDR) * sizeof(int64_t)) | |
79 | 79 | |||
80 | #define ULFS_MAXSYMLINKLEN(ip) \ | 80 | #define ULFS_MAXSYMLINKLEN(ip) \ | |
81 | ((ip)->i_ump->um_fstype == ULFS1) ? \ | 81 | ((ip)->i_ump->um_fstype == ULFS1) ? \ | |
82 | ULFS1_MAXSYMLINKLEN : ULFS2_MAXSYMLINKLEN | 82 | ULFS1_MAXSYMLINKLEN : ULFS2_MAXSYMLINKLEN |
--- src/sys/ufs/lfs/ulfs_vfsops.c 2013/06/06 00:52:14 1.7
+++ src/sys/ufs/lfs/ulfs_vfsops.c 2013/06/08 02:12:56 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ulfs_vfsops.c,v 1.7 2013/06/06 00:52:14 dholland Exp $ */ | 1 | /* $NetBSD: ulfs_vfsops.c,v 1.8 2013/06/08 02:12:56 dholland Exp $ */ | |
2 | /* from NetBSD: ufs_vfsops.c,v 1.52 2013/01/22 09:39:18 dholland Exp */ | 2 | /* from NetBSD: ufs_vfsops.c,v 1.52 2013/01/22 09:39:18 dholland Exp */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 1991, 1993, 1994 | 5 | * Copyright (c) 1991, 1993, 1994 | |
6 | * The Regents of the University of California. All rights reserved. | 6 | * The Regents of the University of California. All rights reserved. | |
7 | * (c) UNIX System Laboratories, Inc. | 7 | * (c) UNIX System Laboratories, Inc. | |
8 | * All or some portions of this file are derived from material licensed | 8 | * All or some portions of this file are derived from material licensed | |
9 | * to the University of California by American Telephone and Telegraph | 9 | * to the University of California by American Telephone and Telegraph | |
10 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | 10 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | |
11 | * the permission of UNIX System Laboratories, Inc. | 11 | * the permission of UNIX System Laboratories, Inc. | |
12 | * | 12 | * | |
13 | * Redistribution and use in source and binary forms, with or without | 13 | * Redistribution and use in source and binary forms, with or without | |
14 | * modification, are permitted provided that the following conditions | 14 | * modification, are permitted provided that the following conditions | |
@@ -28,27 +28,27 @@ | @@ -28,27 +28,27 @@ | |||
28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
35 | * SUCH DAMAGE. | 35 | * SUCH DAMAGE. | |
36 | * | 36 | * | |
37 | * @(#)ufs_vfsops.c 8.8 (Berkeley) 5/20/95 | 37 | * @(#)ufs_vfsops.c 8.8 (Berkeley) 5/20/95 | |
38 | */ | 38 | */ | |
39 | 39 | |||
40 | #include <sys/cdefs.h> | 40 | #include <sys/cdefs.h> | |
41 | __KERNEL_RCSID(0, "$NetBSD: ulfs_vfsops.c,v 1.7 2013/06/06 00:52:14 dholland Exp $"); | 41 | __KERNEL_RCSID(0, "$NetBSD: ulfs_vfsops.c,v 1.8 2013/06/08 02:12:56 dholland Exp $"); | |
42 | 42 | |||
43 | #if defined(_KERNEL_OPT) | 43 | #if defined(_KERNEL_OPT) | |
44 | #include "opt_lfs.h" | 44 | #include "opt_lfs.h" | |
45 | #include "opt_quota.h" | 45 | #include "opt_quota.h" | |
46 | #endif | 46 | #endif | |
47 | 47 | |||
48 | #include <sys/param.h> | 48 | #include <sys/param.h> | |
49 | #include <sys/mbuf.h> | 49 | #include <sys/mbuf.h> | |
50 | #include <sys/mount.h> | 50 | #include <sys/mount.h> | |
51 | #include <sys/proc.h> | 51 | #include <sys/proc.h> | |
52 | #include <sys/buf.h> | 52 | #include <sys/buf.h> | |
53 | #include <sys/vnode.h> | 53 | #include <sys/vnode.h> | |
54 | #include <sys/kmem.h> | 54 | #include <sys/kmem.h> | |
@@ -234,27 +234,27 @@ ulfs_fhtovp(struct mount *mp, struct ulf | @@ -234,27 +234,27 @@ ulfs_fhtovp(struct mount *mp, struct ulf | |||
234 | *vpp = nvp; | 234 | *vpp = nvp; | |
235 | return (0); | 235 | return (0); | |
236 | } | 236 | } | |
237 | 237 | |||
238 | /* | 238 | /* | |
239 | * Initialize ULFS filesystems, done only once. | 239 | * Initialize ULFS filesystems, done only once. | |
240 | */ | 240 | */ | |
241 | void | 241 | void | |
242 | ulfs_init(void) | 242 | ulfs_init(void) | |
243 | { | 243 | { | |
244 | if (ulfs_initcount++ > 0) | 244 | if (ulfs_initcount++ > 0) | |
245 | return; | 245 | return; | |
246 | 246 | |||
247 | ulfs_direct_cache = pool_cache_init(sizeof(struct direct), 0, 0, 0, | 247 | ulfs_direct_cache = pool_cache_init(sizeof(struct lfs_direct), 0, 0, 0, | |
248 | "ulfsdir", NULL, IPL_NONE, NULL, NULL, NULL); | 248 | "ulfsdir", NULL, IPL_NONE, NULL, NULL, NULL); | |
249 | 249 | |||
250 | ulfs_ihashinit(); | 250 | ulfs_ihashinit(); | |
251 | #if defined(LFS_QUOTA) || defined(LFS_QUOTA2) | 251 | #if defined(LFS_QUOTA) || defined(LFS_QUOTA2) | |
252 | lfs_dqinit(); | 252 | lfs_dqinit(); | |
253 | #endif | 253 | #endif | |
254 | #ifdef LFS_DIRHASH | 254 | #ifdef LFS_DIRHASH | |
255 | ulfsdirhash_init(); | 255 | ulfsdirhash_init(); | |
256 | #endif | 256 | #endif | |
257 | #ifdef LFS_EXTATTR | 257 | #ifdef LFS_EXTATTR | |
258 | ulfs_extattr_init(); | 258 | ulfs_extattr_init(); | |
259 | #endif | 259 | #endif | |
260 | } | 260 | } |
--- src/sys/ufs/lfs/ulfs_vnops.c 2013/06/08 02:11:11 1.7
+++ src/sys/ufs/lfs/ulfs_vnops.c 2013/06/08 02:12:56 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ulfs_vnops.c,v 1.7 2013/06/08 02:11:11 dholland Exp $ */ | 1 | /* $NetBSD: ulfs_vnops.c,v 1.8 2013/06/08 02:12:56 dholland Exp $ */ | |
2 | /* from NetBSD: ufs_vnops.c,v 1.212 2013/03/18 19:35:48 plunky Exp */ | 2 | /* from NetBSD: ufs_vnops.c,v 1.212 2013/03/18 19:35:48 plunky Exp */ | |
3 | 3 | |||
4 | /*- | 4 | /*- | |
5 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | 5 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * This code is derived from software contributed to The NetBSD Foundation | 8 | * This code is derived from software contributed to The NetBSD Foundation | |
9 | * by Wasabi Systems, Inc. | 9 | * by Wasabi Systems, Inc. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -57,27 +57,27 @@ | @@ -57,27 +57,27 @@ | |||
57 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 57 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
58 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 58 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
59 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 59 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
60 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 60 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
61 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 61 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
62 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 62 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
63 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 63 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
64 | * SUCH DAMAGE. | 64 | * SUCH DAMAGE. | |
65 | * | 65 | * | |
66 | * @(#)ufs_vnops.c 8.28 (Berkeley) 7/31/95 | 66 | * @(#)ufs_vnops.c 8.28 (Berkeley) 7/31/95 | |
67 | */ | 67 | */ | |
68 | 68 | |||
69 | #include <sys/cdefs.h> | 69 | #include <sys/cdefs.h> | |
70 | __KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.7 2013/06/08 02:11:11 dholland Exp $"); | 70 | __KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.8 2013/06/08 02:12:56 dholland Exp $"); | |
71 | 71 | |||
72 | #if defined(_KERNEL_OPT) | 72 | #if defined(_KERNEL_OPT) | |
73 | #include "opt_lfs.h" | 73 | #include "opt_lfs.h" | |
74 | #include "opt_quota.h" | 74 | #include "opt_quota.h" | |
75 | #endif | 75 | #endif | |
76 | 76 | |||
77 | #include <sys/param.h> | 77 | #include <sys/param.h> | |
78 | #include <sys/systm.h> | 78 | #include <sys/systm.h> | |
79 | #include <sys/namei.h> | 79 | #include <sys/namei.h> | |
80 | #include <sys/resourcevar.h> | 80 | #include <sys/resourcevar.h> | |
81 | #include <sys/kernel.h> | 81 | #include <sys/kernel.h> | |
82 | #include <sys/file.h> | 82 | #include <sys/file.h> | |
83 | #include <sys/stat.h> | 83 | #include <sys/stat.h> | |
@@ -108,29 +108,29 @@ __KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c | @@ -108,29 +108,29 @@ __KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c | |||
108 | #endif | 108 | #endif | |
109 | #include <ufs/lfs/lfs_extern.h> | 109 | #include <ufs/lfs/lfs_extern.h> | |
110 | #include <ufs/lfs/lfs.h> | 110 | #include <ufs/lfs/lfs.h> | |
111 | 111 | |||
112 | #include <uvm/uvm.h> | 112 | #include <uvm/uvm.h> | |
113 | 113 | |||
114 | static int ulfs_chmod(struct vnode *, int, kauth_cred_t, struct lwp *); | 114 | static int ulfs_chmod(struct vnode *, int, kauth_cred_t, struct lwp *); | |
115 | static int ulfs_chown(struct vnode *, uid_t, gid_t, kauth_cred_t, | 115 | static int ulfs_chown(struct vnode *, uid_t, gid_t, kauth_cred_t, | |
116 | struct lwp *); | 116 | struct lwp *); | |
117 | 117 | |||
118 | /* | 118 | /* | |
119 | * A virgin directory (no blushing please). | 119 | * A virgin directory (no blushing please). | |
120 | */ | 120 | */ | |
121 | static const struct dirtemplate mastertemplate = { | 121 | static const struct lfs_dirtemplate mastertemplate = { | |
122 | 0, 12, DT_DIR, 1, ".", | 122 | 0, 12, LFS_DT_DIR, 1, ".", | |
123 | 0, DIRBLKSIZ - 12, DT_DIR, 2, ".." | 123 | 0, DIRBLKSIZ - 12, LFS_DT_DIR, 2, ".." | |
124 | }; | 124 | }; | |
125 | 125 | |||
126 | /* | 126 | /* | |
127 | * Create a regular file | 127 | * Create a regular file | |
128 | */ | 128 | */ | |
129 | int | 129 | int | |
130 | ulfs_create(void *v) | 130 | ulfs_create(void *v) | |
131 | { | 131 | { | |
132 | struct vop_create_args /* { | 132 | struct vop_create_args /* { | |
133 | struct vnode *a_dvp; | 133 | struct vnode *a_dvp; | |
134 | struct vnode **a_vpp; | 134 | struct vnode **a_vpp; | |
135 | struct componentname *a_cnp; | 135 | struct componentname *a_cnp; | |
136 | struct vattr *a_vap; | 136 | struct vattr *a_vap; | |
@@ -816,27 +816,27 @@ ulfs_remove(void *v) | @@ -816,27 +816,27 @@ ulfs_remove(void *v) | |||
816 | */ | 816 | */ | |
817 | int | 817 | int | |
818 | ulfs_link(void *v) | 818 | ulfs_link(void *v) | |
819 | { | 819 | { | |
820 | struct vop_link_args /* { | 820 | struct vop_link_args /* { | |
821 | struct vnode *a_dvp; | 821 | struct vnode *a_dvp; | |
822 | struct vnode *a_vp; | 822 | struct vnode *a_vp; | |
823 | struct componentname *a_cnp; | 823 | struct componentname *a_cnp; | |
824 | } */ *ap = v; | 824 | } */ *ap = v; | |
825 | struct vnode *dvp = ap->a_dvp; | 825 | struct vnode *dvp = ap->a_dvp; | |
826 | struct vnode *vp = ap->a_vp; | 826 | struct vnode *vp = ap->a_vp; | |
827 | struct componentname *cnp = ap->a_cnp; | 827 | struct componentname *cnp = ap->a_cnp; | |
828 | struct inode *ip; | 828 | struct inode *ip; | |
829 | struct direct *newdir; | 829 | struct lfs_direct *newdir; | |
830 | int error; | 830 | int error; | |
831 | struct ulfs_lookup_results *ulr; | 831 | struct ulfs_lookup_results *ulr; | |
832 | 832 | |||
833 | KASSERT(dvp != vp); | 833 | KASSERT(dvp != vp); | |
834 | KASSERT(vp->v_type != VDIR); | 834 | KASSERT(vp->v_type != VDIR); | |
835 | KASSERT(dvp->v_mount == vp->v_mount); | 835 | KASSERT(dvp->v_mount == vp->v_mount); | |
836 | 836 | |||
837 | /* XXX should handle this material another way */ | 837 | /* XXX should handle this material another way */ | |
838 | ulr = &VTOI(dvp)->i_crap; | 838 | ulr = &VTOI(dvp)->i_crap; | |
839 | ULFS_CHECK_CRAPCOUNTER(VTOI(dvp)); | 839 | ULFS_CHECK_CRAPCOUNTER(VTOI(dvp)); | |
840 | 840 | |||
841 | fstrans_start(dvp->v_mount, FSTRANS_SHARED); | 841 | fstrans_start(dvp->v_mount, FSTRANS_SHARED); | |
842 | error = vn_lock(vp, LK_EXCLUSIVE); | 842 | error = vn_lock(vp, LK_EXCLUSIVE); | |
@@ -890,27 +890,27 @@ ulfs_link(void *v) | @@ -890,27 +890,27 @@ ulfs_link(void *v) | |||
890 | /* | 890 | /* | |
891 | * whiteout vnode call | 891 | * whiteout vnode call | |
892 | */ | 892 | */ | |
893 | int | 893 | int | |
894 | ulfs_whiteout(void *v) | 894 | ulfs_whiteout(void *v) | |
895 | { | 895 | { | |
896 | struct vop_whiteout_args /* { | 896 | struct vop_whiteout_args /* { | |
897 | struct vnode *a_dvp; | 897 | struct vnode *a_dvp; | |
898 | struct componentname *a_cnp; | 898 | struct componentname *a_cnp; | |
899 | int a_flags; | 899 | int a_flags; | |
900 | } */ *ap = v; | 900 | } */ *ap = v; | |
901 | struct vnode *dvp = ap->a_dvp; | 901 | struct vnode *dvp = ap->a_dvp; | |
902 | struct componentname *cnp = ap->a_cnp; | 902 | struct componentname *cnp = ap->a_cnp; | |
903 | struct direct *newdir; | 903 | struct lfs_direct *newdir; | |
904 | int error; | 904 | int error; | |
905 | struct ulfsmount *ump = VFSTOULFS(dvp->v_mount); | 905 | struct ulfsmount *ump = VFSTOULFS(dvp->v_mount); | |
906 | struct ulfs_lookup_results *ulr; | 906 | struct ulfs_lookup_results *ulr; | |
907 | 907 | |||
908 | /* XXX should handle this material another way */ | 908 | /* XXX should handle this material another way */ | |
909 | ulr = &VTOI(dvp)->i_crap; | 909 | ulr = &VTOI(dvp)->i_crap; | |
910 | ULFS_CHECK_CRAPCOUNTER(VTOI(dvp)); | 910 | ULFS_CHECK_CRAPCOUNTER(VTOI(dvp)); | |
911 | 911 | |||
912 | error = 0; | 912 | error = 0; | |
913 | switch (ap->a_flags) { | 913 | switch (ap->a_flags) { | |
914 | case LOOKUP: | 914 | case LOOKUP: | |
915 | /* 4.4 format directories support whiteout operations */ | 915 | /* 4.4 format directories support whiteout operations */ | |
916 | if (ump->um_maxsymlinklen > 0) | 916 | if (ump->um_maxsymlinklen > 0) | |
@@ -924,27 +924,27 @@ ulfs_whiteout(void *v) | @@ -924,27 +924,27 @@ ulfs_whiteout(void *v) | |||
924 | if (error) | 924 | if (error) | |
925 | break; | 925 | break; | |
926 | #ifdef DIAGNOSTIC | 926 | #ifdef DIAGNOSTIC | |
927 | if (ump->um_maxsymlinklen <= 0) | 927 | if (ump->um_maxsymlinklen <= 0) | |
928 | panic("ulfs_whiteout: old format filesystem"); | 928 | panic("ulfs_whiteout: old format filesystem"); | |
929 | #endif | 929 | #endif | |
930 | 930 | |||
931 | newdir = pool_cache_get(ulfs_direct_cache, PR_WAITOK); | 931 | newdir = pool_cache_get(ulfs_direct_cache, PR_WAITOK); | |
932 | newdir->d_ino = ULFS_WINO; | 932 | newdir->d_ino = ULFS_WINO; | |
933 | newdir->d_namlen = cnp->cn_namelen; | 933 | newdir->d_namlen = cnp->cn_namelen; | |
934 | memcpy(newdir->d_name, cnp->cn_nameptr, | 934 | memcpy(newdir->d_name, cnp->cn_nameptr, | |
935 | (size_t)cnp->cn_namelen); | 935 | (size_t)cnp->cn_namelen); | |
936 | newdir->d_name[cnp->cn_namelen] = '\0'; | 936 | newdir->d_name[cnp->cn_namelen] = '\0'; | |
937 | newdir->d_type = DT_WHT; | 937 | newdir->d_type = LFS_DT_WHT; | |
938 | error = ulfs_direnter(dvp, ulr, NULL, newdir, cnp, NULL); | 938 | error = ulfs_direnter(dvp, ulr, NULL, newdir, cnp, NULL); | |
939 | pool_cache_put(ulfs_direct_cache, newdir); | 939 | pool_cache_put(ulfs_direct_cache, newdir); | |
940 | break; | 940 | break; | |
941 | 941 | |||
942 | case DELETE: | 942 | case DELETE: | |
943 | /* remove an existing directory whiteout */ | 943 | /* remove an existing directory whiteout */ | |
944 | fstrans_start(dvp->v_mount, FSTRANS_SHARED); | 944 | fstrans_start(dvp->v_mount, FSTRANS_SHARED); | |
945 | error = ULFS_WAPBL_BEGIN(dvp->v_mount); | 945 | error = ULFS_WAPBL_BEGIN(dvp->v_mount); | |
946 | if (error) | 946 | if (error) | |
947 | break; | 947 | break; | |
948 | #ifdef DIAGNOSTIC | 948 | #ifdef DIAGNOSTIC | |
949 | if (ump->um_maxsymlinklen <= 0) | 949 | if (ump->um_maxsymlinklen <= 0) | |
950 | panic("ulfs_whiteout: old format filesystem"); | 950 | panic("ulfs_whiteout: old format filesystem"); | |
@@ -966,28 +966,28 @@ int | @@ -966,28 +966,28 @@ int | |||
966 | ulfs_mkdir(void *v) | 966 | ulfs_mkdir(void *v) | |
967 | { | 967 | { | |
968 | struct vop_mkdir_args /* { | 968 | struct vop_mkdir_args /* { | |
969 | struct vnode *a_dvp; | 969 | struct vnode *a_dvp; | |
970 | struct vnode **a_vpp; | 970 | struct vnode **a_vpp; | |
971 | struct componentname *a_cnp; | 971 | struct componentname *a_cnp; | |
972 | struct vattr *a_vap; | 972 | struct vattr *a_vap; | |
973 | } */ *ap = v; | 973 | } */ *ap = v; | |
974 | struct vnode *dvp = ap->a_dvp, *tvp; | 974 | struct vnode *dvp = ap->a_dvp, *tvp; | |
975 | struct vattr *vap = ap->a_vap; | 975 | struct vattr *vap = ap->a_vap; | |
976 | struct componentname *cnp = ap->a_cnp; | 976 | struct componentname *cnp = ap->a_cnp; | |
977 | struct inode *ip, *dp = VTOI(dvp); | 977 | struct inode *ip, *dp = VTOI(dvp); | |
978 | struct buf *bp; | 978 | struct buf *bp; | |
979 | struct dirtemplate dirtemplate; | 979 | struct lfs_dirtemplate dirtemplate; | |
980 | struct direct *newdir; | 980 | struct lfs_direct *newdir; | |
981 | int error, dmode; | 981 | int error, dmode; | |
982 | struct ulfsmount *ump = dp->i_ump; | 982 | struct ulfsmount *ump = dp->i_ump; | |
983 | int dirblksiz = ump->um_dirblksiz; | 983 | int dirblksiz = ump->um_dirblksiz; | |
984 | struct ulfs_lookup_results *ulr; | 984 | struct ulfs_lookup_results *ulr; | |
985 | 985 | |||
986 | fstrans_start(dvp->v_mount, FSTRANS_SHARED); | 986 | fstrans_start(dvp->v_mount, FSTRANS_SHARED); | |
987 | 987 | |||
988 | /* XXX should handle this material another way */ | 988 | /* XXX should handle this material another way */ | |
989 | ulr = &dp->i_crap; | 989 | ulr = &dp->i_crap; | |
990 | ULFS_CHECK_CRAPCOUNTER(dp); | 990 | ULFS_CHECK_CRAPCOUNTER(dp); | |
991 | 991 | |||
992 | if ((nlink_t)dp->i_nlink >= LINK_MAX) { | 992 | if ((nlink_t)dp->i_nlink >= LINK_MAX) { | |
993 | error = EMLINK; | 993 | error = EMLINK; | |
@@ -1276,42 +1276,42 @@ ulfs_symlink(void *v) | @@ -1276,42 +1276,42 @@ ulfs_symlink(void *v) | |||
1276 | ap->a_cnp->cn_cred, NULL, NULL); | 1276 | ap->a_cnp->cn_cred, NULL, NULL); | |
1277 | ULFS_WAPBL_END1(ap->a_dvp->v_mount, ap->a_dvp); | 1277 | ULFS_WAPBL_END1(ap->a_dvp->v_mount, ap->a_dvp); | |
1278 | if (error) | 1278 | if (error) | |
1279 | vput(vp); | 1279 | vput(vp); | |
1280 | out: | 1280 | out: | |
1281 | fstrans_done(ap->a_dvp->v_mount); | 1281 | fstrans_done(ap->a_dvp->v_mount); | |
1282 | return (error); | 1282 | return (error); | |
1283 | } | 1283 | } | |
1284 | 1284 | |||
1285 | /* | 1285 | /* | |
1286 | * Vnode op for reading directories. | 1286 | * Vnode op for reading directories. | |
1287 | * | 1287 | * | |
1288 | * This routine handles converting from the on-disk directory format | 1288 | * This routine handles converting from the on-disk directory format | |
1289 | * "struct direct" to the in-memory format "struct dirent" as well as | 1289 | * "struct lfs_direct" to the in-memory format "struct dirent" as well as | |
1290 | * byte swapping the entries if necessary. | 1290 | * byte swapping the entries if necessary. | |
1291 | */ | 1291 | */ | |
1292 | int | 1292 | int | |
1293 | ulfs_readdir(void *v) | 1293 | ulfs_readdir(void *v) | |
1294 | { | 1294 | { | |
1295 | struct vop_readdir_args /* { | 1295 | struct vop_readdir_args /* { | |
1296 | struct vnode *a_vp; | 1296 | struct vnode *a_vp; | |
1297 | struct uio *a_uio; | 1297 | struct uio *a_uio; | |
1298 | kauth_cred_t a_cred; | 1298 | kauth_cred_t a_cred; | |
1299 | int *a_eofflag; | 1299 | int *a_eofflag; | |
1300 | off_t **a_cookies; | 1300 | off_t **a_cookies; | |
1301 | int *ncookies; | 1301 | int *ncookies; | |
1302 | } */ *ap = v; | 1302 | } */ *ap = v; | |
1303 | struct vnode *vp = ap->a_vp; | 1303 | struct vnode *vp = ap->a_vp; | |
1304 | struct direct *cdp, *ecdp; | 1304 | struct lfs_direct *cdp, *ecdp; | |
1305 | struct dirent *ndp; | 1305 | struct dirent *ndp; | |
1306 | char *cdbuf, *ndbuf, *endp; | 1306 | char *cdbuf, *ndbuf, *endp; | |
1307 | struct uio auio, *uio; | 1307 | struct uio auio, *uio; | |
1308 | struct iovec aiov; | 1308 | struct iovec aiov; | |
1309 | int error; | 1309 | int error; | |
1310 | size_t count, ccount, rcount, cdbufsz, ndbufsz; | 1310 | size_t count, ccount, rcount, cdbufsz, ndbufsz; | |
1311 | off_t off, *ccp; | 1311 | off_t off, *ccp; | |
1312 | off_t startoff; | 1312 | off_t startoff; | |
1313 | size_t skipbytes; | 1313 | size_t skipbytes; | |
1314 | struct ulfsmount *ump = VFSTOULFS(vp->v_mount); | 1314 | struct ulfsmount *ump = VFSTOULFS(vp->v_mount); | |
1315 | int nswap = ULFS_MPNEEDSWAP(ump); | 1315 | int nswap = ULFS_MPNEEDSWAP(ump); | |
1316 | #if BYTE_ORDER == LITTLE_ENDIAN | 1316 | #if BYTE_ORDER == LITTLE_ENDIAN | |
1317 | int needswap = ump->um_maxsymlinklen <= 0 && nswap == 0; | 1317 | int needswap = ump->um_maxsymlinklen <= 0 && nswap == 0; | |
@@ -1337,28 +1337,28 @@ ulfs_readdir(void *v) | @@ -1337,28 +1337,28 @@ ulfs_readdir(void *v) | |||
1337 | auio.uio_rw = UIO_READ; | 1337 | auio.uio_rw = UIO_READ; | |
1338 | cdbufsz = rcount; | 1338 | cdbufsz = rcount; | |
1339 | cdbuf = kmem_alloc(cdbufsz, KM_SLEEP); | 1339 | cdbuf = kmem_alloc(cdbufsz, KM_SLEEP); | |
1340 | aiov.iov_base = cdbuf; | 1340 | aiov.iov_base = cdbuf; | |
1341 | aiov.iov_len = rcount; | 1341 | aiov.iov_len = rcount; | |
1342 | error = VOP_READ(vp, &auio, 0, ap->a_cred); | 1342 | error = VOP_READ(vp, &auio, 0, ap->a_cred); | |
1343 | if (error != 0) { | 1343 | if (error != 0) { | |
1344 | kmem_free(cdbuf, cdbufsz); | 1344 | kmem_free(cdbuf, cdbufsz); | |
1345 | return error; | 1345 | return error; | |
1346 | } | 1346 | } | |
1347 | 1347 | |||
1348 | rcount -= auio.uio_resid; | 1348 | rcount -= auio.uio_resid; | |
1349 | 1349 | |||
1350 | cdp = (struct direct *)(void *)cdbuf; | 1350 | cdp = (struct lfs_direct *)(void *)cdbuf; | |
1351 | ecdp = (struct direct *)(void *)&cdbuf[rcount]; | 1351 | ecdp = (struct lfs_direct *)(void *)&cdbuf[rcount]; | |
1352 | 1352 | |||
1353 | ndbufsz = count; | 1353 | ndbufsz = count; | |
1354 | ndbuf = kmem_alloc(ndbufsz, KM_SLEEP); | 1354 | ndbuf = kmem_alloc(ndbufsz, KM_SLEEP); | |
1355 | ndp = (struct dirent *)(void *)ndbuf; | 1355 | ndp = (struct dirent *)(void *)ndbuf; | |
1356 | endp = &ndbuf[count]; | 1356 | endp = &ndbuf[count]; | |
1357 | 1357 | |||
1358 | off = uio->uio_offset; | 1358 | off = uio->uio_offset; | |
1359 | if (ap->a_cookies) { | 1359 | if (ap->a_cookies) { | |
1360 | ccount = rcount / _DIRENT_RECLEN(cdp, 1); | 1360 | ccount = rcount / _DIRENT_RECLEN(cdp, 1); | |
1361 | ccp = *(ap->a_cookies) = malloc(ccount * sizeof(*ccp), | 1361 | ccp = *(ap->a_cookies) = malloc(ccount * sizeof(*ccp), | |
1362 | M_TEMP, M_WAITOK); | 1362 | M_TEMP, M_WAITOK); | |
1363 | } else { | 1363 | } else { | |
1364 | /* XXX: GCC */ | 1364 | /* XXX: GCC */ | |
@@ -1796,27 +1796,27 @@ ulfs_vinit(struct mount *mntp, int (**sp | @@ -1796,27 +1796,27 @@ ulfs_vinit(struct mount *mntp, int (**sp | |||
1796 | ip->i_modrev = (uint64_t)(uint)tv.tv_sec << 32 | 1796 | ip->i_modrev = (uint64_t)(uint)tv.tv_sec << 32 | |
1797 | | tv.tv_usec * 4294u; | 1797 | | tv.tv_usec * 4294u; | |
1798 | *vpp = vp; | 1798 | *vpp = vp; | |
1799 | } | 1799 | } | |
1800 | 1800 | |||
1801 | /* | 1801 | /* | |
1802 | * Allocate a new inode. | 1802 | * Allocate a new inode. | |
1803 | */ | 1803 | */ | |
1804 | int | 1804 | int | |
1805 | ulfs_makeinode(int mode, struct vnode *dvp, const struct ulfs_lookup_results *ulr, | 1805 | ulfs_makeinode(int mode, struct vnode *dvp, const struct ulfs_lookup_results *ulr, | |
1806 | struct vnode **vpp, struct componentname *cnp) | 1806 | struct vnode **vpp, struct componentname *cnp) | |
1807 | { | 1807 | { | |
1808 | struct inode *ip, *pdir; | 1808 | struct inode *ip, *pdir; | |
1809 | struct direct *newdir; | 1809 | struct lfs_direct *newdir; | |
1810 | struct vnode *tvp; | 1810 | struct vnode *tvp; | |
1811 | int error; | 1811 | int error; | |
1812 | 1812 | |||
1813 | ULFS_WAPBL_JUNLOCK_ASSERT(dvp->v_mount); | 1813 | ULFS_WAPBL_JUNLOCK_ASSERT(dvp->v_mount); | |
1814 | 1814 | |||
1815 | pdir = VTOI(dvp); | 1815 | pdir = VTOI(dvp); | |
1816 | 1816 | |||
1817 | if ((mode & LFS_IFMT) == 0) | 1817 | if ((mode & LFS_IFMT) == 0) | |
1818 | mode |= LFS_IFREG; | 1818 | mode |= LFS_IFREG; | |
1819 | 1819 | |||
1820 | if ((error = ULFS_VALLOC(dvp, mode, cnp->cn_cred, vpp)) != 0) { | 1820 | if ((error = ULFS_VALLOC(dvp, mode, cnp->cn_cred, vpp)) != 0) { | |
1821 | vput(dvp); | 1821 | vput(dvp); | |
1822 | return (error); | 1822 | return (error); |
--- src/sys/ufs/lfs/Attic/ulfs_dir.h 2013/06/08 02:04:31 1.4
+++ src/sys/ufs/lfs/Attic/ulfs_dir.h 2013/06/08 02:12:56 1.5
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ulfs_dir.h,v 1.4 2013/06/08 02:04:31 dholland Exp $ */ | 1 | /* $NetBSD: ulfs_dir.h,v 1.5 2013/06/08 02:12:56 dholland Exp $ */ | |
2 | /* from NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp */ | 2 | /* from NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 1982, 1986, 1989, 1993 | 5 | * Copyright (c) 1982, 1986, 1989, 1993 | |
6 | * The Regents of the University of California. All rights reserved. | 6 | * The Regents of the University of California. All rights reserved. | |
7 | * (c) UNIX System Laboratories, Inc. | 7 | * (c) UNIX System Laboratories, Inc. | |
8 | * All or some portions of this file are derived from material licensed | 8 | * All or some portions of this file are derived from material licensed | |
9 | * to the University of California by American Telephone and Telegraph | 9 | * to the University of California by American Telephone and Telegraph | |
10 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | 10 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | |
11 | * the permission of UNIX System Laboratories, Inc. | 11 | * the permission of UNIX System Laboratories, Inc. | |
12 | * | 12 | * | |
13 | * Redistribution and use in source and binary forms, with or without | 13 | * Redistribution and use in source and binary forms, with or without | |
14 | * modification, are permitted provided that the following conditions | 14 | * modification, are permitted provided that the following conditions | |
@@ -37,116 +37,116 @@ | @@ -37,116 +37,116 @@ | |||
37 | * @(#)dir.h 8.5 (Berkeley) 4/27/95 | 37 | * @(#)dir.h 8.5 (Berkeley) 4/27/95 | |
38 | */ | 38 | */ | |
39 | 39 | |||
40 | #ifndef _UFS_LFS_ULFS_DIR_H_ | 40 | #ifndef _UFS_LFS_ULFS_DIR_H_ | |
41 | #define _UFS_LFS_ULFS_DIR_H_ | 41 | #define _UFS_LFS_ULFS_DIR_H_ | |
42 | 42 | |||
43 | /* | 43 | /* | |
44 | * A directory consists of some number of blocks of DIRBLKSIZ | 44 | * A directory consists of some number of blocks of DIRBLKSIZ | |
45 | * bytes, where DIRBLKSIZ is chosen such that it can be transferred | 45 | * bytes, where DIRBLKSIZ is chosen such that it can be transferred | |
46 | * to disk in a single atomic operation (e.g. 512 bytes on most machines). | 46 | * to disk in a single atomic operation (e.g. 512 bytes on most machines). | |
47 | * | 47 | * | |
48 | * Each DIRBLKSIZ byte block contains some number of directory entry | 48 | * Each DIRBLKSIZ byte block contains some number of directory entry | |
49 | * structures, which are of variable length. Each directory entry has | 49 | * structures, which are of variable length. Each directory entry has | |
50 | * a struct direct at the front of it, containing its inode number, | 50 | * a struct lfs_direct at the front of it, containing its inode number, | |
51 | * the length of the entry, and the length of the name contained in | 51 | * the length of the entry, and the length of the name contained in | |
52 | * the entry. These are followed by the name padded to a 4 byte boundary. | 52 | * the entry. These are followed by the name padded to a 4 byte boundary. | |
53 | * All names are guaranteed null terminated. | 53 | * All names are guaranteed null terminated. | |
54 | * The maximum length of a name in a directory is FFS_MAXNAMLEN. | 54 | * The maximum length of a name in a directory is FFS_MAXNAMLEN. | |
55 | * | 55 | * | |
56 | * The macro DIRSIZ(fmt, dp) gives the amount of space required to represent | 56 | * The macro DIRSIZ(fmt, dp) gives the amount of space required to represent | |
57 | * a directory entry. Free space in a directory is represented by | 57 | * a directory entry. Free space in a directory is represented by | |
58 | * entries which have dp->d_reclen > DIRSIZ(fmt, dp). All DIRBLKSIZ bytes | 58 | * entries which have dp->d_reclen > DIRSIZ(fmt, dp). All DIRBLKSIZ bytes | |
59 | * in a directory block are claimed by the directory entries. This | 59 | * in a directory block are claimed by the directory entries. This | |
60 | * usually results in the last entry in a directory having a large | 60 | * usually results in the last entry in a directory having a large | |
61 | * dp->d_reclen. When entries are deleted from a directory, the | 61 | * dp->d_reclen. When entries are deleted from a directory, the | |
62 | * space is returned to the previous entry in the same directory | 62 | * space is returned to the previous entry in the same directory | |
63 | * block by increasing its dp->d_reclen. If the first entry of | 63 | * block by increasing its dp->d_reclen. If the first entry of | |
64 | * a directory block is free, then its dp->d_ino is set to 0. | 64 | * a directory block is free, then its dp->d_ino is set to 0. | |
65 | * Entries other than the first in a directory do not normally have | 65 | * Entries other than the first in a directory do not normally have | |
66 | * dp->d_ino set to 0. | 66 | * dp->d_ino set to 0. | |
67 | */ | 67 | */ | |
68 | #undef DIRBLKSIZ | 68 | #undef DIRBLKSIZ | |
69 | #define DIRBLKSIZ DEV_BSIZE | 69 | #define DIRBLKSIZ DEV_BSIZE | |
70 | #define FFS_MAXNAMLEN 255 | 70 | #define FFS_MAXNAMLEN 255 | |
71 | 71 | |||
72 | #define d_ino d_fileno | 72 | #define d_ino d_fileno | |
73 | struct direct { | 73 | struct lfs_direct { | |
74 | u_int32_t d_fileno; /* inode number of entry */ | 74 | u_int32_t d_fileno; /* inode number of entry */ | |
75 | u_int16_t d_reclen; /* length of this record */ | 75 | u_int16_t d_reclen; /* length of this record */ | |
76 | u_int8_t d_type; /* file type, see below */ | 76 | u_int8_t d_type; /* file type, see below */ | |
77 | u_int8_t d_namlen; /* length of string in d_name */ | 77 | u_int8_t d_namlen; /* length of string in d_name */ | |
78 | char d_name[FFS_MAXNAMLEN + 1];/* name with length <= FFS_MAXNAMLEN */ | 78 | char d_name[FFS_MAXNAMLEN + 1];/* name with length <= FFS_MAXNAMLEN */ | |
79 | }; | 79 | }; | |
80 | 80 | |||
81 | /* | 81 | /* | |
82 | * File types | 82 | * File types | |
83 | */ | 83 | */ | |
84 | #define DT_UNKNOWN 0 | 84 | #define LFS_DT_UNKNOWN 0 | |
85 | #define DT_FIFO 1 | 85 | #define LFS_DT_FIFO 1 | |
86 | #define DT_CHR 2 | 86 | #define LFS_DT_CHR 2 | |
87 | #define DT_DIR 4 | 87 | #define LFS_DT_DIR 4 | |
88 | #define DT_BLK 6 | 88 | #define LFS_DT_BLK 6 | |
89 | #define DT_REG 8 | 89 | #define LFS_DT_REG 8 | |
90 | #define DT_LNK 10 | 90 | #define LFS_DT_LNK 10 | |
91 | #define DT_SOCK 12 | 91 | #define LFS_DT_SOCK 12 | |
92 | #define DT_WHT 14 | 92 | #define LFS_DT_WHT 14 | |
93 | 93 | |||
94 | /* | 94 | /* | |
95 | * Convert between stat structure types and directory types. | 95 | * Convert between stat structure types and directory types. | |
96 | */ | 96 | */ | |
97 | #define IFTODT(mode) (((mode) & 0170000) >> 12) | 97 | #define IFTODT(mode) (((mode) & 0170000) >> 12) | |
98 | #define DTTOIF(dirtype) ((dirtype) << 12) | 98 | #define DTTOIF(dirtype) ((dirtype) << 12) | |
99 | 99 | |||
100 | /* | 100 | /* | |
101 | * The DIRSIZ macro gives the minimum record length which will hold | 101 | * The DIRSIZ macro gives the minimum record length which will hold | |
102 | * the directory entry. This requires the amount of space in struct direct | 102 | * the directory entry. This requires the amount of space in struct lfs_direct | |
103 | * without the d_name field, plus enough space for the name with a terminating | 103 | * without the d_name field, plus enough space for the name with a terminating | |
104 | * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. | 104 | * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. | |
105 | */ | 105 | */ | |
106 | #define DIRECTSIZ(namlen) \ | 106 | #define DIRECTSIZ(namlen) \ | |
107 | ((sizeof(struct direct) - (FFS_MAXNAMLEN+1)) + (((namlen)+1 + 3) &~ 3)) | 107 | ((sizeof(struct lfs_direct) - (FFS_MAXNAMLEN+1)) + (((namlen)+1 + 3) &~ 3)) | |
108 | 108 | |||
109 | #if (BYTE_ORDER == LITTLE_ENDIAN) | 109 | #if (BYTE_ORDER == LITTLE_ENDIAN) | |
110 | #define DIRSIZ(oldfmt, dp, needswap) \ | 110 | #define DIRSIZ(oldfmt, dp, needswap) \ | |
111 | (((oldfmt) && !(needswap)) ? \ | 111 | (((oldfmt) && !(needswap)) ? \ | |
112 | DIRECTSIZ((dp)->d_type) : DIRECTSIZ((dp)->d_namlen)) | 112 | DIRECTSIZ((dp)->d_type) : DIRECTSIZ((dp)->d_namlen)) | |
113 | #else | 113 | #else | |
114 | #define DIRSIZ(oldfmt, dp, needswap) \ | 114 | #define DIRSIZ(oldfmt, dp, needswap) \ | |
115 | (((oldfmt) && (needswap)) ? \ | 115 | (((oldfmt) && (needswap)) ? \ | |
116 | DIRECTSIZ((dp)->d_type) : DIRECTSIZ((dp)->d_namlen)) | 116 | DIRECTSIZ((dp)->d_type) : DIRECTSIZ((dp)->d_namlen)) | |
117 | #endif | 117 | #endif | |
118 | 118 | |||
119 | #define OLDDIRFMT 1 | 119 | #define OLDDIRFMT 1 | |
120 | #define NEWDIRFMT 0 | 120 | #define NEWDIRFMT 0 | |
121 | 121 | |||
122 | /* | 122 | /* | |
123 | * Template for manipulating directories. Should use struct direct's, | 123 | * Template for manipulating directories. Should use struct direct's, | |
124 | * but the name field is FFS_MAXNAMLEN - 1, and this just won't do. | 124 | * but the name field is FFS_MAXNAMLEN - 1, and this just won't do. | |
125 | */ | 125 | */ | |
126 | struct dirtemplate { | 126 | struct lfs_dirtemplate { | |
127 | u_int32_t dot_ino; | 127 | u_int32_t dot_ino; | |
128 | int16_t dot_reclen; | 128 | int16_t dot_reclen; | |
129 | u_int8_t dot_type; | 129 | u_int8_t dot_type; | |
130 | u_int8_t dot_namlen; | 130 | u_int8_t dot_namlen; | |
131 | char dot_name[4]; /* must be multiple of 4 */ | 131 | char dot_name[4]; /* must be multiple of 4 */ | |
132 | u_int32_t dotdot_ino; | 132 | u_int32_t dotdot_ino; | |
133 | int16_t dotdot_reclen; | 133 | int16_t dotdot_reclen; | |
134 | u_int8_t dotdot_type; | 134 | u_int8_t dotdot_type; | |
135 | u_int8_t dotdot_namlen; | 135 | u_int8_t dotdot_namlen; | |
136 | char dotdot_name[4]; /* ditto */ | 136 | char dotdot_name[4]; /* ditto */ | |
137 | }; | 137 | }; | |
138 | 138 | |||
139 | /* | 139 | /* | |
140 | * This is the old format of directories, sanz type element. | 140 | * This is the old format of directories, sanz type element. | |
141 | */ | 141 | */ | |
142 | struct odirtemplate { | 142 | struct lfs_odirtemplate { | |
143 | u_int32_t dot_ino; | 143 | u_int32_t dot_ino; | |
144 | int16_t dot_reclen; | 144 | int16_t dot_reclen; | |
145 | u_int16_t dot_namlen; | 145 | u_int16_t dot_namlen; | |
146 | char dot_name[4]; /* must be multiple of 4 */ | 146 | char dot_name[4]; /* must be multiple of 4 */ | |
147 | u_int32_t dotdot_ino; | 147 | u_int32_t dotdot_ino; | |
148 | int16_t dotdot_reclen; | 148 | int16_t dotdot_reclen; | |
149 | u_int16_t dotdot_namlen; | 149 | u_int16_t dotdot_namlen; | |
150 | char dotdot_name[4]; /* ditto */ | 150 | char dotdot_name[4]; /* ditto */ | |
151 | }; | 151 | }; | |
152 | #endif /* !_UFS_LFS_ULFS_DIR_H_ */ | 152 | #endif /* !_UFS_LFS_ULFS_DIR_H_ */ |
--- src/sys/ufs/lfs/Attic/ulfs_rename.c 2013/06/08 02:11:11 1.4
+++ src/sys/ufs/lfs/Attic/ulfs_rename.c 2013/06/08 02:12:56 1.5
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ulfs_rename.c,v 1.4 2013/06/08 02:11:11 dholland Exp $ */ | 1 | /* $NetBSD: ulfs_rename.c,v 1.5 2013/06/08 02:12:56 dholland Exp $ */ | |
2 | /* from NetBSD: ufs_rename.c,v 1.6 2013/01/22 09:39:18 dholland Exp */ | 2 | /* from NetBSD: ufs_rename.c,v 1.6 2013/01/22 09:39:18 dholland Exp */ | |
3 | 3 | |||
4 | /*- | 4 | /*- | |
5 | * Copyright (c) 2012 The NetBSD Foundation, Inc. | 5 | * Copyright (c) 2012 The NetBSD Foundation, Inc. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * This code is derived from software contributed to The NetBSD Foundation | 8 | * This code is derived from software contributed to The NetBSD Foundation | |
9 | * by Taylor R Campbell. | 9 | * by Taylor R Campbell. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | 30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | /* | 33 | /* | |
34 | * ULFS Rename | 34 | * ULFS Rename | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | __KERNEL_RCSID(0, "$NetBSD: ulfs_rename.c,v 1.4 2013/06/08 02:11:11 dholland Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: ulfs_rename.c,v 1.5 2013/06/08 02:12:56 dholland Exp $"); | |
39 | 39 | |||
40 | #include <sys/param.h> | 40 | #include <sys/param.h> | |
41 | #include <sys/buf.h> | 41 | #include <sys/buf.h> | |
42 | #include <sys/errno.h> | 42 | #include <sys/errno.h> | |
43 | #include <sys/fstrans.h> | 43 | #include <sys/fstrans.h> | |
44 | #include <sys/kauth.h> | 44 | #include <sys/kauth.h> | |
45 | #include <sys/mount.h> | 45 | #include <sys/mount.h> | |
46 | #include <sys/namei.h> | 46 | #include <sys/namei.h> | |
47 | #include <sys/pool.h> | 47 | #include <sys/pool.h> | |
48 | #include <sys/vnode.h> | 48 | #include <sys/vnode.h> | |
49 | #include <sys/vnode_if.h> | 49 | #include <sys/vnode_if.h> | |
50 | #include <sys/wapbl.h> | 50 | #include <sys/wapbl.h> | |
51 | 51 | |||
@@ -60,29 +60,29 @@ __KERNEL_RCSID(0, "$NetBSD: ulfs_rename. | @@ -60,29 +60,29 @@ __KERNEL_RCSID(0, "$NetBSD: ulfs_rename. | |||
60 | 60 | |||
61 | /* | 61 | /* | |
62 | * Forward declarations | 62 | * Forward declarations | |
63 | */ | 63 | */ | |
64 | 64 | |||
65 | static int ulfs_sane_rename(struct vnode *, struct componentname *, | 65 | static int ulfs_sane_rename(struct vnode *, struct componentname *, | |
66 | struct vnode *, struct componentname *, | 66 | struct vnode *, struct componentname *, | |
67 | kauth_cred_t, bool); | 67 | kauth_cred_t, bool); | |
68 | static bool ulfs_rename_ulr_overlap_p(const struct ulfs_lookup_results *, | 68 | static bool ulfs_rename_ulr_overlap_p(const struct ulfs_lookup_results *, | |
69 | const struct ulfs_lookup_results *); | 69 | const struct ulfs_lookup_results *); | |
70 | static int ulfs_rename_recalculate_fulr(struct vnode *, | 70 | static int ulfs_rename_recalculate_fulr(struct vnode *, | |
71 | struct ulfs_lookup_results *, const struct ulfs_lookup_results *, | 71 | struct ulfs_lookup_results *, const struct ulfs_lookup_results *, | |
72 | const struct componentname *); | 72 | const struct componentname *); | |
73 | static int ulfs_direct_namlen(const struct direct *, const struct vnode *); | 73 | static int ulfs_direct_namlen(const struct lfs_direct *, const struct vnode *); | |
74 | static int ulfs_read_dotdot(struct vnode *, kauth_cred_t, ino_t *); | 74 | static int ulfs_read_dotdot(struct vnode *, kauth_cred_t, ino_t *); | |
75 | static int ulfs_dirbuf_dotdot_namlen(const struct dirtemplate *, | 75 | static int ulfs_dirbuf_dotdot_namlen(const struct lfs_dirtemplate *, | |
76 | const struct vnode *); | 76 | const struct vnode *); | |
77 | 77 | |||
78 | static const struct genfs_rename_ops ulfs_genfs_rename_ops; | 78 | static const struct genfs_rename_ops ulfs_genfs_rename_ops; | |
79 | 79 | |||
80 | /* | 80 | /* | |
81 | * ulfs_sane_rename: The hairiest vop, with the saner API. | 81 | * ulfs_sane_rename: The hairiest vop, with the saner API. | |
82 | * | 82 | * | |
83 | * Arguments: | 83 | * Arguments: | |
84 | * | 84 | * | |
85 | * . fdvp (from directory vnode), | 85 | * . fdvp (from directory vnode), | |
86 | * . fcnp (from component name), | 86 | * . fcnp (from component name), | |
87 | * . tdvp (to directory vnode), | 87 | * . tdvp (to directory vnode), | |
88 | * . tcnp (to component name), | 88 | * . tcnp (to component name), | |
@@ -261,45 +261,45 @@ ulfs_gro_remove_check_permitted(struct m | @@ -261,45 +261,45 @@ ulfs_gro_remove_check_permitted(struct m | |||
261 | KASSERT(vp->v_mount == mp); | 261 | KASSERT(vp->v_mount == mp); | |
262 | KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE); | 262 | KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE); | |
263 | KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE); | 263 | KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE); | |
264 | 264 | |||
265 | return genfs_ufslike_remove_check_permitted(cred, | 265 | return genfs_ufslike_remove_check_permitted(cred, | |
266 | dvp, VTOI(dvp)->i_mode, VTOI(dvp)->i_uid, vp, VTOI(vp)->i_uid); | 266 | dvp, VTOI(dvp)->i_mode, VTOI(dvp)->i_uid, vp, VTOI(vp)->i_uid); | |
267 | } | 267 | } | |
268 | 268 | |||
269 | /* | 269 | /* | |
270 | * A virgin directory (no blushing please). | 270 | * A virgin directory (no blushing please). | |
271 | * | 271 | * | |
272 | * XXX Copypasta from ulfs_vnops.c. Kill! | 272 | * XXX Copypasta from ulfs_vnops.c. Kill! | |
273 | */ | 273 | */ | |
274 | static const struct dirtemplate mastertemplate = { | 274 | static const struct lfs_dirtemplate mastertemplate = { | |
275 | 0, 12, DT_DIR, 1, ".", | 275 | 0, 12, LFS_DT_DIR, 1, ".", | |
276 | 0, DIRBLKSIZ - 12, DT_DIR, 2, ".." | 276 | 0, DIRBLKSIZ - 12, LFS_DT_DIR, 2, ".." | |
277 | }; | 277 | }; | |
278 | 278 | |||
279 | /* | 279 | /* | |
280 | * ulfs_gro_rename: Actually perform the rename operation. | 280 | * ulfs_gro_rename: Actually perform the rename operation. | |
281 | */ | 281 | */ | |
282 | int | 282 | int | |
283 | ulfs_gro_rename(struct mount *mp, kauth_cred_t cred, | 283 | ulfs_gro_rename(struct mount *mp, kauth_cred_t cred, | |
284 | struct vnode *fdvp, struct componentname *fcnp, | 284 | struct vnode *fdvp, struct componentname *fcnp, | |
285 | void *fde, struct vnode *fvp, | 285 | void *fde, struct vnode *fvp, | |
286 | struct vnode *tdvp, struct componentname *tcnp, | 286 | struct vnode *tdvp, struct componentname *tcnp, | |
287 | void *tde, struct vnode *tvp) | 287 | void *tde, struct vnode *tvp) | |
288 | { | 288 | { | |
289 | struct ulfs_lookup_results *fulr = fde; | 289 | struct ulfs_lookup_results *fulr = fde; | |
290 | struct ulfs_lookup_results *tulr = tde; | 290 | struct ulfs_lookup_results *tulr = tde; | |
291 | bool directory_p, reparent_p; | 291 | bool directory_p, reparent_p; | |
292 | struct direct *newdir; | 292 | struct lfs_direct *newdir; | |
293 | int error; | 293 | int error; | |
294 | 294 | |||
295 | KASSERT(mp != NULL); | 295 | KASSERT(mp != NULL); | |
296 | KASSERT(fdvp != NULL); | 296 | KASSERT(fdvp != NULL); | |
297 | KASSERT(fcnp != NULL); | 297 | KASSERT(fcnp != NULL); | |
298 | KASSERT(fulr != NULL); | 298 | KASSERT(fulr != NULL); | |
299 | KASSERT(fvp != NULL); | 299 | KASSERT(fvp != NULL); | |
300 | KASSERT(tdvp != NULL); | 300 | KASSERT(tdvp != NULL); | |
301 | KASSERT(tcnp != NULL); | 301 | KASSERT(tcnp != NULL); | |
302 | KASSERT(tulr != NULL); | 302 | KASSERT(tulr != NULL); | |
303 | KASSERT(fulr != tulr); | 303 | KASSERT(fulr != tulr); | |
304 | KASSERT(fdvp != fvp); | 304 | KASSERT(fdvp != fvp); | |
305 | KASSERT(fdvp != tvp); | 305 | KASSERT(fdvp != tvp); | |
@@ -478,27 +478,27 @@ ulfs_gro_rename(struct mount *mp, kauth_ | @@ -478,27 +478,27 @@ ulfs_gro_rename(struct mount *mp, kauth_ | |||
478 | } | 478 | } | |
479 | } | 479 | } | |
480 | 480 | |||
481 | /* | 481 | /* | |
482 | * If the source is a directory with a new parent, the link | 482 | * If the source is a directory with a new parent, the link | |
483 | * count of the old parent directory must be decremented and | 483 | * count of the old parent directory must be decremented and | |
484 | * ".." set to point to the new parent. | 484 | * ".." set to point to the new parent. | |
485 | * | 485 | * | |
486 | * XXX ulfs_dirrewrite updates the link count of fdvp, but not | 486 | * XXX ulfs_dirrewrite updates the link count of fdvp, but not | |
487 | * the link count of fvp or the link count of tdvp. Go figure. | 487 | * the link count of fvp or the link count of tdvp. Go figure. | |
488 | */ | 488 | */ | |
489 | if (directory_p && reparent_p) { | 489 | if (directory_p && reparent_p) { | |
490 | error = ulfs_dirrewrite(VTOI(fvp), mastertemplate.dot_reclen, | 490 | error = ulfs_dirrewrite(VTOI(fvp), mastertemplate.dot_reclen, | |
491 | VTOI(fdvp), VTOI(tdvp)->i_number, DT_DIR, 0, IN_CHANGE); | 491 | VTOI(fdvp), VTOI(tdvp)->i_number, LFS_DT_DIR, 0, IN_CHANGE); | |
492 | #if 0 /* XXX This branch was not in ulfs_rename! */ | 492 | #if 0 /* XXX This branch was not in ulfs_rename! */ | |
493 | if (error) | 493 | if (error) | |
494 | goto whymustithurtsomuch; | 494 | goto whymustithurtsomuch; | |
495 | #endif | 495 | #endif | |
496 | 496 | |||
497 | /* XXX WTF? Why purge here? Why not purge others? */ | 497 | /* XXX WTF? Why purge here? Why not purge others? */ | |
498 | cache_purge(fdvp); | 498 | cache_purge(fdvp); | |
499 | } | 499 | } | |
500 | 500 | |||
501 | /* | 501 | /* | |
502 | * 3) Unlink the source. | 502 | * 3) Unlink the source. | |
503 | */ | 503 | */ | |
504 | 504 | |||
@@ -604,27 +604,27 @@ static int | @@ -604,27 +604,27 @@ static int | |||
604 | ulfs_rename_recalculate_fulr(struct vnode *dvp, | 604 | ulfs_rename_recalculate_fulr(struct vnode *dvp, | |
605 | struct ulfs_lookup_results *fulr, const struct ulfs_lookup_results *tulr, | 605 | struct ulfs_lookup_results *fulr, const struct ulfs_lookup_results *tulr, | |
606 | const struct componentname *fcnp) | 606 | const struct componentname *fcnp) | |
607 | { | 607 | { | |
608 | struct mount *mp; | 608 | struct mount *mp; | |
609 | struct ulfsmount *ump; | 609 | struct ulfsmount *ump; | |
610 | int needswap; | 610 | int needswap; | |
611 | /* XXX int is a silly type for this; blame ulfsmount::um_dirblksiz. */ | 611 | /* XXX int is a silly type for this; blame ulfsmount::um_dirblksiz. */ | |
612 | int dirblksiz; | 612 | int dirblksiz; | |
613 | doff_t search_start, search_end; | 613 | doff_t search_start, search_end; | |
614 | doff_t offset; /* Offset of entry we're examining. */ | 614 | doff_t offset; /* Offset of entry we're examining. */ | |
615 | struct buf *bp; /* I/O block we're examining. */ | 615 | struct buf *bp; /* I/O block we're examining. */ | |
616 | char *dirbuf; /* Pointer into directory at search_start. */ | 616 | char *dirbuf; /* Pointer into directory at search_start. */ | |
617 | struct direct *ep; /* Pointer to the entry we're examining. */ | 617 | struct lfs_direct *ep; /* Pointer to the entry we're examining. */ | |
618 | /* XXX direct::d_reclen is 16-bit; | 618 | /* XXX direct::d_reclen is 16-bit; | |
619 | * ulfs_lookup_results::ulr_reclen is 32-bit. Blah. */ | 619 | * ulfs_lookup_results::ulr_reclen is 32-bit. Blah. */ | |
620 | uint32_t reclen; /* Length of the entry we're examining. */ | 620 | uint32_t reclen; /* Length of the entry we're examining. */ | |
621 | uint32_t prev_reclen; /* Length of the preceding entry. */ | 621 | uint32_t prev_reclen; /* Length of the preceding entry. */ | |
622 | int error; | 622 | int error; | |
623 | 623 | |||
624 | KASSERT(dvp != NULL); | 624 | KASSERT(dvp != NULL); | |
625 | KASSERT(dvp->v_mount != NULL); | 625 | KASSERT(dvp->v_mount != NULL); | |
626 | KASSERT(VTOI(dvp) != NULL); | 626 | KASSERT(VTOI(dvp) != NULL); | |
627 | KASSERT(fulr != NULL); | 627 | KASSERT(fulr != NULL); | |
628 | KASSERT(tulr != NULL); | 628 | KASSERT(tulr != NULL); | |
629 | KASSERT(fulr != tulr); | 629 | KASSERT(fulr != tulr); | |
630 | KASSERT(ulfs_rename_ulr_overlap_p(fulr, tulr)); | 630 | KASSERT(ulfs_rename_ulr_overlap_p(fulr, tulr)); | |
@@ -673,27 +673,27 @@ ulfs_rename_recalculate_fulr(struct vnod | @@ -673,27 +673,27 @@ ulfs_rename_recalculate_fulr(struct vnod | |||
673 | 673 | |||
674 | /* | 674 | /* | |
675 | * Search from search_start to search_end for the entry matching | 675 | * Search from search_start to search_end for the entry matching | |
676 | * fcnp, which must be there because we found it before and it | 676 | * fcnp, which must be there because we found it before and it | |
677 | * should only at most have moved earlier. | 677 | * should only at most have moved earlier. | |
678 | */ | 678 | */ | |
679 | for (;;) { | 679 | for (;;) { | |
680 | KASSERT(search_start <= offset); | 680 | KASSERT(search_start <= offset); | |
681 | KASSERT(offset < search_end); | 681 | KASSERT(offset < search_end); | |
682 | 682 | |||
683 | /* | 683 | /* | |
684 | * Examine the directory entry at offset. | 684 | * Examine the directory entry at offset. | |
685 | */ | 685 | */ | |
686 | ep = (struct direct *)(dirbuf + (offset - search_start)); | 686 | ep = (struct lfs_direct *)(dirbuf + (offset - search_start)); | |
687 | reclen = ulfs_rw16(ep->d_reclen, needswap); | 687 | reclen = ulfs_rw16(ep->d_reclen, needswap); | |
688 | 688 | |||
689 | if (ep->d_ino == 0) | 689 | if (ep->d_ino == 0) | |
690 | goto next; /* Entry is unused. */ | 690 | goto next; /* Entry is unused. */ | |
691 | 691 | |||
692 | if (ulfs_rw32(ep->d_ino, needswap) == ULFS_WINO) | 692 | if (ulfs_rw32(ep->d_ino, needswap) == ULFS_WINO) | |
693 | goto next; /* Entry is whiteout. */ | 693 | goto next; /* Entry is whiteout. */ | |
694 | 694 | |||
695 | if (fcnp->cn_namelen != ulfs_direct_namlen(ep, dvp)) | 695 | if (fcnp->cn_namelen != ulfs_direct_namlen(ep, dvp)) | |
696 | goto next; /* Wrong name length. */ | 696 | goto next; /* Wrong name length. */ | |
697 | 697 | |||
698 | if (memcmp(ep->d_name, fcnp->cn_nameptr, fcnp->cn_namelen)) | 698 | if (memcmp(ep->d_name, fcnp->cn_nameptr, fcnp->cn_namelen)) | |
699 | goto next; /* Wrong name. */ | 699 | goto next; /* Wrong name. */ | |
@@ -734,27 +734,27 @@ next: | @@ -734,27 +734,27 @@ next: | |||
734 | * start of a directory block. | 734 | * start of a directory block. | |
735 | */ | 735 | */ | |
736 | fulr->ulr_count = ((offset & (dirblksiz - 1))? prev_reclen : 0); | 736 | fulr->ulr_count = ((offset & (dirblksiz - 1))? prev_reclen : 0); | |
737 | 737 | |||
738 | brelse(bp, 0); | 738 | brelse(bp, 0); | |
739 | return 0; | 739 | return 0; | |
740 | } | 740 | } | |
741 | 741 | |||
742 | /* | 742 | /* | |
743 | * ulfs_direct_namlen: Return the namlen of the directory entry ep from | 743 | * ulfs_direct_namlen: Return the namlen of the directory entry ep from | |
744 | * the directory vp. | 744 | * the directory vp. | |
745 | */ | 745 | */ | |
746 | static int /* XXX int? uint8_t? */ | 746 | static int /* XXX int? uint8_t? */ | |
747 | ulfs_direct_namlen(const struct direct *ep, const struct vnode *vp) | 747 | ulfs_direct_namlen(const struct lfs_direct *ep, const struct vnode *vp) | |
748 | { | 748 | { | |
749 | bool swap; | 749 | bool swap; | |
750 | 750 | |||
751 | KASSERT(ep != NULL); | 751 | KASSERT(ep != NULL); | |
752 | KASSERT(vp != NULL); | 752 | KASSERT(vp != NULL); | |
753 | KASSERT(VTOI(vp) != NULL); | 753 | KASSERT(VTOI(vp) != NULL); | |
754 | KASSERT(VTOI(vp)->i_ump != NULL); | 754 | KASSERT(VTOI(vp)->i_ump != NULL); | |
755 | 755 | |||
756 | #if (BYTE_ORDER == LITTLE_ENDIAN) | 756 | #if (BYTE_ORDER == LITTLE_ENDIAN) | |
757 | swap = (ULFS_MPNEEDSWAP(VTOI(vp)->i_ump) == 0); | 757 | swap = (ULFS_MPNEEDSWAP(VTOI(vp)->i_ump) == 0); | |
758 | #else | 758 | #else | |
759 | swap = (ULFS_MPNEEDSWAP(VTOI(vp)->i_ump) != 0); | 759 | swap = (ULFS_MPNEEDSWAP(VTOI(vp)->i_ump) != 0); | |
760 | #endif | 760 | #endif | |
@@ -862,27 +862,27 @@ ulfs_rmdired_p(struct vnode *vp) | @@ -862,27 +862,27 @@ ulfs_rmdired_p(struct vnode *vp) | |||
862 | KASSERT(vp->v_type == VDIR); | 862 | KASSERT(vp->v_type == VDIR); | |
863 | 863 | |||
864 | /* XXX Is this correct? */ | 864 | /* XXX Is this correct? */ | |
865 | return (VTOI(vp)->i_size == 0); | 865 | return (VTOI(vp)->i_size == 0); | |
866 | } | 866 | } | |
867 | 867 | |||
868 | /* | 868 | /* | |
869 | * ulfs_read_dotdot: Store in *ino_ret the inode number of the parent | 869 | * ulfs_read_dotdot: Store in *ino_ret the inode number of the parent | |
870 | * of the directory vp. | 870 | * of the directory vp. | |
871 | */ | 871 | */ | |
872 | static int | 872 | static int | |
873 | ulfs_read_dotdot(struct vnode *vp, kauth_cred_t cred, ino_t *ino_ret) | 873 | ulfs_read_dotdot(struct vnode *vp, kauth_cred_t cred, ino_t *ino_ret) | |
874 | { | 874 | { | |
875 | struct dirtemplate dirbuf; | 875 | struct lfs_dirtemplate dirbuf; | |
876 | int error; | 876 | int error; | |
877 | 877 | |||
878 | KASSERT(vp != NULL); | 878 | KASSERT(vp != NULL); | |
879 | KASSERT(ino_ret != NULL); | 879 | KASSERT(ino_ret != NULL); | |
880 | KASSERT(vp->v_type == VDIR); | 880 | KASSERT(vp->v_type == VDIR); | |
881 | 881 | |||
882 | error = vn_rdwr(UIO_READ, vp, &dirbuf, sizeof dirbuf, (off_t)0, | 882 | error = vn_rdwr(UIO_READ, vp, &dirbuf, sizeof dirbuf, (off_t)0, | |
883 | UIO_SYSSPACE, IO_NODELOCKED, cred, NULL, NULL); | 883 | UIO_SYSSPACE, IO_NODELOCKED, cred, NULL, NULL); | |
884 | if (error) | 884 | if (error) | |
885 | return error; | 885 | return error; | |
886 | 886 | |||
887 | if (ulfs_dirbuf_dotdot_namlen(&dirbuf, vp) != 2 || | 887 | if (ulfs_dirbuf_dotdot_namlen(&dirbuf, vp) != 2 || | |
888 | dirbuf.dotdot_name[0] != '.' || | 888 | dirbuf.dotdot_name[0] != '.' || | |
@@ -891,27 +891,27 @@ ulfs_read_dotdot(struct vnode *vp, kauth | @@ -891,27 +891,27 @@ ulfs_read_dotdot(struct vnode *vp, kauth | |||
891 | return ENOTDIR; | 891 | return ENOTDIR; | |
892 | 892 | |||
893 | *ino_ret = ulfs_rw32(dirbuf.dotdot_ino, | 893 | *ino_ret = ulfs_rw32(dirbuf.dotdot_ino, | |
894 | ULFS_MPNEEDSWAP(VTOI(vp)->i_ump)); | 894 | ULFS_MPNEEDSWAP(VTOI(vp)->i_ump)); | |
895 | return 0; | 895 | return 0; | |
896 | } | 896 | } | |
897 | 897 | |||
898 | /* | 898 | /* | |
899 | * ulfs_dirbuf_dotdot_namlen: Return the namlen of the directory buffer | 899 | * ulfs_dirbuf_dotdot_namlen: Return the namlen of the directory buffer | |
900 | * dirbuf that came from the directory vp. Swap byte order if | 900 | * dirbuf that came from the directory vp. Swap byte order if | |
901 | * necessary. | 901 | * necessary. | |
902 | */ | 902 | */ | |
903 | static int /* XXX int? uint8_t? */ | 903 | static int /* XXX int? uint8_t? */ | |
904 | ulfs_dirbuf_dotdot_namlen(const struct dirtemplate *dirbuf, | 904 | ulfs_dirbuf_dotdot_namlen(const struct lfs_dirtemplate *dirbuf, | |
905 | const struct vnode *vp) | 905 | const struct vnode *vp) | |
906 | { | 906 | { | |
907 | bool swap; | 907 | bool swap; | |
908 | 908 | |||
909 | KASSERT(dirbuf != NULL); | 909 | KASSERT(dirbuf != NULL); | |
910 | KASSERT(vp != NULL); | 910 | KASSERT(vp != NULL); | |
911 | KASSERT(VTOI(vp) != NULL); | 911 | KASSERT(VTOI(vp) != NULL); | |
912 | KASSERT(VTOI(vp)->i_ump != NULL); | 912 | KASSERT(VTOI(vp)->i_ump != NULL); | |
913 | 913 | |||
914 | #if (BYTE_ORDER == LITTLE_ENDIAN) | 914 | #if (BYTE_ORDER == LITTLE_ENDIAN) | |
915 | swap = (ULFS_MPNEEDSWAP(VTOI(vp)->i_ump) == 0); | 915 | swap = (ULFS_MPNEEDSWAP(VTOI(vp)->i_ump) == 0); | |
916 | #else | 916 | #else | |
917 | swap = (ULFS_MPNEEDSWAP(VTOI(vp)->i_ump) != 0); | 917 | swap = (ULFS_MPNEEDSWAP(VTOI(vp)->i_ump) != 0); |
--- src/sys/ufs/lfs/ulfs_dirhash.c 2013/06/06 00:48:04 1.3
+++ src/sys/ufs/lfs/ulfs_dirhash.c 2013/06/08 02:12:56 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ulfs_dirhash.c,v 1.3 2013/06/06 00:48:04 dholland Exp $ */ | 1 | /* $NetBSD: ulfs_dirhash.c,v 1.4 2013/06/08 02:12:56 dholland Exp $ */ | |
2 | /* from NetBSD: ufs_dirhash.c,v 1.34 2009/10/05 23:48:08 rmind Exp */ | 2 | /* from NetBSD: ufs_dirhash.c,v 1.34 2009/10/05 23:48:08 rmind Exp */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 2001, 2002 Ian Dowse. All rights reserved. | 5 | * Copyright (c) 2001, 2002 Ian Dowse. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -19,27 +19,27 @@ | @@ -19,27 +19,27 @@ | |||
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | * | 27 | * | |
28 | * $FreeBSD: src/sys/ufs/ufs/ufs_dirhash.c,v 1.3.2.8 2004/12/08 11:54:13 dwmalone Exp $ | 28 | * $FreeBSD: src/sys/ufs/ufs/ufs_dirhash.c,v 1.3.2.8 2004/12/08 11:54:13 dwmalone Exp $ | |
29 | */ | 29 | */ | |
30 | 30 | |||
31 | #include <sys/cdefs.h> | 31 | #include <sys/cdefs.h> | |
32 | __KERNEL_RCSID(0, "$NetBSD: ulfs_dirhash.c,v 1.3 2013/06/06 00:48:04 dholland Exp $"); | 32 | __KERNEL_RCSID(0, "$NetBSD: ulfs_dirhash.c,v 1.4 2013/06/08 02:12:56 dholland Exp $"); | |
33 | 33 | |||
34 | /* | 34 | /* | |
35 | * This implements a hash-based lookup scheme for ULFS directories. | 35 | * This implements a hash-based lookup scheme for ULFS directories. | |
36 | */ | 36 | */ | |
37 | 37 | |||
38 | #include <sys/param.h> | 38 | #include <sys/param.h> | |
39 | #include <sys/systm.h> | 39 | #include <sys/systm.h> | |
40 | #include <sys/kernel.h> | 40 | #include <sys/kernel.h> | |
41 | #include <sys/kmem.h> | 41 | #include <sys/kmem.h> | |
42 | #include <sys/types.h> | 42 | #include <sys/types.h> | |
43 | #include <sys/hash.h> | 43 | #include <sys/hash.h> | |
44 | #include <sys/proc.h> | 44 | #include <sys/proc.h> | |
45 | #include <sys/buf.h> | 45 | #include <sys/buf.h> | |
@@ -62,27 +62,27 @@ __KERNEL_RCSID(0, "$NetBSD: ulfs_dirhash | @@ -62,27 +62,27 @@ __KERNEL_RCSID(0, "$NetBSD: ulfs_dirhash | |||
62 | #define BLKFREE2IDX(n) ((n) > DH_NFSTATS ? DH_NFSTATS : (n)) | 62 | #define BLKFREE2IDX(n) ((n) > DH_NFSTATS ? DH_NFSTATS : (n)) | |
63 | 63 | |||
64 | static u_int ulfs_dirhashminblks = 5; | 64 | static u_int ulfs_dirhashminblks = 5; | |
65 | static u_int ulfs_dirhashmaxmem = 2 * 1024 * 1024; | 65 | static u_int ulfs_dirhashmaxmem = 2 * 1024 * 1024; | |
66 | static u_int ulfs_dirhashmem; | 66 | static u_int ulfs_dirhashmem; | |
67 | static u_int ulfs_dirhashcheck = 0; | 67 | static u_int ulfs_dirhashcheck = 0; | |
68 | 68 | |||
69 | static int ulfsdirhash_hash(struct dirhash *dh, const char *name, int namelen); | 69 | static int ulfsdirhash_hash(struct dirhash *dh, const char *name, int namelen); | |
70 | static void ulfsdirhash_adjfree(struct dirhash *dh, doff_t offset, int diff, | 70 | static void ulfsdirhash_adjfree(struct dirhash *dh, doff_t offset, int diff, | |
71 | int dirblksiz); | 71 | int dirblksiz); | |
72 | static void ulfsdirhash_delslot(struct dirhash *dh, int slot); | 72 | static void ulfsdirhash_delslot(struct dirhash *dh, int slot); | |
73 | static int ulfsdirhash_findslot(struct dirhash *dh, const char *name, | 73 | static int ulfsdirhash_findslot(struct dirhash *dh, const char *name, | |
74 | int namelen, doff_t offset); | 74 | int namelen, doff_t offset); | |
75 | static doff_t ulfsdirhash_getprev(struct direct *dp, doff_t offset, | 75 | static doff_t ulfsdirhash_getprev(struct lfs_direct *dp, doff_t offset, | |
76 | int dirblksiz); | 76 | int dirblksiz); | |
77 | static int ulfsdirhash_recycle(int wanted); | 77 | static int ulfsdirhash_recycle(int wanted); | |
78 | 78 | |||
79 | static pool_cache_t ulfsdirhashblk_cache; | 79 | static pool_cache_t ulfsdirhashblk_cache; | |
80 | static pool_cache_t ulfsdirhash_cache; | 80 | static pool_cache_t ulfsdirhash_cache; | |
81 | 81 | |||
82 | #define DIRHASHLIST_LOCK() mutex_enter(&ulfsdirhash_lock) | 82 | #define DIRHASHLIST_LOCK() mutex_enter(&ulfsdirhash_lock) | |
83 | #define DIRHASHLIST_UNLOCK() mutex_exit(&ulfsdirhash_lock) | 83 | #define DIRHASHLIST_UNLOCK() mutex_exit(&ulfsdirhash_lock) | |
84 | #define DIRHASH_LOCK(dh) mutex_enter(&(dh)->dh_lock) | 84 | #define DIRHASH_LOCK(dh) mutex_enter(&(dh)->dh_lock) | |
85 | #define DIRHASH_UNLOCK(dh) mutex_exit(&(dh)->dh_lock) | 85 | #define DIRHASH_UNLOCK(dh) mutex_exit(&(dh)->dh_lock) | |
86 | #define DIRHASH_BLKALLOC() \ | 86 | #define DIRHASH_BLKALLOC() \ | |
87 | pool_cache_get(ulfsdirhashblk_cache, PR_NOWAIT) | 87 | pool_cache_get(ulfsdirhashblk_cache, PR_NOWAIT) | |
88 | #define DIRHASH_BLKFREE(ptr) \ | 88 | #define DIRHASH_BLKFREE(ptr) \ | |
@@ -105,27 +105,27 @@ static struct sysctllog *ulfsdirhash_sys | @@ -105,27 +105,27 @@ static struct sysctllog *ulfsdirhash_sys | |||
105 | * ulfsdirhash_lock. Only the owner of the inode may free the associated | 105 | * ulfsdirhash_lock. Only the owner of the inode may free the associated | |
106 | * dirhash, but anything can steal its memory and set dh_hash to NULL. | 106 | * dirhash, but anything can steal its memory and set dh_hash to NULL. | |
107 | */ | 107 | */ | |
108 | 108 | |||
109 | /* | 109 | /* | |
110 | * Attempt to build up a hash table for the directory contents in | 110 | * Attempt to build up a hash table for the directory contents in | |
111 | * inode 'ip'. Returns 0 on success, or -1 of the operation failed. | 111 | * inode 'ip'. Returns 0 on success, or -1 of the operation failed. | |
112 | */ | 112 | */ | |
113 | int | 113 | int | |
114 | ulfsdirhash_build(struct inode *ip) | 114 | ulfsdirhash_build(struct inode *ip) | |
115 | { | 115 | { | |
116 | struct dirhash *dh; | 116 | struct dirhash *dh; | |
117 | struct buf *bp = NULL; | 117 | struct buf *bp = NULL; | |
118 | struct direct *ep; | 118 | struct lfs_direct *ep; | |
119 | struct vnode *vp; | 119 | struct vnode *vp; | |
120 | doff_t bmask, pos; | 120 | doff_t bmask, pos; | |
121 | int dirblocks, i, j, memreqd, nblocks, narrays, nslots, slot; | 121 | int dirblocks, i, j, memreqd, nblocks, narrays, nslots, slot; | |
122 | const int needswap = ULFS_MPNEEDSWAP(ip->i_ump); | 122 | const int needswap = ULFS_MPNEEDSWAP(ip->i_ump); | |
123 | int dirblksiz = ip->i_ump->um_dirblksiz; | 123 | int dirblksiz = ip->i_ump->um_dirblksiz; | |
124 | 124 | |||
125 | /* Check if we can/should use dirhash. */ | 125 | /* Check if we can/should use dirhash. */ | |
126 | if (ip->i_dirhash == NULL) { | 126 | if (ip->i_dirhash == NULL) { | |
127 | if (ip->i_size < (ulfs_dirhashminblks * dirblksiz) || OFSFMT(ip)) | 127 | if (ip->i_size < (ulfs_dirhashminblks * dirblksiz) || OFSFMT(ip)) | |
128 | return (-1); | 128 | return (-1); | |
129 | } else { | 129 | } else { | |
130 | /* Hash exists, but sysctls could have changed. */ | 130 | /* Hash exists, but sysctls could have changed. */ | |
131 | if (ip->i_size < (ulfs_dirhashminblks * dirblksiz) || | 131 | if (ip->i_size < (ulfs_dirhashminblks * dirblksiz) || | |
@@ -216,27 +216,27 @@ ulfsdirhash_build(struct inode *ip) | @@ -216,27 +216,27 @@ ulfsdirhash_build(struct inode *ip) | |||
216 | if ((curcpu()->ci_schedstate.spc_flags & SPCF_SHOULDYIELD) | 216 | if ((curcpu()->ci_schedstate.spc_flags & SPCF_SHOULDYIELD) | |
217 | != 0) { | 217 | != 0) { | |
218 | preempt(); | 218 | preempt(); | |
219 | } | 219 | } | |
220 | /* If necessary, get the next directory block. */ | 220 | /* If necessary, get the next directory block. */ | |
221 | if ((pos & bmask) == 0) { | 221 | if ((pos & bmask) == 0) { | |
222 | if (bp != NULL) | 222 | if (bp != NULL) | |
223 | brelse(bp, 0); | 223 | brelse(bp, 0); | |
224 | if (ulfs_blkatoff(vp, (off_t)pos, NULL, &bp, false) != 0) | 224 | if (ulfs_blkatoff(vp, (off_t)pos, NULL, &bp, false) != 0) | |
225 | goto fail; | 225 | goto fail; | |
226 | } | 226 | } | |
227 | 227 | |||
228 | /* Add this entry to the hash. */ | 228 | /* Add this entry to the hash. */ | |
229 | ep = (struct direct *)((char *)bp->b_data + (pos & bmask)); | 229 | ep = (struct lfs_direct *)((char *)bp->b_data + (pos & bmask)); | |
230 | if (ep->d_reclen == 0 || ep->d_reclen > | 230 | if (ep->d_reclen == 0 || ep->d_reclen > | |
231 | dirblksiz - (pos & (dirblksiz - 1))) { | 231 | dirblksiz - (pos & (dirblksiz - 1))) { | |
232 | /* Corrupted directory. */ | 232 | /* Corrupted directory. */ | |
233 | brelse(bp, 0); | 233 | brelse(bp, 0); | |
234 | goto fail; | 234 | goto fail; | |
235 | } | 235 | } | |
236 | if (ep->d_ino != 0) { | 236 | if (ep->d_ino != 0) { | |
237 | /* Add the entry (simplified ulfsdirhash_add). */ | 237 | /* Add the entry (simplified ulfsdirhash_add). */ | |
238 | slot = ulfsdirhash_hash(dh, ep->d_name, ep->d_namlen); | 238 | slot = ulfsdirhash_hash(dh, ep->d_name, ep->d_namlen); | |
239 | while (DH_ENTRY(dh, slot) != DIRHASH_EMPTY) | 239 | while (DH_ENTRY(dh, slot) != DIRHASH_EMPTY) | |
240 | slot = WRAPINCR(slot, dh->dh_hlen); | 240 | slot = WRAPINCR(slot, dh->dh_hlen); | |
241 | dh->dh_hused++; | 241 | dh->dh_hused++; | |
242 | DH_ENTRY(dh, slot) = pos; | 242 | DH_ENTRY(dh, slot) = pos; | |
@@ -315,27 +315,27 @@ ulfsdirhash_free(struct inode *ip) | @@ -315,27 +315,27 @@ ulfsdirhash_free(struct inode *ip) | |||
315 | * EJUSTRETURN if the caller should revert to a linear search. | 315 | * EJUSTRETURN if the caller should revert to a linear search. | |
316 | * | 316 | * | |
317 | * If successful, the directory offset is stored in *offp, and a | 317 | * If successful, the directory offset is stored in *offp, and a | |
318 | * pointer to a struct buf containing the entry is stored in *bpp. If | 318 | * pointer to a struct buf containing the entry is stored in *bpp. If | |
319 | * prevoffp is non-NULL, the offset of the previous entry within | 319 | * prevoffp is non-NULL, the offset of the previous entry within | |
320 | * the DIRBLKSIZ-sized block is stored in *prevoffp (if the entry | 320 | * the DIRBLKSIZ-sized block is stored in *prevoffp (if the entry | |
321 | * is the first in a block, the start of the block is used). | 321 | * is the first in a block, the start of the block is used). | |
322 | */ | 322 | */ | |
323 | int | 323 | int | |
324 | ulfsdirhash_lookup(struct inode *ip, const char *name, int namelen, doff_t *offp, | 324 | ulfsdirhash_lookup(struct inode *ip, const char *name, int namelen, doff_t *offp, | |
325 | struct buf **bpp, doff_t *prevoffp) | 325 | struct buf **bpp, doff_t *prevoffp) | |
326 | { | 326 | { | |
327 | struct dirhash *dh, *dh_next; | 327 | struct dirhash *dh, *dh_next; | |
328 | struct direct *dp; | 328 | struct lfs_direct *dp; | |
329 | struct vnode *vp; | 329 | struct vnode *vp; | |
330 | struct buf *bp; | 330 | struct buf *bp; | |
331 | doff_t blkoff, bmask, offset, prevoff; | 331 | doff_t blkoff, bmask, offset, prevoff; | |
332 | int i, slot; | 332 | int i, slot; | |
333 | const int needswap = ULFS_MPNEEDSWAP(ip->i_ump); | 333 | const int needswap = ULFS_MPNEEDSWAP(ip->i_ump); | |
334 | int dirblksiz = ip->i_ump->um_dirblksiz; | 334 | int dirblksiz = ip->i_ump->um_dirblksiz; | |
335 | 335 | |||
336 | if ((dh = ip->i_dirhash) == NULL) | 336 | if ((dh = ip->i_dirhash) == NULL) | |
337 | return (EJUSTRETURN); | 337 | return (EJUSTRETURN); | |
338 | 338 | |||
339 | /* | 339 | /* | |
340 | * Move this dirhash towards the end of the list if it has a | 340 | * Move this dirhash towards the end of the list if it has a | |
341 | * score higher than the next entry, and acquire the dh_lock. | 341 | * score higher than the next entry, and acquire the dh_lock. | |
@@ -412,27 +412,27 @@ restart: | @@ -412,27 +412,27 @@ restart: | |||
412 | 412 | |||
413 | if (offset < 0 || offset >= ip->i_size) | 413 | if (offset < 0 || offset >= ip->i_size) | |
414 | panic("ulfsdirhash_lookup: bad offset in hash array"); | 414 | panic("ulfsdirhash_lookup: bad offset in hash array"); | |
415 | if ((offset & ~bmask) != blkoff) { | 415 | if ((offset & ~bmask) != blkoff) { | |
416 | if (bp != NULL) | 416 | if (bp != NULL) | |
417 | brelse(bp, 0); | 417 | brelse(bp, 0); | |
418 | blkoff = offset & ~bmask; | 418 | blkoff = offset & ~bmask; | |
419 | if (ulfs_blkatoff(vp, (off_t)blkoff, | 419 | if (ulfs_blkatoff(vp, (off_t)blkoff, | |
420 | NULL, &bp, false) != 0) { | 420 | NULL, &bp, false) != 0) { | |
421 | DIRHASH_UNLOCK(dh); | 421 | DIRHASH_UNLOCK(dh); | |
422 | return (EJUSTRETURN); | 422 | return (EJUSTRETURN); | |
423 | } | 423 | } | |
424 | } | 424 | } | |
425 | dp = (struct direct *)((char *)bp->b_data + (offset & bmask)); | 425 | dp = (struct lfs_direct *)((char *)bp->b_data + (offset & bmask)); | |
426 | if (dp->d_reclen == 0 || dp->d_reclen > | 426 | if (dp->d_reclen == 0 || dp->d_reclen > | |
427 | dirblksiz - (offset & (dirblksiz - 1))) { | 427 | dirblksiz - (offset & (dirblksiz - 1))) { | |
428 | /* Corrupted directory. */ | 428 | /* Corrupted directory. */ | |
429 | DIRHASH_UNLOCK(dh); | 429 | DIRHASH_UNLOCK(dh); | |
430 | brelse(bp, 0); | 430 | brelse(bp, 0); | |
431 | return (EJUSTRETURN); | 431 | return (EJUSTRETURN); | |
432 | } | 432 | } | |
433 | if (dp->d_namlen == namelen && | 433 | if (dp->d_namlen == namelen && | |
434 | memcmp(dp->d_name, name, namelen) == 0) { | 434 | memcmp(dp->d_name, name, namelen) == 0) { | |
435 | /* Found. Get the prev offset if needed. */ | 435 | /* Found. Get the prev offset if needed. */ | |
436 | if (prevoffp != NULL) { | 436 | if (prevoffp != NULL) { | |
437 | if (offset & (dirblksiz - 1)) { | 437 | if (offset & (dirblksiz - 1)) { | |
438 | prevoff = ulfsdirhash_getprev(dp, | 438 | prevoff = ulfsdirhash_getprev(dp, | |
@@ -488,27 +488,27 @@ restart: | @@ -488,27 +488,27 @@ restart: | |||
488 | * | 488 | * | |
489 | * To use the space, the caller may need to compact existing entries in | 489 | * To use the space, the caller may need to compact existing entries in | |
490 | * the directory. The total number of bytes in all of the entries involved | 490 | * the directory. The total number of bytes in all of the entries involved | |
491 | * in the compaction is stored in *slotsize. In other words, all of | 491 | * in the compaction is stored in *slotsize. In other words, all of | |
492 | * the entries that must be compacted are exactly contained in the | 492 | * the entries that must be compacted are exactly contained in the | |
493 | * region beginning at the returned offset and spanning *slotsize bytes. | 493 | * region beginning at the returned offset and spanning *slotsize bytes. | |
494 | * | 494 | * | |
495 | * Returns -1 if no space was found, indicating that the directory | 495 | * Returns -1 if no space was found, indicating that the directory | |
496 | * must be extended. | 496 | * must be extended. | |
497 | */ | 497 | */ | |
498 | doff_t | 498 | doff_t | |
499 | ulfsdirhash_findfree(struct inode *ip, int slotneeded, int *slotsize) | 499 | ulfsdirhash_findfree(struct inode *ip, int slotneeded, int *slotsize) | |
500 | { | 500 | { | |
501 | struct direct *dp; | 501 | struct lfs_direct *dp; | |
502 | struct dirhash *dh; | 502 | struct dirhash *dh; | |
503 | struct buf *bp; | 503 | struct buf *bp; | |
504 | doff_t pos, slotstart; | 504 | doff_t pos, slotstart; | |
505 | int dirblock, error, freebytes, i; | 505 | int dirblock, error, freebytes, i; | |
506 | const int needswap = ULFS_MPNEEDSWAP(ip->i_ump); | 506 | const int needswap = ULFS_MPNEEDSWAP(ip->i_ump); | |
507 | int dirblksiz = ip->i_ump->um_dirblksiz; | 507 | int dirblksiz = ip->i_ump->um_dirblksiz; | |
508 | 508 | |||
509 | if ((dh = ip->i_dirhash) == NULL) | 509 | if ((dh = ip->i_dirhash) == NULL) | |
510 | return (-1); | 510 | return (-1); | |
511 | 511 | |||
512 | DIRHASH_LOCK(dh); | 512 | DIRHASH_LOCK(dh); | |
513 | if (dh->dh_hash == NULL) { | 513 | if (dh->dh_hash == NULL) { | |
514 | DIRHASH_UNLOCK(dh); | 514 | DIRHASH_UNLOCK(dh); | |
@@ -534,48 +534,48 @@ ulfsdirhash_findfree(struct inode *ip, i | @@ -534,48 +534,48 @@ ulfsdirhash_findfree(struct inode *ip, i | |||
534 | DIRHASH_UNLOCK(dh); | 534 | DIRHASH_UNLOCK(dh); | |
535 | return (-1); | 535 | return (-1); | |
536 | } | 536 | } | |
537 | /* Find the first entry with free space. */ | 537 | /* Find the first entry with free space. */ | |
538 | for (i = 0; i < dirblksiz; ) { | 538 | for (i = 0; i < dirblksiz; ) { | |
539 | if (dp->d_reclen == 0) { | 539 | if (dp->d_reclen == 0) { | |
540 | DIRHASH_UNLOCK(dh); | 540 | DIRHASH_UNLOCK(dh); | |
541 | brelse(bp, 0); | 541 | brelse(bp, 0); | |
542 | return (-1); | 542 | return (-1); | |
543 | } | 543 | } | |
544 | if (dp->d_ino == 0 || dp->d_reclen > DIRSIZ(0, dp, needswap)) | 544 | if (dp->d_ino == 0 || dp->d_reclen > DIRSIZ(0, dp, needswap)) | |
545 | break; | 545 | break; | |
546 | i += dp->d_reclen; | 546 | i += dp->d_reclen; | |
547 | dp = (struct direct *)((char *)dp + dp->d_reclen); | 547 | dp = (struct lfs_direct *)((char *)dp + dp->d_reclen); | |
548 | } | 548 | } | |
549 | if (i > dirblksiz) { | 549 | if (i > dirblksiz) { | |
550 | DIRHASH_UNLOCK(dh); | 550 | DIRHASH_UNLOCK(dh); | |
551 | brelse(bp, 0); | 551 | brelse(bp, 0); | |
552 | return (-1); | 552 | return (-1); | |
553 | } | 553 | } | |
554 | slotstart = pos + i; | 554 | slotstart = pos + i; | |
555 | 555 | |||
556 | /* Find the range of entries needed to get enough space */ | 556 | /* Find the range of entries needed to get enough space */ | |
557 | freebytes = 0; | 557 | freebytes = 0; | |
558 | while (i < dirblksiz && freebytes < slotneeded) { | 558 | while (i < dirblksiz && freebytes < slotneeded) { | |
559 | freebytes += dp->d_reclen; | 559 | freebytes += dp->d_reclen; | |
560 | if (dp->d_ino != 0) | 560 | if (dp->d_ino != 0) | |
561 | freebytes -= DIRSIZ(0, dp, needswap); | 561 | freebytes -= DIRSIZ(0, dp, needswap); | |
562 | if (dp->d_reclen == 0) { | 562 | if (dp->d_reclen == 0) { | |
563 | DIRHASH_UNLOCK(dh); | 563 | DIRHASH_UNLOCK(dh); | |
564 | brelse(bp, 0); | 564 | brelse(bp, 0); | |
565 | return (-1); | 565 | return (-1); | |
566 | } | 566 | } | |
567 | i += dp->d_reclen; | 567 | i += dp->d_reclen; | |
568 | dp = (struct direct *)((char *)dp + dp->d_reclen); | 568 | dp = (struct lfs_direct *)((char *)dp + dp->d_reclen); | |
569 | } | 569 | } | |
570 | if (i > dirblksiz) { | 570 | if (i > dirblksiz) { | |
571 | DIRHASH_UNLOCK(dh); | 571 | DIRHASH_UNLOCK(dh); | |
572 | brelse(bp, 0); | 572 | brelse(bp, 0); | |
573 | return (-1); | 573 | return (-1); | |
574 | } | 574 | } | |
575 | if (freebytes < slotneeded) | 575 | if (freebytes < slotneeded) | |
576 | panic("ulfsdirhash_findfree: free mismatch"); | 576 | panic("ulfsdirhash_findfree: free mismatch"); | |
577 | DIRHASH_UNLOCK(dh); | 577 | DIRHASH_UNLOCK(dh); | |
578 | brelse(bp, 0); | 578 | brelse(bp, 0); | |
579 | *slotsize = pos + i - slotstart; | 579 | *slotsize = pos + i - slotstart; | |
580 | return (slotstart); | 580 | return (slotstart); | |
581 | } | 581 | } | |
@@ -605,31 +605,31 @@ ulfsdirhash_enduseful(struct inode *ip) | @@ -605,31 +605,31 @@ ulfsdirhash_enduseful(struct inode *ip) | |||
605 | DIRHASH_UNLOCK(dh); | 605 | DIRHASH_UNLOCK(dh); | |
606 | return (-1); | 606 | return (-1); | |
607 | } | 607 | } | |
608 | 608 | |||
609 | for (i = dh->dh_dirblks - 1; i >= 0; i--) | 609 | for (i = dh->dh_dirblks - 1; i >= 0; i--) | |
610 | if (dh->dh_blkfree[i] != dirblksiz / DIRALIGN) | 610 | if (dh->dh_blkfree[i] != dirblksiz / DIRALIGN) | |
611 | break; | 611 | break; | |
612 | DIRHASH_UNLOCK(dh); | 612 | DIRHASH_UNLOCK(dh); | |
613 | return ((doff_t)(i + 1) * dirblksiz); | 613 | return ((doff_t)(i + 1) * dirblksiz); | |
614 | } | 614 | } | |
615 | 615 | |||
616 | /* | 616 | /* | |
617 | * Insert information into the hash about a new directory entry. dirp | 617 | * Insert information into the hash about a new directory entry. dirp | |
618 | * points to a struct direct containing the entry, and offset specifies | 618 | * points to a struct lfs_direct containing the entry, and offset specifies | |
619 | * the offset of this entry. | 619 | * the offset of this entry. | |
620 | */ | 620 | */ | |
621 | void | 621 | void | |
622 | ulfsdirhash_add(struct inode *ip, struct direct *dirp, doff_t offset) | 622 | ulfsdirhash_add(struct inode *ip, struct lfs_direct *dirp, doff_t offset) | |
623 | { | 623 | { | |
624 | struct dirhash *dh; | 624 | struct dirhash *dh; | |
625 | int slot; | 625 | int slot; | |
626 | const int needswap = ULFS_MPNEEDSWAP(ip->i_ump); | 626 | const int needswap = ULFS_MPNEEDSWAP(ip->i_ump); | |
627 | int dirblksiz = ip->i_ump->um_dirblksiz; | 627 | int dirblksiz = ip->i_ump->um_dirblksiz; | |
628 | 628 | |||
629 | if ((dh = ip->i_dirhash) == NULL) | 629 | if ((dh = ip->i_dirhash) == NULL) | |
630 | return; | 630 | return; | |
631 | 631 | |||
632 | DIRHASH_LOCK(dh); | 632 | DIRHASH_LOCK(dh); | |
633 | if (dh->dh_hash == NULL) { | 633 | if (dh->dh_hash == NULL) { | |
634 | DIRHASH_UNLOCK(dh); | 634 | DIRHASH_UNLOCK(dh); | |
635 | ulfsdirhash_free(ip); | 635 | ulfsdirhash_free(ip); | |
@@ -656,27 +656,27 @@ ulfsdirhash_add(struct inode *ip, struct | @@ -656,27 +656,27 @@ ulfsdirhash_add(struct inode *ip, struct | |||
656 | DH_ENTRY(dh, slot) = offset; | 656 | DH_ENTRY(dh, slot) = offset; | |
657 | 657 | |||
658 | /* Update the per-block summary info. */ | 658 | /* Update the per-block summary info. */ | |
659 | ulfsdirhash_adjfree(dh, offset, -DIRSIZ(0, dirp, needswap), dirblksiz); | 659 | ulfsdirhash_adjfree(dh, offset, -DIRSIZ(0, dirp, needswap), dirblksiz); | |
660 | DIRHASH_UNLOCK(dh); | 660 | DIRHASH_UNLOCK(dh); | |
661 | } | 661 | } | |
662 | 662 | |||
663 | /* | 663 | /* | |
664 | * Remove the specified directory entry from the hash. The entry to remove | 664 | * Remove the specified directory entry from the hash. The entry to remove | |
665 | * is defined by the name in `dirp', which must exist at the specified | 665 | * is defined by the name in `dirp', which must exist at the specified | |
666 | * `offset' within the directory. | 666 | * `offset' within the directory. | |
667 | */ | 667 | */ | |
668 | void | 668 | void | |
669 | ulfsdirhash_remove(struct inode *ip, struct direct *dirp, doff_t offset) | 669 | ulfsdirhash_remove(struct inode *ip, struct lfs_direct *dirp, doff_t offset) | |
670 | { | 670 | { | |
671 | struct dirhash *dh; | 671 | struct dirhash *dh; | |
672 | int slot; | 672 | int slot; | |
673 | const int needswap = ULFS_MPNEEDSWAP(ip->i_ump); | 673 | const int needswap = ULFS_MPNEEDSWAP(ip->i_ump); | |
674 | int dirblksiz = ip->i_ump->um_dirblksiz; | 674 | int dirblksiz = ip->i_ump->um_dirblksiz; | |
675 | 675 | |||
676 | if ((dh = ip->i_dirhash) == NULL) | 676 | if ((dh = ip->i_dirhash) == NULL) | |
677 | return; | 677 | return; | |
678 | 678 | |||
679 | DIRHASH_LOCK(dh); | 679 | DIRHASH_LOCK(dh); | |
680 | if (dh->dh_hash == NULL) { | 680 | if (dh->dh_hash == NULL) { | |
681 | DIRHASH_UNLOCK(dh); | 681 | DIRHASH_UNLOCK(dh); | |
682 | ulfsdirhash_free(ip); | 682 | ulfsdirhash_free(ip); | |
@@ -690,27 +690,27 @@ ulfsdirhash_remove(struct inode *ip, str | @@ -690,27 +690,27 @@ ulfsdirhash_remove(struct inode *ip, str | |||
690 | /* Remove the hash entry. */ | 690 | /* Remove the hash entry. */ | |
691 | ulfsdirhash_delslot(dh, slot); | 691 | ulfsdirhash_delslot(dh, slot); | |
692 | 692 | |||
693 | /* Update the per-block summary info. */ | 693 | /* Update the per-block summary info. */ | |
694 | ulfsdirhash_adjfree(dh, offset, DIRSIZ(0, dirp, needswap), dirblksiz); | 694 | ulfsdirhash_adjfree(dh, offset, DIRSIZ(0, dirp, needswap), dirblksiz); | |
695 | DIRHASH_UNLOCK(dh); | 695 | DIRHASH_UNLOCK(dh); | |
696 | } | 696 | } | |
697 | 697 | |||
698 | /* | 698 | /* | |
699 | * Change the offset associated with a directory entry in the hash. Used | 699 | * Change the offset associated with a directory entry in the hash. Used | |
700 | * when compacting directory blocks. | 700 | * when compacting directory blocks. | |
701 | */ | 701 | */ | |
702 | void | 702 | void | |
703 | ulfsdirhash_move(struct inode *ip, struct direct *dirp, doff_t oldoff, | 703 | ulfsdirhash_move(struct inode *ip, struct lfs_direct *dirp, doff_t oldoff, | |
704 | doff_t newoff) | 704 | doff_t newoff) | |
705 | { | 705 | { | |
706 | struct dirhash *dh; | 706 | struct dirhash *dh; | |
707 | int slot; | 707 | int slot; | |
708 | 708 | |||
709 | if ((dh = ip->i_dirhash) == NULL) | 709 | if ((dh = ip->i_dirhash) == NULL) | |
710 | return; | 710 | return; | |
711 | DIRHASH_LOCK(dh); | 711 | DIRHASH_LOCK(dh); | |
712 | if (dh->dh_hash == NULL) { | 712 | if (dh->dh_hash == NULL) { | |
713 | DIRHASH_UNLOCK(dh); | 713 | DIRHASH_UNLOCK(dh); | |
714 | ulfsdirhash_free(ip); | 714 | ulfsdirhash_free(ip); | |
715 | return; | 715 | return; | |
716 | } | 716 | } | |
@@ -814,50 +814,50 @@ ulfsdirhash_dirtrunc(struct inode *ip, d | @@ -814,50 +814,50 @@ ulfsdirhash_dirtrunc(struct inode *ip, d | |||
814 | /* | 814 | /* | |
815 | * Debugging function to check that the dirhash information about | 815 | * Debugging function to check that the dirhash information about | |
816 | * a directory block matches its actual contents. Panics if a mismatch | 816 | * a directory block matches its actual contents. Panics if a mismatch | |
817 | * is detected. | 817 | * is detected. | |
818 | * | 818 | * | |
819 | * On entry, `sbuf' should point to the start of an in-core | 819 | * On entry, `sbuf' should point to the start of an in-core | |
820 | * DIRBLKSIZ-sized directory block, and `offset' should contain the | 820 | * DIRBLKSIZ-sized directory block, and `offset' should contain the | |
821 | * offset from the start of the directory of that block. | 821 | * offset from the start of the directory of that block. | |
822 | */ | 822 | */ | |
823 | void | 823 | void | |
824 | ulfsdirhash_checkblock(struct inode *ip, char *sbuf, doff_t offset) | 824 | ulfsdirhash_checkblock(struct inode *ip, char *sbuf, doff_t offset) | |
825 | { | 825 | { | |
826 | struct dirhash *dh; | 826 | struct dirhash *dh; | |
827 | struct direct *dp; | 827 | struct lfs_direct *dp; | |
828 | int block, ffslot, i, nfree; | 828 | int block, ffslot, i, nfree; | |
829 | const int needswap = ULFS_MPNEEDSWAP(ip->i_ump); | 829 | const int needswap = ULFS_MPNEEDSWAP(ip->i_ump); | |
830 | int dirblksiz = ip->i_ump->um_dirblksiz; | 830 | int dirblksiz = ip->i_ump->um_dirblksiz; | |
831 | 831 | |||
832 | if (!ulfs_dirhashcheck) | 832 | if (!ulfs_dirhashcheck) | |
833 | return; | 833 | return; | |
834 | if ((dh = ip->i_dirhash) == NULL) | 834 | if ((dh = ip->i_dirhash) == NULL) | |
835 | return; | 835 | return; | |
836 | 836 | |||
837 | DIRHASH_LOCK(dh); | 837 | DIRHASH_LOCK(dh); | |
838 | if (dh->dh_hash == NULL) { | 838 | if (dh->dh_hash == NULL) { | |
839 | DIRHASH_UNLOCK(dh); | 839 | DIRHASH_UNLOCK(dh); | |
840 | ulfsdirhash_free(ip); | 840 | ulfsdirhash_free(ip); | |
841 | return; | 841 | return; | |
842 | } | 842 | } | |
843 | 843 | |||
844 | block = offset / dirblksiz; | 844 | block = offset / dirblksiz; | |
845 | if ((offset & (dirblksiz - 1)) != 0 || block >= dh->dh_dirblks) | 845 | if ((offset & (dirblksiz - 1)) != 0 || block >= dh->dh_dirblks) | |
846 | panic("ulfsdirhash_checkblock: bad offset"); | 846 | panic("ulfsdirhash_checkblock: bad offset"); | |
847 | 847 | |||
848 | nfree = 0; | 848 | nfree = 0; | |
849 | for (i = 0; i < dirblksiz; i += dp->d_reclen) { | 849 | for (i = 0; i < dirblksiz; i += dp->d_reclen) { | |
850 | dp = (struct direct *)(sbuf + i); | 850 | dp = (struct lfs_direct *)(sbuf + i); | |
851 | if (dp->d_reclen == 0 || i + dp->d_reclen > dirblksiz) | 851 | if (dp->d_reclen == 0 || i + dp->d_reclen > dirblksiz) | |
852 | panic("ulfsdirhash_checkblock: bad dir"); | 852 | panic("ulfsdirhash_checkblock: bad dir"); | |
853 | 853 | |||
854 | if (dp->d_ino == 0) { | 854 | if (dp->d_ino == 0) { | |
855 | #if 0 | 855 | #if 0 | |
856 | /* | 856 | /* | |
857 | * XXX entries with d_ino == 0 should only occur | 857 | * XXX entries with d_ino == 0 should only occur | |
858 | * at the start of a DIRBLKSIZ block. However the | 858 | * at the start of a DIRBLKSIZ block. However the | |
859 | * ulfs code is tolerant of such entries at other | 859 | * ulfs code is tolerant of such entries at other | |
860 | * offsets, and fsck does not fix them. | 860 | * offsets, and fsck does not fix them. | |
861 | */ | 861 | */ | |
862 | if (i != 0) | 862 | if (i != 0) | |
863 | panic("ulfsdirhash_checkblock: bad dir inode"); | 863 | panic("ulfsdirhash_checkblock: bad dir inode"); | |
@@ -996,45 +996,45 @@ ulfsdirhash_delslot(struct dirhash *dh, | @@ -996,45 +996,45 @@ ulfsdirhash_delslot(struct dirhash *dh, | |||
996 | i = WRAPDECR(i, dh->dh_hlen); | 996 | i = WRAPDECR(i, dh->dh_hlen); | |
997 | } | 997 | } | |
998 | KASSERT(dh->dh_hused >= 0); | 998 | KASSERT(dh->dh_hused >= 0); | |
999 | } | 999 | } | |
1000 | } | 1000 | } | |
1001 | 1001 | |||
1002 | /* | 1002 | /* | |
1003 | * Given a directory entry and its offset, find the offset of the | 1003 | * Given a directory entry and its offset, find the offset of the | |
1004 | * previous entry in the same DIRBLKSIZ-sized block. Returns an | 1004 | * previous entry in the same DIRBLKSIZ-sized block. Returns an | |
1005 | * offset, or -1 if there is no previous entry in the block or some | 1005 | * offset, or -1 if there is no previous entry in the block or some | |
1006 | * other problem occurred. | 1006 | * other problem occurred. | |
1007 | */ | 1007 | */ | |
1008 | static doff_t | 1008 | static doff_t | |
1009 | ulfsdirhash_getprev(struct direct *dirp, doff_t offset, int dirblksiz) | 1009 | ulfsdirhash_getprev(struct lfs_direct *dirp, doff_t offset, int dirblksiz) | |
1010 | { | 1010 | { | |
1011 | struct direct *dp; | 1011 | struct lfs_direct *dp; | |
1012 | char *blkbuf; | 1012 | char *blkbuf; | |
1013 | doff_t blkoff, prevoff; | 1013 | doff_t blkoff, prevoff; | |
1014 | int entrypos, i; | 1014 | int entrypos, i; | |
1015 | 1015 | |||
1016 | blkoff = offset & ~(dirblksiz - 1); /* offset of start of block */ | 1016 | blkoff = offset & ~(dirblksiz - 1); /* offset of start of block */ | |
1017 | entrypos = offset & (dirblksiz - 1); /* entry relative to block */ | 1017 | entrypos = offset & (dirblksiz - 1); /* entry relative to block */ | |
1018 | blkbuf = (char *)dirp - entrypos; | 1018 | blkbuf = (char *)dirp - entrypos; | |
1019 | prevoff = blkoff; | 1019 | prevoff = blkoff; | |
1020 | 1020 | |||
1021 | /* If `offset' is the start of a block, there is no previous entry. */ | 1021 | /* If `offset' is the start of a block, there is no previous entry. */ | |
1022 | if (entrypos == 0) | 1022 | if (entrypos == 0) | |
1023 | return (-1); | 1023 | return (-1); | |
1024 | 1024 | |||
1025 | /* Scan from the start of the block until we get to the entry. */ | 1025 | /* Scan from the start of the block until we get to the entry. */ | |
1026 | for (i = 0; i < entrypos; i += dp->d_reclen) { | 1026 | for (i = 0; i < entrypos; i += dp->d_reclen) { | |
1027 | dp = (struct direct *)(blkbuf + i); | 1027 | dp = (struct lfs_direct *)(blkbuf + i); | |
1028 | if (dp->d_reclen == 0 || i + dp->d_reclen > entrypos) | 1028 | if (dp->d_reclen == 0 || i + dp->d_reclen > entrypos) | |
1029 | return (-1); /* Corrupted directory. */ | 1029 | return (-1); /* Corrupted directory. */ | |
1030 | prevoff = blkoff + i; | 1030 | prevoff = blkoff + i; | |
1031 | } | 1031 | } | |
1032 | return (prevoff); | 1032 | return (prevoff); | |
1033 | } | 1033 | } | |
1034 | 1034 | |||
1035 | /* | 1035 | /* | |
1036 | * Try to free up `wanted' bytes by stealing memory from existing | 1036 | * Try to free up `wanted' bytes by stealing memory from existing | |
1037 | * dirhashes. Returns zero with list locked if successful. | 1037 | * dirhashes. Returns zero with list locked if successful. | |
1038 | */ | 1038 | */ | |
1039 | static int | 1039 | static int | |
1040 | ulfsdirhash_recycle(int wanted) | 1040 | ulfsdirhash_recycle(int wanted) |
--- src/sys/ufs/lfs/ulfs_dirhash.h 2013/06/06 00:48:04 1.2
+++ src/sys/ufs/lfs/ulfs_dirhash.h 2013/06/08 02:12:56 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ulfs_dirhash.h,v 1.2 2013/06/06 00:48:04 dholland Exp $ */ | 1 | /* $NetBSD: ulfs_dirhash.h,v 1.3 2013/06/08 02:12:56 dholland Exp $ */ | |
2 | /* from NetBSD: dirhash.h,v 1.6 2008/06/04 11:33:19 ad Exp */ | 2 | /* from NetBSD: dirhash.h,v 1.6 2008/06/04 11:33:19 ad Exp */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 2001 Ian Dowse. All rights reserved. | 5 | * Copyright (c) 2001 Ian Dowse. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -108,23 +108,23 @@ struct dirhash { | @@ -108,23 +108,23 @@ struct dirhash { | |||
108 | TAILQ_ENTRY(dirhash) dh_list; /* chain of all dirhashes */ | 108 | TAILQ_ENTRY(dirhash) dh_list; /* chain of all dirhashes */ | |
109 | }; | 109 | }; | |
110 | 110 | |||
111 | 111 | |||
112 | /* | 112 | /* | |
113 | * Dirhash functions. | 113 | * Dirhash functions. | |
114 | */ | 114 | */ | |
115 | int ulfsdirhash_build(struct inode *); | 115 | int ulfsdirhash_build(struct inode *); | |
116 | doff_t ulfsdirhash_findfree(struct inode *, int, int *); | 116 | doff_t ulfsdirhash_findfree(struct inode *, int, int *); | |
117 | doff_t ulfsdirhash_enduseful(struct inode *); | 117 | doff_t ulfsdirhash_enduseful(struct inode *); | |
118 | int ulfsdirhash_lookup(struct inode *, const char *, int, doff_t *, | 118 | int ulfsdirhash_lookup(struct inode *, const char *, int, doff_t *, | |
119 | struct buf **, doff_t *); | 119 | struct buf **, doff_t *); | |
120 | void ulfsdirhash_newblk(struct inode *, doff_t); | 120 | void ulfsdirhash_newblk(struct inode *, doff_t); | |
121 | void ulfsdirhash_add(struct inode *, struct direct *, doff_t); | 121 | void ulfsdirhash_add(struct inode *, struct lfs_direct *, doff_t); | |
122 | void ulfsdirhash_remove(struct inode *, struct direct *, doff_t); | 122 | void ulfsdirhash_remove(struct inode *, struct lfs_direct *, doff_t); | |
123 | void ulfsdirhash_move(struct inode *, struct direct *, doff_t, doff_t); | 123 | void ulfsdirhash_move(struct inode *, struct lfs_direct *, doff_t, doff_t); | |
124 | void ulfsdirhash_dirtrunc(struct inode *, doff_t); | 124 | void ulfsdirhash_dirtrunc(struct inode *, doff_t); | |
125 | void ulfsdirhash_free(struct inode *); | 125 | void ulfsdirhash_free(struct inode *); | |
126 | void ulfsdirhash_checkblock(struct inode *, char *, doff_t); | 126 | void ulfsdirhash_checkblock(struct inode *, char *, doff_t); | |
127 | void ulfsdirhash_init(void); | 127 | void ulfsdirhash_init(void); | |
128 | void ulfsdirhash_done(void); | 128 | void ulfsdirhash_done(void); | |
129 | 129 | |||
130 | #endif /* !_UFS_LFS_ULFS_DIRHASH_H_ */ | 130 | #endif /* !_UFS_LFS_ULFS_DIRHASH_H_ */ |
--- src/sys/ufs/lfs/ulfs_extern.h 2013/06/06 00:52:14 1.5
+++ src/sys/ufs/lfs/ulfs_extern.h 2013/06/08 02:12:56 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ulfs_extern.h,v 1.5 2013/06/06 00:52:14 dholland Exp $ */ | 1 | /* $NetBSD: ulfs_extern.h,v 1.6 2013/06/08 02:12:56 dholland Exp $ */ | |
2 | /* from NetBSD: ufs_extern.h,v 1.72 2012/05/09 00:21:18 riastradh Exp */ | 2 | /* from NetBSD: ufs_extern.h,v 1.72 2012/05/09 00:21:18 riastradh Exp */ | |
3 | 3 | |||
4 | /*- | 4 | /*- | |
5 | * Copyright (c) 1991, 1993, 1994 | 5 | * Copyright (c) 1991, 1993, 1994 | |
6 | * The Regents of the University of California. All rights reserved. | 6 | * The Regents of the University of California. All rights reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -29,46 +29,46 @@ | @@ -29,46 +29,46 @@ | |||
29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
30 | * SUCH DAMAGE. | 30 | * SUCH DAMAGE. | |
31 | * | 31 | * | |
32 | * @(#)ufs_extern.h 8.10 (Berkeley) 5/14/95 | 32 | * @(#)ufs_extern.h 8.10 (Berkeley) 5/14/95 | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | #ifndef _UFS_LFS_ULFS_EXTERN_H_ | 35 | #ifndef _UFS_LFS_ULFS_EXTERN_H_ | |
36 | #define _UFS_LFS_ULFS_EXTERN_H_ | 36 | #define _UFS_LFS_ULFS_EXTERN_H_ | |
37 | 37 | |||
38 | #include <sys/mutex.h> | 38 | #include <sys/mutex.h> | |
39 | 39 | |||
40 | struct buf; | 40 | struct buf; | |
41 | struct componentname; | 41 | struct componentname; | |
42 | struct direct; | |||
43 | struct disklabel; | 42 | struct disklabel; | |
44 | struct dquot; | 43 | struct dquot; | |
45 | struct fid; | 44 | struct fid; | |
46 | struct flock; | 45 | struct flock; | |
47 | struct indir; | 46 | struct indir; | |
48 | struct inode; | 47 | struct inode; | |
49 | struct mbuf; | 48 | struct mbuf; | |
50 | struct mount; | 49 | struct mount; | |
51 | struct nameidata; | 50 | struct nameidata; | |
51 | struct lfs_direct; | |||
52 | struct lwp; | 52 | struct lwp; | |
53 | struct ulfs_ufid; | |||
54 | struct ulfs_args; | 53 | struct ulfs_args; | |
55 | struct ulfs_lookup_results; | 54 | struct ulfs_lookup_results; | |
55 | struct ulfs_ufid; | |||
56 | struct ulfsmount; | 56 | struct ulfsmount; | |
57 | struct uio; | 57 | struct uio; | |
58 | struct vattr; | 58 | struct vattr; | |
59 | struct vnode; | 59 | struct vnode; | |
60 | 60 | |||
61 | extern pool_cache_t ulfs_direct_cache; /* memory pool for directs */ | 61 | extern pool_cache_t ulfs_direct_cache; /* memory pool for lfs_directs */ | |
62 | 62 | |||
63 | __BEGIN_DECLS | 63 | __BEGIN_DECLS | |
64 | #define ulfs_abortop genfs_abortop | 64 | #define ulfs_abortop genfs_abortop | |
65 | int ulfs_access(void *); | 65 | int ulfs_access(void *); | |
66 | int ulfs_advlock(void *); | 66 | int ulfs_advlock(void *); | |
67 | int ulfs_bmap(void *); | 67 | int ulfs_bmap(void *); | |
68 | int ulfs_close(void *); | 68 | int ulfs_close(void *); | |
69 | int ulfs_create(void *); | 69 | int ulfs_create(void *); | |
70 | int ulfs_getattr(void *); | 70 | int ulfs_getattr(void *); | |
71 | int ulfs_inactive(void *); | 71 | int ulfs_inactive(void *); | |
72 | #define ulfs_fcntl genfs_fcntl | 72 | #define ulfs_fcntl genfs_fcntl | |
73 | #define ulfs_ioctl genfs_enoioctl | 73 | #define ulfs_ioctl genfs_enoioctl | |
74 | #define ulfs_islocked genfs_islocked | 74 | #define ulfs_islocked genfs_islocked | |
@@ -114,31 +114,31 @@ void ulfs_ihashinit(void); | @@ -114,31 +114,31 @@ void ulfs_ihashinit(void); | |||
114 | void ulfs_ihashreinit(void); | 114 | void ulfs_ihashreinit(void); | |
115 | void ulfs_ihashdone(void); | 115 | void ulfs_ihashdone(void); | |
116 | struct vnode *ulfs_ihashlookup(dev_t, ino_t); | 116 | struct vnode *ulfs_ihashlookup(dev_t, ino_t); | |
117 | struct vnode *ulfs_ihashget(dev_t, ino_t, int); | 117 | struct vnode *ulfs_ihashget(dev_t, ino_t, int); | |
118 | void ulfs_ihashins(struct inode *); | 118 | void ulfs_ihashins(struct inode *); | |
119 | void ulfs_ihashrem(struct inode *); | 119 | void ulfs_ihashrem(struct inode *); | |
120 | 120 | |||
121 | /* ulfs_inode.c */ | 121 | /* ulfs_inode.c */ | |
122 | int ulfs_reclaim(struct vnode *); | 122 | int ulfs_reclaim(struct vnode *); | |
123 | int ulfs_balloc_range(struct vnode *, off_t, off_t, kauth_cred_t, int); | 123 | int ulfs_balloc_range(struct vnode *, off_t, off_t, kauth_cred_t, int); | |
124 | 124 | |||
125 | /* ulfs_lookup.c */ | 125 | /* ulfs_lookup.c */ | |
126 | void ulfs_dirbad(struct inode *, doff_t, const char *); | 126 | void ulfs_dirbad(struct inode *, doff_t, const char *); | |
127 | int ulfs_dirbadentry(struct vnode *, struct direct *, int); | 127 | int ulfs_dirbadentry(struct vnode *, struct lfs_direct *, int); | |
128 | void ulfs_makedirentry(struct inode *, struct componentname *, | 128 | void ulfs_makedirentry(struct inode *, struct componentname *, | |
129 | struct direct *); | 129 | struct lfs_direct *); | |
130 | int ulfs_direnter(struct vnode *, const struct ulfs_lookup_results *, | 130 | int ulfs_direnter(struct vnode *, const struct ulfs_lookup_results *, | |
131 | struct vnode *, struct direct *, | 131 | struct vnode *, struct lfs_direct *, | |
132 | struct componentname *, struct buf *); | 132 | struct componentname *, struct buf *); | |
133 | int ulfs_dirremove(struct vnode *, const struct ulfs_lookup_results *, | 133 | int ulfs_dirremove(struct vnode *, const struct ulfs_lookup_results *, | |
134 | struct inode *, int, int); | 134 | struct inode *, int, int); | |
135 | int ulfs_dirrewrite(struct inode *, off_t, | 135 | int ulfs_dirrewrite(struct inode *, off_t, | |
136 | struct inode *, ino_t, int, int, int); | 136 | struct inode *, ino_t, int, int, int); | |
137 | int ulfs_dirempty(struct inode *, ino_t, kauth_cred_t); | 137 | int ulfs_dirempty(struct inode *, ino_t, kauth_cred_t); | |
138 | int ulfs_checkpath(struct inode *, struct inode *, kauth_cred_t); | 138 | int ulfs_checkpath(struct inode *, struct inode *, kauth_cred_t); | |
139 | int ulfs_parentcheck(struct vnode *, struct vnode *, kauth_cred_t, | 139 | int ulfs_parentcheck(struct vnode *, struct vnode *, kauth_cred_t, | |
140 | int *, struct vnode **); | 140 | int *, struct vnode **); | |
141 | int ulfs_blkatoff(struct vnode *, off_t, char **, struct buf **, bool); | 141 | int ulfs_blkatoff(struct vnode *, off_t, char **, struct buf **, bool); | |
142 | 142 | |||
143 | /* ulfs_rename.c -- for lfs */ | 143 | /* ulfs_rename.c -- for lfs */ | |
144 | bool ulfs_gro_directory_empty_p(struct mount *, kauth_cred_t, | 144 | bool ulfs_gro_directory_empty_p(struct mount *, kauth_cred_t, |
--- src/sys/ufs/lfs/ulfs_lookup.c 2013/06/06 00:50:51 1.6
+++ src/sys/ufs/lfs/ulfs_lookup.c 2013/06/08 02:12:56 1.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ulfs_lookup.c,v 1.6 2013/06/06 00:50:51 dholland Exp $ */ | 1 | /* $NetBSD: ulfs_lookup.c,v 1.7 2013/06/08 02:12:56 dholland Exp $ */ | |
2 | /* from NetBSD: ufs_lookup.c,v 1.122 2013/01/22 09:39:18 dholland Exp */ | 2 | /* from NetBSD: ufs_lookup.c,v 1.122 2013/01/22 09:39:18 dholland Exp */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 1989, 1993 | 5 | * Copyright (c) 1989, 1993 | |
6 | * The Regents of the University of California. All rights reserved. | 6 | * The Regents of the University of California. All rights reserved. | |
7 | * (c) UNIX System Laboratories, Inc. | 7 | * (c) UNIX System Laboratories, Inc. | |
8 | * All or some portions of this file are derived from material licensed | 8 | * All or some portions of this file are derived from material licensed | |
9 | * to the University of California by American Telephone and Telegraph | 9 | * to the University of California by American Telephone and Telegraph | |
10 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | 10 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | |
11 | * the permission of UNIX System Laboratories, Inc. | 11 | * the permission of UNIX System Laboratories, Inc. | |
12 | * | 12 | * | |
13 | * Redistribution and use in source and binary forms, with or without | 13 | * Redistribution and use in source and binary forms, with or without | |
14 | * modification, are permitted provided that the following conditions | 14 | * modification, are permitted provided that the following conditions | |
@@ -28,27 +28,27 @@ | @@ -28,27 +28,27 @@ | |||
28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
35 | * SUCH DAMAGE. | 35 | * SUCH DAMAGE. | |
36 | * | 36 | * | |
37 | * @(#)ufs_lookup.c 8.9 (Berkeley) 8/11/94 | 37 | * @(#)ufs_lookup.c 8.9 (Berkeley) 8/11/94 | |
38 | */ | 38 | */ | |
39 | 39 | |||
40 | #include <sys/cdefs.h> | 40 | #include <sys/cdefs.h> | |
41 | __KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.6 2013/06/06 00:50:51 dholland Exp $"); | 41 | __KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.7 2013/06/08 02:12:56 dholland Exp $"); | |
42 | 42 | |||
43 | #ifdef _KERNEL_OPT | 43 | #ifdef _KERNEL_OPT | |
44 | #include "opt_lfs.h" | 44 | #include "opt_lfs.h" | |
45 | #endif | 45 | #endif | |
46 | 46 | |||
47 | #include <sys/param.h> | 47 | #include <sys/param.h> | |
48 | #include <sys/systm.h> | 48 | #include <sys/systm.h> | |
49 | #include <sys/namei.h> | 49 | #include <sys/namei.h> | |
50 | #include <sys/buf.h> | 50 | #include <sys/buf.h> | |
51 | #include <sys/file.h> | 51 | #include <sys/file.h> | |
52 | #include <sys/stat.h> | 52 | #include <sys/stat.h> | |
53 | #include <sys/mount.h> | 53 | #include <sys/mount.h> | |
54 | #include <sys/vnode.h> | 54 | #include <sys/vnode.h> | |
@@ -111,27 +111,27 @@ int lfs_dirchk = 0; | @@ -111,27 +111,27 @@ int lfs_dirchk = 0; | |||
111 | * nor deleting, add name to cache | 111 | * nor deleting, add name to cache | |
112 | */ | 112 | */ | |
113 | int | 113 | int | |
114 | ulfs_lookup(void *v) | 114 | ulfs_lookup(void *v) | |
115 | { | 115 | { | |
116 | struct vop_lookup_args /* { | 116 | struct vop_lookup_args /* { | |
117 | struct vnode *a_dvp; | 117 | struct vnode *a_dvp; | |
118 | struct vnode **a_vpp; | 118 | struct vnode **a_vpp; | |
119 | struct componentname *a_cnp; | 119 | struct componentname *a_cnp; | |
120 | } */ *ap = v; | 120 | } */ *ap = v; | |
121 | struct vnode *vdp = ap->a_dvp; /* vnode for directory being searched */ | 121 | struct vnode *vdp = ap->a_dvp; /* vnode for directory being searched */ | |
122 | struct inode *dp = VTOI(vdp); /* inode for directory being searched */ | 122 | struct inode *dp = VTOI(vdp); /* inode for directory being searched */ | |
123 | struct buf *bp; /* a buffer of directory entries */ | 123 | struct buf *bp; /* a buffer of directory entries */ | |
124 | struct direct *ep; /* the current directory entry */ | 124 | struct lfs_direct *ep; /* the current directory entry */ | |
125 | int entryoffsetinblock; /* offset of ep in bp's buffer */ | 125 | int entryoffsetinblock; /* offset of ep in bp's buffer */ | |
126 | enum { | 126 | enum { | |
127 | NONE, /* need to search a slot for our new entry */ | 127 | NONE, /* need to search a slot for our new entry */ | |
128 | COMPACT, /* a compaction can make a slot in the current | 128 | COMPACT, /* a compaction can make a slot in the current | |
129 | DIRBLKSIZ block */ | 129 | DIRBLKSIZ block */ | |
130 | FOUND, /* found a slot (or no need to search) */ | 130 | FOUND, /* found a slot (or no need to search) */ | |
131 | } slotstatus; | 131 | } slotstatus; | |
132 | doff_t slotoffset; /* offset of area with free space. | 132 | doff_t slotoffset; /* offset of area with free space. | |
133 | a special value -1 for invalid */ | 133 | a special value -1 for invalid */ | |
134 | int slotsize; /* size of area at slotoffset */ | 134 | int slotsize; /* size of area at slotoffset */ | |
135 | int slotfreespace; /* accumulated amount of space free in | 135 | int slotfreespace; /* accumulated amount of space free in | |
136 | the current DIRBLKSIZ block */ | 136 | the current DIRBLKSIZ block */ | |
137 | int slotneeded; /* size of the entry we're seeking */ | 137 | int slotneeded; /* size of the entry we're seeking */ | |
@@ -253,27 +253,27 @@ ulfs_lookup(void *v) | @@ -253,27 +253,27 @@ ulfs_lookup(void *v) | |||
253 | if (slotoffset >= 0) { | 253 | if (slotoffset >= 0) { | |
254 | slotstatus = COMPACT; | 254 | slotstatus = COMPACT; | |
255 | enduseful = ulfsdirhash_enduseful(dp); | 255 | enduseful = ulfsdirhash_enduseful(dp); | |
256 | if (enduseful < 0) | 256 | if (enduseful < 0) | |
257 | enduseful = dp->i_size; | 257 | enduseful = dp->i_size; | |
258 | } | 258 | } | |
259 | } | 259 | } | |
260 | /* Look up the component. */ | 260 | /* Look up the component. */ | |
261 | numdirpasses = 1; | 261 | numdirpasses = 1; | |
262 | entryoffsetinblock = 0; /* silence compiler warning */ | 262 | entryoffsetinblock = 0; /* silence compiler warning */ | |
263 | switch (ulfsdirhash_lookup(dp, cnp->cn_nameptr, cnp->cn_namelen, | 263 | switch (ulfsdirhash_lookup(dp, cnp->cn_nameptr, cnp->cn_namelen, | |
264 | &results->ulr_offset, &bp, nameiop == DELETE ? &prevoff : NULL)) { | 264 | &results->ulr_offset, &bp, nameiop == DELETE ? &prevoff : NULL)) { | |
265 | case 0: | 265 | case 0: | |
266 | ep = (struct direct *)((char *)bp->b_data + | 266 | ep = (struct lfs_direct *)((char *)bp->b_data + | |
267 | (results->ulr_offset & bmask)); | 267 | (results->ulr_offset & bmask)); | |
268 | goto foundentry; | 268 | goto foundentry; | |
269 | case ENOENT: | 269 | case ENOENT: | |
270 | results->ulr_offset = roundup(dp->i_size, dirblksiz); | 270 | results->ulr_offset = roundup(dp->i_size, dirblksiz); | |
271 | goto notfound; | 271 | goto notfound; | |
272 | default: | 272 | default: | |
273 | /* Something failed; just do a linear search. */ | 273 | /* Something failed; just do a linear search. */ | |
274 | break; | 274 | break; | |
275 | } | 275 | } | |
276 | } | 276 | } | |
277 | #endif /* LFS_DIRHASH */ | 277 | #endif /* LFS_DIRHASH */ | |
278 | 278 | |||
279 | if (nameiop != LOOKUP || results->ulr_diroff == 0 || | 279 | if (nameiop != LOOKUP || results->ulr_diroff == 0 || | |
@@ -317,27 +317,27 @@ searchloop: | @@ -317,27 +317,27 @@ searchloop: | |||
317 | if (slotstatus == NONE && | 317 | if (slotstatus == NONE && | |
318 | (entryoffsetinblock & (dirblksiz - 1)) == 0) { | 318 | (entryoffsetinblock & (dirblksiz - 1)) == 0) { | |
319 | slotoffset = -1; | 319 | slotoffset = -1; | |
320 | slotfreespace = 0; | 320 | slotfreespace = 0; | |
321 | } | 321 | } | |
322 | /* | 322 | /* | |
323 | * Get pointer to next entry. | 323 | * Get pointer to next entry. | |
324 | * Full validation checks are slow, so we only check | 324 | * Full validation checks are slow, so we only check | |
325 | * enough to insure forward progress through the | 325 | * enough to insure forward progress through the | |
326 | * directory. Complete checks can be run by patching | 326 | * directory. Complete checks can be run by patching | |
327 | * "lfs_dirchk" to be true. | 327 | * "lfs_dirchk" to be true. | |
328 | */ | 328 | */ | |
329 | KASSERT(bp != NULL); | 329 | KASSERT(bp != NULL); | |
330 | ep = (struct direct *)((char *)bp->b_data + entryoffsetinblock); | 330 | ep = (struct lfs_direct *)((char *)bp->b_data + entryoffsetinblock); | |
331 | if (ep->d_reclen == 0 || | 331 | if (ep->d_reclen == 0 || | |
332 | (lfs_dirchk && ulfs_dirbadentry(vdp, ep, entryoffsetinblock))) { | 332 | (lfs_dirchk && ulfs_dirbadentry(vdp, ep, entryoffsetinblock))) { | |
333 | int i; | 333 | int i; | |
334 | 334 | |||
335 | ulfs_dirbad(dp, results->ulr_offset, "mangled entry"); | 335 | ulfs_dirbad(dp, results->ulr_offset, "mangled entry"); | |
336 | i = dirblksiz - (entryoffsetinblock & (dirblksiz - 1)); | 336 | i = dirblksiz - (entryoffsetinblock & (dirblksiz - 1)); | |
337 | results->ulr_offset += i; | 337 | results->ulr_offset += i; | |
338 | entryoffsetinblock += i; | 338 | entryoffsetinblock += i; | |
339 | continue; | 339 | continue; | |
340 | } | 340 | } | |
341 | 341 | |||
342 | /* | 342 | /* | |
343 | * If an appropriate sized slot has not yet been found, | 343 | * If an appropriate sized slot has not yet been found, | |
@@ -388,27 +388,27 @@ searchloop: | @@ -388,27 +388,27 @@ searchloop: | |||
388 | else | 388 | else | |
389 | namlen = ep->d_namlen; | 389 | namlen = ep->d_namlen; | |
390 | #endif | 390 | #endif | |
391 | if (namlen == cnp->cn_namelen && | 391 | if (namlen == cnp->cn_namelen && | |
392 | !memcmp(cnp->cn_nameptr, ep->d_name, | 392 | !memcmp(cnp->cn_nameptr, ep->d_name, | |
393 | (unsigned)namlen)) { | 393 | (unsigned)namlen)) { | |
394 | #ifdef LFS_DIRHASH | 394 | #ifdef LFS_DIRHASH | |
395 | foundentry: | 395 | foundentry: | |
396 | #endif | 396 | #endif | |
397 | /* | 397 | /* | |
398 | * Save directory entry's inode number and | 398 | * Save directory entry's inode number and | |
399 | * reclen, and release directory buffer. | 399 | * reclen, and release directory buffer. | |
400 | */ | 400 | */ | |
401 | if (!FSFMT(vdp) && ep->d_type == DT_WHT) { | 401 | if (!FSFMT(vdp) && ep->d_type == LFS_DT_WHT) { | |
402 | slotstatus = FOUND; | 402 | slotstatus = FOUND; | |
403 | slotoffset = results->ulr_offset; | 403 | slotoffset = results->ulr_offset; | |
404 | slotsize = ulfs_rw16(ep->d_reclen, | 404 | slotsize = ulfs_rw16(ep->d_reclen, | |
405 | needswap); | 405 | needswap); | |
406 | results->ulr_reclen = slotsize; | 406 | results->ulr_reclen = slotsize; | |
407 | /* | 407 | /* | |
408 | * This is used to set | 408 | * This is used to set | |
409 | * results->ulr_endoff, | 409 | * results->ulr_endoff, | |
410 | * which may be used by ulfs_direnter() | 410 | * which may be used by ulfs_direnter() | |
411 | * as a length to truncate the | 411 | * as a length to truncate the | |
412 | * directory to. Therefore, it must | 412 | * directory to. Therefore, it must | |
413 | * point past the end of the last | 413 | * point past the end of the last | |
414 | * non-empty directory entry. We don't | 414 | * non-empty directory entry. We don't | |
@@ -701,27 +701,27 @@ ulfs_dirbad(struct inode *ip, doff_t off | @@ -701,27 +701,27 @@ ulfs_dirbad(struct inode *ip, doff_t off | |||
701 | if ((mp->mnt_stat.f_flag & MNT_RDONLY) == 0) | 701 | if ((mp->mnt_stat.f_flag & MNT_RDONLY) == 0) | |
702 | panic("bad dir"); | 702 | panic("bad dir"); | |
703 | } | 703 | } | |
704 | 704 | |||
705 | /* | 705 | /* | |
706 | * Do consistency checking on a directory entry: | 706 | * Do consistency checking on a directory entry: | |
707 | * record length must be multiple of 4 | 707 | * record length must be multiple of 4 | |
708 | * entry must fit in rest of its DIRBLKSIZ block | 708 | * entry must fit in rest of its DIRBLKSIZ block | |
709 | * record must be large enough to contain entry | 709 | * record must be large enough to contain entry | |
710 | * name is not longer than FFS_MAXNAMLEN | 710 | * name is not longer than FFS_MAXNAMLEN | |
711 | * name must be as long as advertised, and null terminated | 711 | * name must be as long as advertised, and null terminated | |
712 | */ | 712 | */ | |
713 | int | 713 | int | |
714 | ulfs_dirbadentry(struct vnode *dp, struct direct *ep, int entryoffsetinblock) | 714 | ulfs_dirbadentry(struct vnode *dp, struct lfs_direct *ep, int entryoffsetinblock) | |
715 | { | 715 | { | |
716 | int i; | 716 | int i; | |
717 | int namlen; | 717 | int namlen; | |
718 | struct ulfsmount *ump = VFSTOULFS(dp->v_mount); | 718 | struct ulfsmount *ump = VFSTOULFS(dp->v_mount); | |
719 | const int needswap = ULFS_MPNEEDSWAP(ump); | 719 | const int needswap = ULFS_MPNEEDSWAP(ump); | |
720 | int dirblksiz = ump->um_dirblksiz; | 720 | int dirblksiz = ump->um_dirblksiz; | |
721 | 721 | |||
722 | #if (BYTE_ORDER == LITTLE_ENDIAN) | 722 | #if (BYTE_ORDER == LITTLE_ENDIAN) | |
723 | if (FSFMT(dp) && needswap == 0) | 723 | if (FSFMT(dp) && needswap == 0) | |
724 | namlen = ep->d_type; | 724 | namlen = ep->d_type; | |
725 | else | 725 | else | |
726 | namlen = ep->d_namlen; | 726 | namlen = ep->d_namlen; | |
727 | #else | 727 | #else | |
@@ -757,27 +757,27 @@ ulfs_dirbadentry(struct vnode *dp, struc | @@ -757,27 +757,27 @@ ulfs_dirbadentry(struct vnode *dp, struc | |||
757 | goto bad; | 757 | goto bad; | |
758 | return (0); | 758 | return (0); | |
759 | bad: | 759 | bad: | |
760 | return (1); | 760 | return (1); | |
761 | } | 761 | } | |
762 | 762 | |||
763 | /* | 763 | /* | |
764 | * Construct a new directory entry after a call to namei, using the | 764 | * Construct a new directory entry after a call to namei, using the | |
765 | * name in the componentname argument cnp. The argument ip is the | 765 | * name in the componentname argument cnp. The argument ip is the | |
766 | * inode to which the new directory entry will refer. | 766 | * inode to which the new directory entry will refer. | |
767 | */ | 767 | */ | |
768 | void | 768 | void | |
769 | ulfs_makedirentry(struct inode *ip, struct componentname *cnp, | 769 | ulfs_makedirentry(struct inode *ip, struct componentname *cnp, | |
770 | struct direct *newdirp) | 770 | struct lfs_direct *newdirp) | |
771 | { | 771 | { | |
772 | newdirp->d_ino = ip->i_number; | 772 | newdirp->d_ino = ip->i_number; | |
773 | newdirp->d_namlen = cnp->cn_namelen; | 773 | newdirp->d_namlen = cnp->cn_namelen; | |
774 | memcpy(newdirp->d_name, cnp->cn_nameptr, (size_t)cnp->cn_namelen); | 774 | memcpy(newdirp->d_name, cnp->cn_nameptr, (size_t)cnp->cn_namelen); | |
775 | newdirp->d_name[cnp->cn_namelen] = '\0'; | 775 | newdirp->d_name[cnp->cn_namelen] = '\0'; | |
776 | if (FSFMT(ITOV(ip))) | 776 | if (FSFMT(ITOV(ip))) | |
777 | newdirp->d_type = 0; | 777 | newdirp->d_type = 0; | |
778 | else | 778 | else | |
779 | newdirp->d_type = IFTODT(ip->i_mode); | 779 | newdirp->d_type = IFTODT(ip->i_mode); | |
780 | } | 780 | } | |
781 | 781 | |||
782 | /* | 782 | /* | |
783 | * Write a directory entry after a call to namei, using the parameters | 783 | * Write a directory entry after a call to namei, using the parameters | |
@@ -800,36 +800,36 @@ ulfs_makedirentry(struct inode *ip, stru | @@ -800,36 +800,36 @@ ulfs_makedirentry(struct inode *ip, stru | |||
800 | * directory AFAIK) and a fresh block is allocated to put the new | 800 | * directory AFAIK) and a fresh block is allocated to put the new | |
801 | * directory entry in. | 801 | * directory entry in. | |
802 | * | 802 | * | |
803 | * If ulr->ulr_count is not zero, ulfs_lookup found a slot to insert | 803 | * If ulr->ulr_count is not zero, ulfs_lookup found a slot to insert | |
804 | * the entry into. This slot ranges from ulr_offset to ulr_offset + | 804 | * the entry into. This slot ranges from ulr_offset to ulr_offset + | |
805 | * ulr_count. However, this slot may already be partially populated | 805 | * ulr_count. However, this slot may already be partially populated | |
806 | * requiring compaction. See notes below. | 806 | * requiring compaction. See notes below. | |
807 | * | 807 | * | |
808 | * Furthermore, if ulr_count is not zero and ulr_endoff is not the | 808 | * Furthermore, if ulr_count is not zero and ulr_endoff is not the | |
809 | * same as i_size, the directory is truncated to size ulr_endoff. | 809 | * same as i_size, the directory is truncated to size ulr_endoff. | |
810 | */ | 810 | */ | |
811 | int | 811 | int | |
812 | ulfs_direnter(struct vnode *dvp, const struct ulfs_lookup_results *ulr, | 812 | ulfs_direnter(struct vnode *dvp, const struct ulfs_lookup_results *ulr, | |
813 | struct vnode *tvp, struct direct *dirp, | 813 | struct vnode *tvp, struct lfs_direct *dirp, | |
814 | struct componentname *cnp, struct buf *newdirbp) | 814 | struct componentname *cnp, struct buf *newdirbp) | |
815 | { | 815 | { | |
816 | kauth_cred_t cr; | 816 | kauth_cred_t cr; | |
817 | struct lwp *l; | 817 | struct lwp *l; | |
818 | int newentrysize; | 818 | int newentrysize; | |
819 | struct inode *dp; | 819 | struct inode *dp; | |
820 | struct buf *bp; | 820 | struct buf *bp; | |
821 | u_int dsize; | 821 | u_int dsize; | |
822 | struct direct *ep, *nep; | 822 | struct lfs_direct *ep, *nep; | |
823 | int error, ret, blkoff, loc, spacefree; | 823 | int error, ret, blkoff, loc, spacefree; | |
824 | char *dirbuf; | 824 | char *dirbuf; | |
825 | struct timespec ts; | 825 | struct timespec ts; | |
826 | struct ulfsmount *ump = VFSTOULFS(dvp->v_mount); | 826 | struct ulfsmount *ump = VFSTOULFS(dvp->v_mount); | |
827 | const int needswap = ULFS_MPNEEDSWAP(ump); | 827 | const int needswap = ULFS_MPNEEDSWAP(ump); | |
828 | int dirblksiz = ump->um_dirblksiz; | 828 | int dirblksiz = ump->um_dirblksiz; | |
829 | 829 | |||
830 | ULFS_WAPBL_JLOCK_ASSERT(dvp->v_mount); | 830 | ULFS_WAPBL_JLOCK_ASSERT(dvp->v_mount); | |
831 | 831 | |||
832 | error = 0; | 832 | error = 0; | |
833 | cr = cnp->cn_cred; | 833 | cr = cnp->cn_cred; | |
834 | l = curlwp; | 834 | l = curlwp; | |
835 | 835 | |||
@@ -913,37 +913,37 @@ ulfs_direnter(struct vnode *dvp, const s | @@ -913,37 +913,37 @@ ulfs_direnter(struct vnode *dvp, const s | |||
913 | /* | 913 | /* | |
914 | * Get the block containing the space for the new directory entry. | 914 | * Get the block containing the space for the new directory entry. | |
915 | */ | 915 | */ | |
916 | error = ulfs_blkatoff(dvp, (off_t)ulr->ulr_offset, &dirbuf, &bp, true); | 916 | error = ulfs_blkatoff(dvp, (off_t)ulr->ulr_offset, &dirbuf, &bp, true); | |
917 | if (error) { | 917 | if (error) { | |
918 | return (error); | 918 | return (error); | |
919 | } | 919 | } | |
920 | /* | 920 | /* | |
921 | * Find space for the new entry. In the simple case, the entry at | 921 | * Find space for the new entry. In the simple case, the entry at | |
922 | * offset base will have the space. If it does not, then namei | 922 | * offset base will have the space. If it does not, then namei | |
923 | * arranged that compacting the region ulr_offset to | 923 | * arranged that compacting the region ulr_offset to | |
924 | * ulr_offset + ulr_count would yield the space. | 924 | * ulr_offset + ulr_count would yield the space. | |
925 | */ | 925 | */ | |
926 | ep = (struct direct *)dirbuf; | 926 | ep = (struct lfs_direct *)dirbuf; | |
927 | dsize = (ep->d_ino != 0) ? DIRSIZ(FSFMT(dvp), ep, needswap) : 0; | 927 | dsize = (ep->d_ino != 0) ? DIRSIZ(FSFMT(dvp), ep, needswap) : 0; | |
928 | spacefree = ulfs_rw16(ep->d_reclen, needswap) - dsize; | 928 | spacefree = ulfs_rw16(ep->d_reclen, needswap) - dsize; | |
929 | for (loc = ulfs_rw16(ep->d_reclen, needswap); loc < ulr->ulr_count; ) { | 929 | for (loc = ulfs_rw16(ep->d_reclen, needswap); loc < ulr->ulr_count; ) { | |
930 | uint16_t reclen; | 930 | uint16_t reclen; | |
931 | 931 | |||
932 | nep = (struct direct *)(dirbuf + loc); | 932 | nep = (struct lfs_direct *)(dirbuf + loc); | |
933 | 933 | |||
934 | /* Trim the existing slot (NB: dsize may be zero). */ | 934 | /* Trim the existing slot (NB: dsize may be zero). */ | |
935 | ep->d_reclen = ulfs_rw16(dsize, needswap); | 935 | ep->d_reclen = ulfs_rw16(dsize, needswap); | |
936 | ep = (struct direct *)((char *)ep + dsize); | 936 | ep = (struct lfs_direct *)((char *)ep + dsize); | |
937 | 937 | |||
938 | reclen = ulfs_rw16(nep->d_reclen, needswap); | 938 | reclen = ulfs_rw16(nep->d_reclen, needswap); | |
939 | loc += reclen; | 939 | loc += reclen; | |
940 | if (nep->d_ino == 0) { | 940 | if (nep->d_ino == 0) { | |
941 | /* | 941 | /* | |
942 | * A mid-block unused entry. Such entries are | 942 | * A mid-block unused entry. Such entries are | |
943 | * never created by the kernel, but fsck_ffs | 943 | * never created by the kernel, but fsck_ffs | |
944 | * can create them (and it doesn't fix them). | 944 | * can create them (and it doesn't fix them). | |
945 | * | 945 | * | |
946 | * Add up the free space, and initialise the | 946 | * Add up the free space, and initialise the | |
947 | * relocated entry since we don't memcpy it. | 947 | * relocated entry since we don't memcpy it. | |
948 | */ | 948 | */ | |
949 | spacefree += reclen; | 949 | spacefree += reclen; | |
@@ -971,27 +971,27 @@ ulfs_direnter(struct vnode *dvp, const s | @@ -971,27 +971,27 @@ ulfs_direnter(struct vnode *dvp, const s | |||
971 | * copy in the new entry, and write out the block. | 971 | * copy in the new entry, and write out the block. | |
972 | */ | 972 | */ | |
973 | if (ep->d_ino == 0 || | 973 | if (ep->d_ino == 0 || | |
974 | (ulfs_rw32(ep->d_ino, needswap) == ULFS_WINO && | 974 | (ulfs_rw32(ep->d_ino, needswap) == ULFS_WINO && | |
975 | memcmp(ep->d_name, dirp->d_name, dirp->d_namlen) == 0)) { | 975 | memcmp(ep->d_name, dirp->d_name, dirp->d_namlen) == 0)) { | |
976 | if (spacefree + dsize < newentrysize) | 976 | if (spacefree + dsize < newentrysize) | |
977 | panic("ulfs_direnter: compact1"); | 977 | panic("ulfs_direnter: compact1"); | |
978 | dirp->d_reclen = spacefree + dsize; | 978 | dirp->d_reclen = spacefree + dsize; | |
979 | } else { | 979 | } else { | |
980 | if (spacefree < newentrysize) | 980 | if (spacefree < newentrysize) | |
981 | panic("ulfs_direnter: compact2"); | 981 | panic("ulfs_direnter: compact2"); | |
982 | dirp->d_reclen = spacefree; | 982 | dirp->d_reclen = spacefree; | |
983 | ep->d_reclen = ulfs_rw16(dsize, needswap); | 983 | ep->d_reclen = ulfs_rw16(dsize, needswap); | |
984 | ep = (struct direct *)((char *)ep + dsize); | 984 | ep = (struct lfs_direct *)((char *)ep + dsize); | |
985 | } | 985 | } | |
986 | dirp->d_reclen = ulfs_rw16(dirp->d_reclen, needswap); | 986 | dirp->d_reclen = ulfs_rw16(dirp->d_reclen, needswap); | |
987 | dirp->d_ino = ulfs_rw32(dirp->d_ino, needswap); | 987 | dirp->d_ino = ulfs_rw32(dirp->d_ino, needswap); | |
988 | if (FSFMT(dvp)) { | 988 | if (FSFMT(dvp)) { | |
989 | #if (BYTE_ORDER == LITTLE_ENDIAN) | 989 | #if (BYTE_ORDER == LITTLE_ENDIAN) | |
990 | if (needswap == 0) { | 990 | if (needswap == 0) { | |
991 | #else | 991 | #else | |
992 | if (needswap != 0) { | 992 | if (needswap != 0) { | |
993 | #endif | 993 | #endif | |
994 | u_char tmp = dirp->d_namlen; | 994 | u_char tmp = dirp->d_namlen; | |
995 | dirp->d_namlen = dirp->d_type; | 995 | dirp->d_namlen = dirp->d_type; | |
996 | dirp->d_type = tmp; | 996 | dirp->d_type = tmp; | |
997 | } | 997 | } | |
@@ -1058,60 +1058,60 @@ ulfs_direnter(struct vnode *dvp, const s | @@ -1058,60 +1058,60 @@ ulfs_direnter(struct vnode *dvp, const s | |||
1058 | * The space is marked free by adding it to the record length (not | 1058 | * The space is marked free by adding it to the record length (not | |
1059 | * name length) of the preceding entry. If the first entry becomes | 1059 | * name length) of the preceding entry. If the first entry becomes | |
1060 | * free, it is marked free by setting the inode number to 0. | 1060 | * free, it is marked free by setting the inode number to 0. | |
1061 | * | 1061 | * | |
1062 | * The link count of IP is decremented. Note that this is not the | 1062 | * The link count of IP is decremented. Note that this is not the | |
1063 | * inverse behavior of ulfs_direnter, which does not adjust link | 1063 | * inverse behavior of ulfs_direnter, which does not adjust link | |
1064 | * counts. Sigh. | 1064 | * counts. Sigh. | |
1065 | */ | 1065 | */ | |
1066 | int | 1066 | int | |
1067 | ulfs_dirremove(struct vnode *dvp, const struct ulfs_lookup_results *ulr, | 1067 | ulfs_dirremove(struct vnode *dvp, const struct ulfs_lookup_results *ulr, | |
1068 | struct inode *ip, int flags, int isrmdir) | 1068 | struct inode *ip, int flags, int isrmdir) | |
1069 | { | 1069 | { | |
1070 | struct inode *dp = VTOI(dvp); | 1070 | struct inode *dp = VTOI(dvp); | |
1071 | struct direct *ep; | 1071 | struct lfs_direct *ep; | |
1072 | struct buf *bp; | 1072 | struct buf *bp; | |
1073 | int error; | 1073 | int error; | |
1074 | #ifdef LFS_EI | 1074 | #ifdef LFS_EI | |
1075 | const int needswap = ULFS_MPNEEDSWAP(dp->i_ump); | 1075 | const int needswap = ULFS_MPNEEDSWAP(dp->i_ump); | |
1076 | #endif | 1076 | #endif | |
1077 | 1077 | |||
1078 | ULFS_WAPBL_JLOCK_ASSERT(dvp->v_mount); | 1078 | ULFS_WAPBL_JLOCK_ASSERT(dvp->v_mount); | |
1079 | 1079 | |||
1080 | if (flags & DOWHITEOUT) { | 1080 | if (flags & DOWHITEOUT) { | |
1081 | /* | 1081 | /* | |
1082 | * Whiteout entry: set d_ino to ULFS_WINO. | 1082 | * Whiteout entry: set d_ino to ULFS_WINO. | |
1083 | */ | 1083 | */ | |
1084 | error = ulfs_blkatoff(dvp, (off_t)ulr->ulr_offset, (void *)&ep, | 1084 | error = ulfs_blkatoff(dvp, (off_t)ulr->ulr_offset, (void *)&ep, | |
1085 | &bp, true); | 1085 | &bp, true); | |
1086 | if (error) | 1086 | if (error) | |
1087 | return (error); | 1087 | return (error); | |
1088 | ep->d_ino = ulfs_rw32(ULFS_WINO, needswap); | 1088 | ep->d_ino = ulfs_rw32(ULFS_WINO, needswap); | |
1089 | ep->d_type = DT_WHT; | 1089 | ep->d_type = LFS_DT_WHT; | |
1090 | goto out; | 1090 | goto out; | |
1091 | } | 1091 | } | |
1092 | 1092 | |||
1093 | if ((error = ulfs_blkatoff(dvp, | 1093 | if ((error = ulfs_blkatoff(dvp, | |
1094 | (off_t)(ulr->ulr_offset - ulr->ulr_count), (void *)&ep, &bp, true)) != 0) | 1094 | (off_t)(ulr->ulr_offset - ulr->ulr_count), (void *)&ep, &bp, true)) != 0) | |
1095 | return (error); | 1095 | return (error); | |
1096 | 1096 | |||
1097 | #ifdef LFS_DIRHASH | 1097 | #ifdef LFS_DIRHASH | |
1098 | /* | 1098 | /* | |
1099 | * Remove the dirhash entry. This is complicated by the fact | 1099 | * Remove the dirhash entry. This is complicated by the fact | |
1100 | * that `ep' is the previous entry when ulr_count != 0. | 1100 | * that `ep' is the previous entry when ulr_count != 0. | |
1101 | */ | 1101 | */ | |
1102 | if (dp->i_dirhash != NULL) | 1102 | if (dp->i_dirhash != NULL) | |
1103 | ulfsdirhash_remove(dp, (ulr->ulr_count == 0) ? ep : | 1103 | ulfsdirhash_remove(dp, (ulr->ulr_count == 0) ? ep : | |
1104 | (struct direct *)((char *)ep + | 1104 | (struct lfs_direct *)((char *)ep + | |
1105 | ulfs_rw16(ep->d_reclen, needswap)), ulr->ulr_offset); | 1105 | ulfs_rw16(ep->d_reclen, needswap)), ulr->ulr_offset); | |
1106 | #endif | 1106 | #endif | |
1107 | 1107 | |||
1108 | if (ulr->ulr_count == 0) { | 1108 | if (ulr->ulr_count == 0) { | |
1109 | /* | 1109 | /* | |
1110 | * First entry in block: set d_ino to zero. | 1110 | * First entry in block: set d_ino to zero. | |
1111 | */ | 1111 | */ | |
1112 | ep->d_ino = 0; | 1112 | ep->d_ino = 0; | |
1113 | } else { | 1113 | } else { | |
1114 | /* | 1114 | /* | |
1115 | * Collapse new free space into previous entry. | 1115 | * Collapse new free space into previous entry. | |
1116 | */ | 1116 | */ | |
1117 | ep->d_reclen = | 1117 | ep->d_reclen = | |
@@ -1168,27 +1168,27 @@ out: | @@ -1168,27 +1168,27 @@ out: | |||
1168 | * (This is ignored if the fs doesn't support that.) | 1168 | * (This is ignored if the fs doesn't support that.) | |
1169 | * ISRMDIR is not used and (XXX) should be removed. | 1169 | * ISRMDIR is not used and (XXX) should be removed. | |
1170 | * IFLAGS are added to DP's inode flags. | 1170 | * IFLAGS are added to DP's inode flags. | |
1171 | * | 1171 | * | |
1172 | * The link count of OIP is decremented. Note that the link count of | 1172 | * The link count of OIP is decremented. Note that the link count of | |
1173 | * the new inode is *not* incremented. Yay for symmetry. | 1173 | * the new inode is *not* incremented. Yay for symmetry. | |
1174 | */ | 1174 | */ | |
1175 | int | 1175 | int | |
1176 | ulfs_dirrewrite(struct inode *dp, off_t offset, | 1176 | ulfs_dirrewrite(struct inode *dp, off_t offset, | |
1177 | struct inode *oip, ino_t newinum, int newtype, | 1177 | struct inode *oip, ino_t newinum, int newtype, | |
1178 | int isrmdir, int iflags) | 1178 | int isrmdir, int iflags) | |
1179 | { | 1179 | { | |
1180 | struct buf *bp; | 1180 | struct buf *bp; | |
1181 | struct direct *ep; | 1181 | struct lfs_direct *ep; | |
1182 | struct vnode *vdp = ITOV(dp); | 1182 | struct vnode *vdp = ITOV(dp); | |
1183 | int error; | 1183 | int error; | |
1184 | 1184 | |||
1185 | error = ulfs_blkatoff(vdp, offset, (void *)&ep, &bp, true); | 1185 | error = ulfs_blkatoff(vdp, offset, (void *)&ep, &bp, true); | |
1186 | if (error) | 1186 | if (error) | |
1187 | return (error); | 1187 | return (error); | |
1188 | ep->d_ino = ulfs_rw32(newinum, ULFS_MPNEEDSWAP(dp->i_ump)); | 1188 | ep->d_ino = ulfs_rw32(newinum, ULFS_MPNEEDSWAP(dp->i_ump)); | |
1189 | if (!FSFMT(vdp)) | 1189 | if (!FSFMT(vdp)) | |
1190 | ep->d_type = newtype; | 1190 | ep->d_type = newtype; | |
1191 | oip->i_nlink--; | 1191 | oip->i_nlink--; | |
1192 | DIP_ASSIGN(oip, nlink, oip->i_nlink); | 1192 | DIP_ASSIGN(oip, nlink, oip->i_nlink); | |
1193 | oip->i_flag |= IN_CHANGE; | 1193 | oip->i_flag |= IN_CHANGE; | |
1194 | ULFS_WAPBL_UPDATE(ITOV(oip), NULL, NULL, UPDATE_DIROP); | 1194 | ULFS_WAPBL_UPDATE(ITOV(oip), NULL, NULL, UPDATE_DIROP); | |
@@ -1199,41 +1199,41 @@ ulfs_dirrewrite(struct inode *dp, off_t | @@ -1199,41 +1199,41 @@ ulfs_dirrewrite(struct inode *dp, off_t | |||
1199 | * drop its snapshot reference so that it will be reclaimed | 1199 | * drop its snapshot reference so that it will be reclaimed | |
1200 | * when last open reference goes away. | 1200 | * when last open reference goes away. | |
1201 | */ | 1201 | */ | |
1202 | if ((oip->i_flags & SF_SNAPSHOT) != 0 && oip->i_nlink == 0) | 1202 | if ((oip->i_flags & SF_SNAPSHOT) != 0 && oip->i_nlink == 0) | |
1203 | ulfs_snapgone(oip); | 1203 | ulfs_snapgone(oip); | |
1204 | ULFS_WAPBL_UPDATE(vdp, NULL, NULL, UPDATE_DIROP); | 1204 | ULFS_WAPBL_UPDATE(vdp, NULL, NULL, UPDATE_DIROP); | |
1205 | return (error); | 1205 | return (error); | |
1206 | } | 1206 | } | |
1207 | 1207 | |||
1208 | /* | 1208 | /* | |
1209 | * Check if a directory is empty or not. | 1209 | * Check if a directory is empty or not. | |
1210 | * Inode supplied must be locked. | 1210 | * Inode supplied must be locked. | |
1211 | * | 1211 | * | |
1212 | * Using a struct dirtemplate here is not precisely | 1212 | * Using a struct lfs_dirtemplate here is not precisely | |
1213 | * what we want, but better than using a struct direct. | 1213 | * what we want, but better than using a struct lfs_direct. | |
1214 | * | 1214 | * | |
1215 | * NB: does not handle corrupted directories. | 1215 | * NB: does not handle corrupted directories. | |
1216 | */ | 1216 | */ | |
1217 | int | 1217 | int | |
1218 | ulfs_dirempty(struct inode *ip, ino_t parentino, kauth_cred_t cred) | 1218 | ulfs_dirempty(struct inode *ip, ino_t parentino, kauth_cred_t cred) | |
1219 | { | 1219 | { | |
1220 | doff_t off; | 1220 | doff_t off; | |
1221 | struct dirtemplate dbuf; | 1221 | struct lfs_dirtemplate dbuf; | |
1222 | struct direct *dp = (struct direct *)&dbuf; | 1222 | struct lfs_direct *dp = (struct lfs_direct *)&dbuf; | |
1223 | int error, namlen; | 1223 | int error, namlen; | |
1224 | size_t count; | 1224 | size_t count; | |
1225 | const int needswap = ULFS_IPNEEDSWAP(ip); | 1225 | const int needswap = ULFS_IPNEEDSWAP(ip); | |
1226 | #define MINDIRSIZ (sizeof (struct dirtemplate) / 2) | 1226 | #define MINDIRSIZ (sizeof (struct lfs_dirtemplate) / 2) | |
1227 | 1227 | |||
1228 | for (off = 0; off < ip->i_size; | 1228 | for (off = 0; off < ip->i_size; | |
1229 | off += ulfs_rw16(dp->d_reclen, needswap)) { | 1229 | off += ulfs_rw16(dp->d_reclen, needswap)) { | |
1230 | error = vn_rdwr(UIO_READ, ITOV(ip), (void *)dp, MINDIRSIZ, off, | 1230 | error = vn_rdwr(UIO_READ, ITOV(ip), (void *)dp, MINDIRSIZ, off, | |
1231 | UIO_SYSSPACE, IO_NODELOCKED, cred, &count, NULL); | 1231 | UIO_SYSSPACE, IO_NODELOCKED, cred, &count, NULL); | |
1232 | /* | 1232 | /* | |
1233 | * Since we read MINDIRSIZ, residual must | 1233 | * Since we read MINDIRSIZ, residual must | |
1234 | * be 0 unless we're at end of file. | 1234 | * be 0 unless we're at end of file. | |
1235 | */ | 1235 | */ | |
1236 | if (error || count != 0) | 1236 | if (error || count != 0) | |
1237 | return (0); | 1237 | return (0); | |
1238 | /* avoid infinite loops */ | 1238 | /* avoid infinite loops */ | |
1239 | if (dp->d_reclen == 0) | 1239 | if (dp->d_reclen == 0) | |
@@ -1273,46 +1273,46 @@ ulfs_dirempty(struct inode *ip, ino_t pa | @@ -1273,46 +1273,46 @@ ulfs_dirempty(struct inode *ip, ino_t pa | |||
1273 | return (1); | 1273 | return (1); | |
1274 | } | 1274 | } | |
1275 | 1275 | |||
1276 | /* | 1276 | /* | |
1277 | * Check if source directory is in the path of the target directory. | 1277 | * Check if source directory is in the path of the target directory. | |
1278 | * Target is supplied locked, source is unlocked. | 1278 | * Target is supplied locked, source is unlocked. | |
1279 | * The target is always vput before returning. | 1279 | * The target is always vput before returning. | |
1280 | */ | 1280 | */ | |
1281 | int | 1281 | int | |
1282 | ulfs_checkpath(struct inode *source, struct inode *target, kauth_cred_t cred) | 1282 | ulfs_checkpath(struct inode *source, struct inode *target, kauth_cred_t cred) | |
1283 | { | 1283 | { | |
1284 | struct vnode *nextvp, *vp; | 1284 | struct vnode *nextvp, *vp; | |
1285 | int error, rootino, namlen; | 1285 | int error, rootino, namlen; | |
1286 | struct dirtemplate dirbuf; | 1286 | struct lfs_dirtemplate dirbuf; | |
1287 | const int needswap = ULFS_MPNEEDSWAP(target->i_ump); | 1287 | const int needswap = ULFS_MPNEEDSWAP(target->i_ump); | |
1288 | 1288 | |||
1289 | vp = ITOV(target); | 1289 | vp = ITOV(target); | |
1290 | if (target->i_number == source->i_number) { | 1290 | if (target->i_number == source->i_number) { | |
1291 | error = EEXIST; | 1291 | error = EEXIST; | |
1292 | goto out; | 1292 | goto out; | |
1293 | } | 1293 | } | |
1294 | rootino = ULFS_ROOTINO; | 1294 | rootino = ULFS_ROOTINO; | |
1295 | error = 0; | 1295 | error = 0; | |
1296 | if (target->i_number == rootino) | 1296 | if (target->i_number == rootino) | |
1297 | goto out; | 1297 | goto out; | |
1298 | 1298 | |||
1299 | for (;;) { | 1299 | for (;;) { | |
1300 | if (vp->v_type != VDIR) { | 1300 | if (vp->v_type != VDIR) { | |
1301 | error = ENOTDIR; | 1301 | error = ENOTDIR; | |
1302 | break; | 1302 | break; | |
1303 | } | 1303 | } | |
1304 | error = vn_rdwr(UIO_READ, vp, (void *)&dirbuf, | 1304 | error = vn_rdwr(UIO_READ, vp, (void *)&dirbuf, | |
1305 | sizeof (struct dirtemplate), (off_t)0, UIO_SYSSPACE, | 1305 | sizeof (struct lfs_dirtemplate), (off_t)0, UIO_SYSSPACE, | |
1306 | IO_NODELOCKED, cred, NULL, NULL); | 1306 | IO_NODELOCKED, cred, NULL, NULL); | |
1307 | if (error != 0) | 1307 | if (error != 0) | |
1308 | break; | 1308 | break; | |
1309 | #if (BYTE_ORDER == LITTLE_ENDIAN) | 1309 | #if (BYTE_ORDER == LITTLE_ENDIAN) | |
1310 | if (FSFMT(vp) && needswap == 0) | 1310 | if (FSFMT(vp) && needswap == 0) | |
1311 | namlen = dirbuf.dotdot_type; | 1311 | namlen = dirbuf.dotdot_type; | |
1312 | else | 1312 | else | |
1313 | namlen = dirbuf.dotdot_namlen; | 1313 | namlen = dirbuf.dotdot_namlen; | |
1314 | #else | 1314 | #else | |
1315 | if (FSFMT(vp) && needswap != 0) | 1315 | if (FSFMT(vp) && needswap != 0) | |
1316 | namlen = dirbuf.dotdot_type; | 1316 | namlen = dirbuf.dotdot_type; | |
1317 | else | 1317 | else | |
1318 | namlen = dirbuf.dotdot_namlen; | 1318 | namlen = dirbuf.dotdot_namlen; | |
@@ -1345,31 +1345,31 @@ out: | @@ -1345,31 +1345,31 @@ out: | |||
1345 | printf("checkpath: .. not a directory\n"); | 1345 | printf("checkpath: .. not a directory\n"); | |
1346 | if (vp != NULL) | 1346 | if (vp != NULL) | |
1347 | vput(vp); | 1347 | vput(vp); | |
1348 | return (error); | 1348 | return (error); | |
1349 | } | 1349 | } | |
1350 | 1350 | |||
1351 | /* | 1351 | /* | |
1352 | * Extract the inode number of ".." from a directory. | 1352 | * Extract the inode number of ".." from a directory. | |
1353 | * Helper for ulfs_parentcheck. | 1353 | * Helper for ulfs_parentcheck. | |
1354 | */ | 1354 | */ | |
1355 | static int | 1355 | static int | |
1356 | ulfs_readdotdot(struct vnode *vp, int needswap, kauth_cred_t cred, ino_t *result) | 1356 | ulfs_readdotdot(struct vnode *vp, int needswap, kauth_cred_t cred, ino_t *result) | |
1357 | { | 1357 | { | |
1358 | struct dirtemplate dirbuf; | 1358 | struct lfs_dirtemplate dirbuf; | |
1359 | int namlen, error; | 1359 | int namlen, error; | |
1360 | 1360 | |||
1361 | error = vn_rdwr(UIO_READ, vp, &dirbuf, | 1361 | error = vn_rdwr(UIO_READ, vp, &dirbuf, | |
1362 | sizeof (struct dirtemplate), (off_t)0, UIO_SYSSPACE, | 1362 | sizeof (struct lfs_dirtemplate), (off_t)0, UIO_SYSSPACE, | |
1363 | IO_NODELOCKED, cred, NULL, NULL); | 1363 | IO_NODELOCKED, cred, NULL, NULL); | |
1364 | if (error) { | 1364 | if (error) { | |
1365 | return error; | 1365 | return error; | |
1366 | } | 1366 | } | |
1367 | 1367 | |||
1368 | #if (BYTE_ORDER == LITTLE_ENDIAN) | 1368 | #if (BYTE_ORDER == LITTLE_ENDIAN) | |
1369 | if (FSFMT(vp) && needswap == 0) | 1369 | if (FSFMT(vp) && needswap == 0) | |
1370 | namlen = dirbuf.dotdot_type; | 1370 | namlen = dirbuf.dotdot_type; | |
1371 | else | 1371 | else | |
1372 | namlen = dirbuf.dotdot_namlen; | 1372 | namlen = dirbuf.dotdot_namlen; | |
1373 | #else | 1373 | #else | |
1374 | if (FSFMT(vp) && needswap != 0) | 1374 | if (FSFMT(vp) && needswap != 0) | |
1375 | namlen = dirbuf.dotdot_type; | 1375 | namlen = dirbuf.dotdot_type; |