1 /* $NetBSD: msdosfs_denode.c,v 1.5 2004/03/27 04:43:43 atatat Exp $ */
2
3 /*-
4 * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
5 * Copyright (C) 1994, 1995, 1997 TooLs GmbH.
6 * All rights reserved.
7 * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by TooLs GmbH.
20 * 4. The name of TooLs GmbH may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34 /*
35 * Written by Paul Popelka (paulp@uts.amdahl.com)
36 *
37 * You can do anything you want with this software, just don't say you wrote
38 * it, and don't remove this notice.
39 *
40 * This software is provided "as is".
41 *
42 * The author supplies this software to be publicly redistributed on the
43 * understanding that the author is not responsible for the correct
44 * functioning of this software in any circumstances and is not liable for
45 * any damages caused by this software.
46 *
47 * October 1992
48 */
49
50 #include <sys/cdefs.h>
51 __KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.5 2004/03/27 04:43:43 atatat Exp $");
52
53 #include <sys/param.h>
54 #include <sys/systm.h>
55 #include <sys/mount.h>
56 #include <sys/malloc.h>
57 #include <sys/pool.h>
58 #include <sys/proc.h>
59 #include <sys/buf.h>
60 #include <sys/vnode.h>
61 #include <sys/kernel.h> /* defines "time" */
62 #include <sys/dirent.h>
63 #include <sys/namei.h>
64
65 #include <uvm/uvm_extern.h>
66
67 #include <fs/msdosfs/bpb.h>
68 #include <fs/msdosfs/msdosfsmount.h>
69 #include <fs/msdosfs/direntry.h>
70 #include <fs/msdosfs/denode.h>
71 #include <fs/msdosfs/fat.h>
72
73 LIST_HEAD(ihashhead, denode) *dehashtbl;
74 u_long dehash; /* size of hash table - 1 */
75 #define DEHASH(dev, dcl, doff) \
76 (((dev) + (dcl) + (doff) / sizeof(struct direntry)) & dehash)
77
78 struct simplelock msdosfs_ihash_slock;
79
80 struct pool msdosfs_denode_pool;
81
82 extern int prtactive;
83
84 struct genfs_ops msdosfs_genfsops = {
85 genfs_size,
86 msdosfs_gop_alloc,
87 genfs_gop_write,
88 };
89
90 static struct denode *msdosfs_hashget __P((dev_t, u_long, u_long));
91 static void msdosfs_hashins __P((struct denode *));
92 static void msdosfs_hashrem __P((struct denode *));
93
94 #ifdef _LKM
95 MALLOC_DECLARE(M_MSDOSFSFAT);
96 #endif
97
98 void
99 msdosfs_init()
100 {
101 #ifdef _LKM
102 malloc_type_attach(M_MSDOSFSMNT);
103 malloc_type_attach(M_MSDOSFSFAT);
104 #endif
105 dehashtbl = hashinit(desiredvnodes / 2, HASH_LIST, M_MSDOSFSMNT,
106 M_WAITOK, &dehash);
107 simple_lock_init(&msdosfs_ihash_slock);
108 pool_init(&msdosfs_denode_pool, sizeof(struct denode), 0, 0, 0,
109 "msdosnopl", &pool_allocator_nointr);
110 }
111
112 /*
113 * Reinitialize inode hash table.
114 */
115
116 void
117 msdosfs_reinit()
118 {
119 struct denode *dep;
120 struct ihashhead *oldhash, *hash;
121 u_long oldmask, mask, val;
122 int i;
123
124 hash = hashinit(desiredvnodes / 2, HASH_LIST, M_MSDOSFSMNT, M_WAITOK,
125 &mask);
126
127 simple_lock(&msdosfs_ihash_slock);
128 oldhash = dehashtbl;
129 oldmask = dehash;
130 dehashtbl = hash;
131 dehash = mask;
132 for (i = 0; i <= oldmask; i++) {
133 while ((dep = LIST_FIRST(&oldhash[i])) != NULL) {
134 LIST_REMOVE(dep, de_hash);
135 val = DEHASH(dep->de_dev, dep->de_dirclust,
136 dep->de_diroffset);
137 LIST_INSERT_HEAD(&hash[val], dep, de_hash);
138 }
139 }
140 simple_unlock(&msdosfs_ihash_slock);
141 hashdone(oldhash, M_MSDOSFSMNT);
142 }
143
144 void
145 msdosfs_done()
146 {
147 hashdone(dehashtbl, M_MSDOSFSMNT);
148 pool_destroy(&msdosfs_denode_pool);
149 #ifdef _LKM
150 malloc_type_detach(M_MSDOSFSFAT);
151 malloc_type_detach(M_MSDOSFSMNT);
152 #endif
153 }
154
155 static struct denode *
156 msdosfs_hashget(dev, dirclust, diroff)
157 dev_t dev;
158 u_long dirclust;
159 u_long diroff;
160 {
161 struct denode *dep;
162 struct vnode *vp;
163
164 loop:
165 simple_lock(&msdosfs_ihash_slock);
166 LIST_FOREACH(dep, &dehashtbl[DEHASH(dev, dirclust, diroff)], de_hash) {
167 if (dirclust == dep->de_dirclust &&
168 diroff == dep->de_diroffset &&
169 dev == dep->de_dev &&
170 dep->de_refcnt != 0) {
171 vp = DETOV(dep);
172 simple_lock(&vp->v_interlock);
173 simple_unlock(&msdosfs_ihash_slock);
174 if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK))
175 goto loop;
176 return (dep);
177 }
178 }
179 simple_unlock(&msdosfs_ihash_slock);
180 return (NULL);
181 }
182
183 static void
184 msdosfs_hashins(dep)
185 struct denode *dep;
186 {
187 struct ihashhead *depp;
188 int val;
189
190 simple_lock(&msdosfs_ihash_slock);
191 val = DEHASH(dep->de_dev, dep->de_dirclust, dep->de_diroffset);
192 depp = &dehashtbl[val];
193 LIST_INSERT_HEAD(depp, dep, de_hash);
194 simple_unlock(&msdosfs_ihash_slock);
195 }
196
197 static void
198 msdosfs_hashrem(dep)
199 struct denode *dep;
200 {
201 simple_lock(&msdosfs_ihash_slock);
202 LIST_REMOVE(dep, de_hash);
203 simple_unlock(&msdosfs_ihash_slock);
204 }
205
206 /*
207 * If deget() succeeds it returns with the gotten denode locked().
208 *
209 * pmp - address of msdosfsmount structure of the filesystem containing
210 * the denode of interest. The pm_dev field and the address of
211 * the msdosfsmount structure are used.
212 * dirclust - which cluster bp contains, if dirclust is 0 (root directory)
213 * diroffset is relative to the beginning of the root directory,
214 * otherwise it is cluster relative.
215 * diroffset - offset past begin of cluster of denode we want
216 * depp - returns the address of the gotten denode.
217 */
218 int
219 deget(pmp, dirclust, diroffset, depp)
220 struct msdosfsmount *pmp; /* so we know the maj/min number */
221 u_long dirclust; /* cluster this dir entry came from */
222 u_long diroffset; /* index of entry within the cluster */
223 struct denode **depp; /* returns the addr of the gotten denode */
224 {
225 int error;
226 extern int (**msdosfs_vnodeop_p) __P((void *));
227 struct direntry *direntptr;
228 struct denode *ldep;
229 struct vnode *nvp;
230 struct buf *bp;
231
232 #ifdef MSDOSFS_DEBUG
233 printf("deget(pmp %p, dirclust %lu, diroffset %lx, depp %p)\n",
234 pmp, dirclust, diroffset, depp);
235 #endif
236
237 /*
238 * On FAT32 filesystems, root is a (more or less) normal
239 * directory
240 */
241 if (FAT32(pmp) && dirclust == MSDOSFSROOT)
242 dirclust = pmp->pm_rootdirblk;
243
244 /*
245 * See if the denode is in the denode cache. Use the location of
246 * the directory entry to compute the hash value. For subdir use
247 * address of "." entry. For root dir (if not FAT32) use cluster
248 * MSDOSFSROOT, offset MSDOSFSROOT_OFS
249 *
250 * NOTE: The check for de_refcnt > 0 below insures the denode being
251 * examined does not represent an unlinked but still open file.
252 * These files are not to be accessible even when the directory
253 * entry that represented the file happens to be reused while the
254 * deleted file is still open.
255 */
256 ldep = msdosfs_hashget(pmp->pm_dev, dirclust, diroffset);
257 if (ldep) {
258 *depp = ldep;
259 return (0);
260 }
261
262 /*
263 * Directory entry was not in cache, have to create a vnode and
264 * copy it from the passed disk buffer.
265 */
266 /* getnewvnode() does a VREF() on the vnode */
267 error = getnewvnode(VT_MSDOSFS, pmp->pm_mountp,
268 msdosfs_vnodeop_p, &nvp);
269 if (error) {
270 *depp = 0;
271 return (error);
272 }
273 ldep = pool_get(&msdosfs_denode_pool, PR_WAITOK);
274 memset(ldep, 0, sizeof *ldep);
275 nvp->v_data = ldep;
276 ldep->de_vnode = nvp;
277 ldep->de_flag = 0;
278 ldep->de_devvp = 0;
279 ldep->de_lockf = 0;
280 ldep->de_dev = pmp->pm_dev;
281 ldep->de_dirclust = dirclust;
282 ldep->de_diroffset = diroffset;
283 fc_purge(ldep, 0); /* init the fat cache for this denode */
284
285 /*
286 * Insert the denode into the hash queue and lock the denode so it
287 * can't be accessed until we've read it in and have done what we
288 * need to it.
289 */
290 vn_lock(nvp, LK_EXCLUSIVE | LK_RETRY);
291 msdosfs_hashins(ldep);
292
293 ldep->de_pmp = pmp;
294 ldep->de_devvp = pmp->pm_devvp;
295 ldep->de_refcnt = 1;
296 /*
297 * Copy the directory entry into the denode area of the vnode.
298 */
299 if ((dirclust == MSDOSFSROOT
300 || (FAT32(pmp) && dirclust == pmp->pm_rootdirblk))
301 && diroffset == MSDOSFSROOT_OFS) {
302 /*
303 * Directory entry for the root directory. There isn't one,
304 * so we manufacture one. We should probably rummage
305 * through the root directory and find a label entry (if it
306 * exists), and then use the time and date from that entry
307 * as the time and date for the root denode.
308 */
309 nvp->v_flag |= VROOT; /* should be further down XXX */
310
311 ldep->de_Attributes = ATTR_DIRECTORY;
312 if (FAT32(pmp))
313 ldep->de_StartCluster = pmp->pm_rootdirblk;
314 /* de_FileSize will be filled in further down */
315 else {
316 ldep->de_StartCluster = MSDOSFSROOT;
317 ldep->de_FileSize = pmp->pm_rootdirsize * pmp->pm_BytesPerSec;
318 }
319 /*
320 * fill in time and date so that dos2unixtime() doesn't
321 * spit up when called from msdosfs_getattr() with root
322 * denode
323 */
324 ldep->de_CHun = 0;
325 ldep->de_CTime = 0x0000; /* 00:00:00 */
326 ldep->de_CDate = (0 << DD_YEAR_SHIFT) | (1 << DD_MONTH_SHIFT)
327 | (1 << DD_DAY_SHIFT);
328 /* Jan 1, 1980 */
329 ldep->de_ADate = ldep->de_CDate;
330 ldep->de_MTime = ldep->de_CTime;
331 ldep->de_MDate = ldep->de_CDate;
332 /* leave the other fields as garbage */
333 } else {
334 error = readep(pmp, dirclust, diroffset, &bp, &direntptr);
335 if (error)
336 return (error);
337 DE_INTERNALIZE(ldep, direntptr);
338 brelse(bp);
339 }
340
341 /*
342 * Fill in a few fields of the vnode and finish filling in the
343 * denode. Then return the address of the found denode.
344 */
345 if (ldep->de_Attributes & ATTR_DIRECTORY) {
346 /*
347 * Since DOS directory entries that describe directories
348 * have 0 in the filesize field, we take this opportunity
349 * to find out the length of the directory and plug it into
350 * the denode structure.
351 */
352 u_long size;
353
354 nvp->v_type = VDIR;
355 if (ldep->de_StartCluster != MSDOSFSROOT) {
356 error = pcbmap(ldep, CLUST_END, 0, &size, 0);
357 if (error == E2BIG) {
358 ldep->de_FileSize = de_cn2off(pmp, size);
359 error = 0;
360 } else
361 printf("deget(): pcbmap returned %d\n", error);
362 }
363 } else
364 nvp->v_type = VREG;
365 genfs_node_init(nvp, &msdosfs_genfsops);
366 VREF(ldep->de_devvp);
367 *depp = ldep;
368 nvp->v_size = ldep->de_FileSize;
369 return (0);
370 }
371
372 int
373 deupdat(dep, waitfor)
374 struct denode *dep;
375 int waitfor;
376 {
377
378 return (VOP_UPDATE(DETOV(dep), NULL, NULL, waitfor ? UPDATE_WAIT : 0));
379 }
380
381 /*
382 * Truncate the file described by dep to the length specified by length.
383 */
384 int
385 detrunc(dep, length, flags, cred, p)
386 struct denode *dep;
387 u_long length;
388 int flags;
389 struct ucred *cred;
390 struct proc *p;
391 {
392 int error;
393 int allerror;
394 u_long eofentry;
395 u_long chaintofree;
396 daddr_t bn, lastblock;
397 int boff;
398 int isadir = dep->de_Attributes & ATTR_DIRECTORY;
399 struct buf *bp;
400 struct msdosfsmount *pmp = dep->de_pmp;
401
402 #ifdef MSDOSFS_DEBUG
403 printf("detrunc(): file %s, length %lu, flags %x\n", dep->de_Name, length, flags);
404 #endif
405
406 /*
407 * Disallow attempts to truncate the root directory since it is of
408 * fixed size. That's just the way dos filesystems are. We use
409 * the VROOT bit in the vnode because checking for the directory
410 * bit and a startcluster of 0 in the denode is not adequate to
411 * recognize the root directory at this point in a file or
412 * directory's life.
413 */
414 if ((DETOV(dep)->v_flag & VROOT) && !FAT32(pmp)) {
415 printf("detrunc(): can't truncate root directory, clust %ld, offset %ld\n",
416 dep->de_dirclust, dep->de_diroffset);
417 return (EINVAL);
418 }
419
420 uvm_vnp_setsize(DETOV(dep), length);
421
422 if (dep->de_FileSize < length)
423 return (deextend(dep, length, cred));
424 lastblock = de_clcount(pmp, length) - 1;
425
426 /*
427 * If the desired length is 0 then remember the starting cluster of
428 * the file and set the StartCluster field in the directory entry
429 * to 0. If the desired length is not zero, then get the number of
430 * the last cluster in the shortened file. Then get the number of
431 * the first cluster in the part of the file that is to be freed.
432 * Then set the next cluster pointer in the last cluster of the
433 * file to CLUST_EOFE.
434 */
435 if (length == 0) {
436 chaintofree = dep->de_StartCluster;
437 dep->de_StartCluster = 0;
438 eofentry = ~0;
439 } else {
440 error = pcbmap(dep, lastblock, 0, &eofentry, 0);
441 if (error) {
442 #ifdef MSDOSFS_DEBUG
443 printf("detrunc(): pcbmap fails %d\n", error);
444 #endif
445 return (error);
446 }
447 }
448
449 fc_purge(dep, lastblock + 1);
450
451 /*
452 * If the new length is not a multiple of the cluster size then we
453 * must zero the tail end of the new last cluster in case it
454 * becomes part of the file again because of a seek.
455 */
456 if ((boff = length & pmp->pm_crbomask) != 0) {
457 if (isadir) {
458 bn = cntobn(pmp, eofentry);
459 error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster,
460 NOCRED, &bp);
461 if (error) {
462 brelse(bp);
463 #ifdef MSDOSFS_DEBUG
464 printf("detrunc(): bread fails %d\n", error);
465 #endif
466 return (error);
467 }
468 memset(bp->b_data + boff, 0, pmp->pm_bpcluster - boff);
469 if (flags & IO_SYNC)
470 bwrite(bp);
471 else
472 bdwrite(bp);
473 } else {
474 uvm_vnp_zerorange(DETOV(dep), length,
475 pmp->pm_bpcluster - boff);
476 }
477 }
478
479 /*
480 * Write out the updated directory entry. Even if the update fails
481 * we free the trailing clusters.
482 */
483 dep->de_FileSize = length;
484 if (!isadir)
485 dep->de_flag |= DE_UPDATE|DE_MODIFIED;
486 vtruncbuf(DETOV(dep), lastblock + 1, 0, 0);
487 allerror = deupdat(dep, 1);
488 #ifdef MSDOSFS_DEBUG
489 printf("detrunc(): allerror %d, eofentry %lu\n",
490 allerror, eofentry);
491 #endif
492
493 /*
494 * If we need to break the cluster chain for the file then do it
495 * now.
496 */
497 if (eofentry != ~0) {
498 error = fatentry(FAT_GET_AND_SET, pmp, eofentry,
499 &chaintofree, CLUST_EOFE);
500 if (error) {
501 #ifdef MSDOSFS_DEBUG
502 printf("detrunc(): fatentry errors %d\n", error);
503 #endif
504 return (error);
505 }
506 fc_setcache(dep, FC_LASTFC, de_cluster(pmp, length - 1),
507 eofentry);
508 }
509
510 /*
511 * Now free the clusters removed from the file because of the
512 * truncation.
513 */
514 if (chaintofree != 0 && !MSDOSFSEOF(chaintofree, pmp->pm_fatmask))
515 freeclusterchain(pmp, chaintofree);
516
517 return (allerror);
518 }
519
520 /*
521 * Extend the file described by dep to length specified by length.
522 */
523 int
524 deextend(dep, length, cred)
525 struct denode *dep;
526 u_long length;
527 struct ucred *cred;
528 {
529 struct msdosfsmount *pmp = dep->de_pmp;
530 u_long count, osize;
531 int error;
532
533 /*
534 * The root of a DOS filesystem cannot be extended.
535 */
536 if ((DETOV(dep)->v_flag & VROOT) && !FAT32(pmp))
537 return (EINVAL);
538
539 /*
540 * Directories cannot be extended.
541 */
542 if (dep->de_Attributes & ATTR_DIRECTORY)
543 return (EISDIR);
544
545 if (length <= dep->de_FileSize)
546 panic("deextend: file too large");
547
548 /*
549 * Compute the number of clusters to allocate.
550 */
551 count = de_clcount(pmp, length) - de_clcount(pmp, dep->de_FileSize);
552 if (count > 0) {
553 if (count > pmp->pm_freeclustercount)
554 return (ENOSPC);
555 error = extendfile(dep, count, NULL, NULL, DE_CLEAR);
556 if (error) {
557 /* truncate the added clusters away again */
558 (void) detrunc(dep, dep->de_FileSize, 0, cred, NULL);
559 return (error);
560 }
561 }
562
563 osize = dep->de_FileSize;
564 dep->de_FileSize = length;
565 uvm_vnp_setsize(DETOV(dep), (voff_t)dep->de_FileSize);
566 dep->de_flag |= DE_UPDATE|DE_MODIFIED;
567 uvm_vnp_zerorange(DETOV(dep), (off_t)osize,
568 (size_t)(dep->de_FileSize - osize));
569 return (deupdat(dep, 1));
570 }
571
572 /*
573 * Move a denode to its correct hash queue after the file it represents has
574 * been moved to a new directory.
575 */
576 void
577 reinsert(dep)
578 struct denode *dep;
579 {
580 /*
581 * Fix up the denode cache. If the denode is for a directory,
582 * there is nothing to do since the hash is based on the starting
583 * cluster of the directory file and that hasn't changed. If for a
584 * file the hash is based on the location of the directory entry,
585 * so we must remove it from the cache and re-enter it with the
586 * hash based on the new location of the directory entry.
587 */
588 if (dep->de_Attributes & ATTR_DIRECTORY)
589 return;
590 msdosfs_hashrem(dep);
591 msdosfs_hashins(dep);
592 }
593
594 int
595 msdosfs_reclaim(v)
596 void *v;
597 {
598 struct vop_reclaim_args /* {
599 struct vnode *a_vp;
600 } */ *ap = v;
601 struct vnode *vp = ap->a_vp;
602 struct denode *dep = VTODE(vp);
603
604 #ifdef MSDOSFS_DEBUG
605 printf("msdosfs_reclaim(): dep %p, file %s, refcnt %ld\n",
606 dep, dep->de_Name, dep->de_refcnt);
607 #endif
608
609 if (prtactive && vp->v_usecount != 0)
610 vprint("msdosfs_reclaim(): pushing active", vp);
611 /*
612 * Remove the denode from its hash chain.
613 */
614 msdosfs_hashrem(dep);
615 /*
616 * Purge old data structures associated with the denode.
617 */
618 cache_purge(vp);
619 if (dep->de_devvp) {
620 vrele(dep->de_devvp);
621 dep->de_devvp = 0;
622 }
623 #if 0 /* XXX */
624 dep->de_flag = 0;
625 #endif
626 pool_put(&msdosfs_denode_pool, dep);
627 vp->v_data = NULL;
628 return (0);
629 }
630
631 int
632 msdosfs_inactive(v)
633 void *v;
634 {
635 struct vop_inactive_args /* {
636 struct vnode *a_vp;
637 struct proc *a_p;
638 } */ *ap = v;
639 struct proc *p = ap->a_p;
640 struct vnode *vp = ap->a_vp;
641 struct denode *dep = VTODE(vp);
642 int error = 0;
643
644 #ifdef MSDOSFS_DEBUG
645 printf("msdosfs_inactive(): dep %p, de_Name[0] %x\n", dep, dep->de_Name[0]);
646 #endif
647
648 if (prtactive && vp->v_usecount != 0)
649 vprint("msdosfs_inactive(): pushing active", vp);
650
651 /*
652 * Get rid of denodes related to stale file handles.
653 */
654 if (dep->de_Name[0] == SLOT_DELETED)
655 goto out;
656
657 /*
658 * If the file has been deleted and it is on a read/write
659 * filesystem, then truncate the file, and mark the directory slot
660 * as empty. (This may not be necessary for the dos filesystem.)
661 */
662 #ifdef MSDOSFS_DEBUG
663 printf("msdosfs_inactive(): dep %p, refcnt %ld, mntflag %x %s\n",
664 dep, dep->de_refcnt, vp->v_mount->mnt_flag,
665 (vp->v_mount->mnt_flag & MNT_RDONLY) ? "MNT_RDONLY" : "");
666 #endif
667 if (dep->de_refcnt <= 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) {
668 if (dep->de_FileSize != 0) {
669 error = detrunc(dep, (u_long)0, 0, NOCRED, NULL);
670 }
671 dep->de_Name[0] = SLOT_DELETED;
672 }
673 deupdat(dep, 0);
674 out:
675 VOP_UNLOCK(vp, 0);
676 /*
677 * If we are done with the denode, reclaim it
678 * so that it can be reused immediately.
679 */
680 #ifdef MSDOSFS_DEBUG
681 printf("msdosfs_inactive(): v_usecount %d, de_Name[0] %x\n",
682 vp->v_usecount, dep->de_Name[0]);
683 #endif
684 if (dep->de_Name[0] == SLOT_DELETED)
685 vrecycle(vp, (struct simplelock *)0, p);
686 return (error);
687 }
688
689 int
690 msdosfs_gop_alloc(struct vnode *vp, off_t off, off_t len, int flags,
691 struct ucred *cred)
692 {
693 return 0;
694 }
Cache object: cdb021f7ea198fa160ac672f539f8ae2
|