No empty .Rs/.Re
[netbsd-mini2440.git] / sys / fs / msdosfs / msdosfs_denode.c
blob2e8df499246258e26b707d991118ce5ffc17f353
1 /* $NetBSD: msdosfs_denode.c,v 1.36 2009/03/15 17:15:57 cegger Exp $ */
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).
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.
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.
35 * Written by Paul Popelka (paulp@uts.amdahl.com)
37 * You can do anything you want with this software, just don't say you wrote
38 * it, and don't remove this notice.
40 * This software is provided "as is".
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.
47 * October 1992
50 #include <sys/cdefs.h>
51 __KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.36 2009/03/15 17:15:57 cegger Exp $");
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 #include <sys/kauth.h>
66 #include <uvm/uvm_extern.h>
68 #include <fs/msdosfs/bpb.h>
69 #include <fs/msdosfs/msdosfsmount.h>
70 #include <fs/msdosfs/direntry.h>
71 #include <fs/msdosfs/denode.h>
72 #include <fs/msdosfs/fat.h>
74 LIST_HEAD(ihashhead, denode) *dehashtbl;
75 u_long dehash; /* size of hash table - 1 */
76 #define DEHASH(dev, dcl, doff) \
77 (((dev) + (dcl) + (doff) / sizeof(struct direntry)) & dehash)
79 kmutex_t msdosfs_ihash_lock;
80 kmutex_t msdosfs_hashlock;
82 struct pool msdosfs_denode_pool;
84 extern int prtactive;
86 static const struct genfs_ops msdosfs_genfsops = {
87 .gop_size = genfs_size,
88 .gop_alloc = msdosfs_gop_alloc,
89 .gop_write = genfs_gop_write,
90 .gop_markupdate = msdosfs_gop_markupdate,
93 static struct denode *msdosfs_hashget(dev_t, u_long, u_long, int);
94 static void msdosfs_hashins(struct denode *);
95 static void msdosfs_hashrem(struct denode *);
97 MALLOC_DECLARE(M_MSDOSFSFAT);
99 void
100 msdosfs_init(void)
103 malloc_type_attach(M_MSDOSFSMNT);
104 malloc_type_attach(M_MSDOSFSFAT);
105 malloc_type_attach(M_MSDOSFSTMP);
106 pool_init(&msdosfs_denode_pool, sizeof(struct denode), 0, 0, 0,
107 "msdosnopl", &pool_allocator_nointr, IPL_NONE);
108 dehashtbl = hashinit(desiredvnodes / 2, HASH_LIST, true, &dehash);
109 mutex_init(&msdosfs_ihash_lock, MUTEX_DEFAULT, IPL_NONE);
110 mutex_init(&msdosfs_hashlock, MUTEX_DEFAULT, IPL_NONE);
114 * Reinitialize inode hash table.
117 void
118 msdosfs_reinit(void)
120 struct denode *dep;
121 struct ihashhead *oldhash, *hash;
122 u_long oldmask, mask, val;
123 int i;
125 hash = hashinit(desiredvnodes / 2, HASH_LIST, true, &mask);
127 mutex_enter(&msdosfs_ihash_lock);
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);
140 mutex_exit(&msdosfs_ihash_lock);
141 hashdone(oldhash, HASH_LIST, oldmask);
144 void
145 msdosfs_done(void)
147 hashdone(dehashtbl, HASH_LIST, dehash);
148 pool_destroy(&msdosfs_denode_pool);
149 mutex_destroy(&msdosfs_ihash_lock);
150 mutex_destroy(&msdosfs_hashlock);
151 malloc_type_detach(M_MSDOSFSTMP);
152 malloc_type_detach(M_MSDOSFSFAT);
153 malloc_type_detach(M_MSDOSFSMNT);
156 static struct denode *
157 msdosfs_hashget(dev_t dev, u_long dirclust, u_long diroff, int flags)
159 struct denode *dep;
160 struct vnode *vp;
162 loop:
163 mutex_enter(&msdosfs_ihash_lock);
164 LIST_FOREACH(dep, &dehashtbl[DEHASH(dev, dirclust, diroff)], de_hash) {
165 if (dirclust == dep->de_dirclust &&
166 diroff == dep->de_diroffset &&
167 dev == dep->de_dev &&
168 dep->de_refcnt != 0) {
169 vp = DETOV(dep);
170 if (flags == 0) {
171 mutex_exit(&msdosfs_ihash_lock);
172 } else {
173 mutex_enter(&vp->v_interlock);
174 mutex_exit(&msdosfs_ihash_lock);
175 if (vget(vp, flags | LK_INTERLOCK))
176 goto loop;
178 return (dep);
181 mutex_exit(&msdosfs_ihash_lock);
182 return (NULL);
185 static void
186 msdosfs_hashins(struct denode *dep)
188 struct ihashhead *depp;
189 int val;
191 KASSERT(mutex_owned(&msdosfs_hashlock));
193 mutex_enter(&msdosfs_ihash_lock);
194 val = DEHASH(dep->de_dev, dep->de_dirclust, dep->de_diroffset);
195 depp = &dehashtbl[val];
196 LIST_INSERT_HEAD(depp, dep, de_hash);
197 mutex_exit(&msdosfs_ihash_lock);
200 static void
201 msdosfs_hashrem(struct denode *dep)
203 mutex_enter(&msdosfs_ihash_lock);
204 LIST_REMOVE(dep, de_hash);
205 mutex_exit(&msdosfs_ihash_lock);
209 * If deget() succeeds it returns with the gotten denode locked().
211 * pmp - address of msdosfsmount structure of the filesystem containing
212 * the denode of interest. The pm_dev field and the address of
213 * the msdosfsmount structure are used.
214 * dirclust - which cluster bp contains, if dirclust is 0 (root directory)
215 * diroffset is relative to the beginning of the root directory,
216 * otherwise it is cluster relative.
217 * diroffset - offset past begin of cluster of denode we want
218 * depp - returns the address of the gotten denode.
221 deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, struct denode **depp)
222 /* pmp: so we know the maj/min number */
223 /* dirclust: cluster this dir entry came from */
224 /* diroffset: index of entry within the cluster */
225 /* depp: returns the addr of the gotten denode */
227 int error;
228 extern int (**msdosfs_vnodeop_p)(void *);
229 struct direntry *direntptr;
230 struct denode *ldep;
231 struct vnode *nvp;
232 struct buf *bp;
234 #ifdef MSDOSFS_DEBUG
235 printf("deget(pmp %p, dirclust %lu, diroffset %lx, depp %p)\n",
236 pmp, dirclust, diroffset, depp);
237 #endif
240 * On FAT32 filesystems, root is a (more or less) normal
241 * directory
243 if (FAT32(pmp) && dirclust == MSDOSFSROOT)
244 dirclust = pmp->pm_rootdirblk;
247 * See if the denode is in the denode cache. Use the location of
248 * the directory entry to compute the hash value. For subdir use
249 * address of "." entry. For root dir (if not FAT32) use cluster
250 * MSDOSFSROOT, offset MSDOSFSROOT_OFS
252 * NOTE: The check for de_refcnt > 0 below insures the denode being
253 * examined does not represent an unlinked but still open file.
254 * These files are not to be accessible even when the directory
255 * entry that represented the file happens to be reused while the
256 * deleted file is still open.
258 retry:
259 ldep = msdosfs_hashget(pmp->pm_dev, dirclust, diroffset, LK_EXCLUSIVE);
260 if (ldep) {
261 *depp = ldep;
262 return (0);
266 * Directory entry was not in cache, have to create a vnode and
267 * copy it from the passed disk buffer.
269 /* getnewvnode() does a VREF() on the vnode */
270 error = getnewvnode(VT_MSDOSFS, pmp->pm_mountp,
271 msdosfs_vnodeop_p, &nvp);
272 if (error) {
273 *depp = 0;
274 return (error);
276 ldep = pool_get(&msdosfs_denode_pool, PR_WAITOK);
279 * If someone beat us to it, put back the freshly allocated
280 * vnode/inode pair and retry.
282 mutex_enter(&msdosfs_hashlock);
283 if (msdosfs_hashget(pmp->pm_dev, dirclust, diroffset, 0)) {
284 mutex_exit(&msdosfs_hashlock);
285 ungetnewvnode(nvp);
286 pool_put(&msdosfs_denode_pool, ldep);
287 goto retry;
289 memset(ldep, 0, sizeof *ldep);
290 nvp->v_data = ldep;
291 ldep->de_vnode = nvp;
292 ldep->de_flag = 0;
293 ldep->de_devvp = 0;
294 ldep->de_lockf = 0;
295 ldep->de_dev = pmp->pm_dev;
296 ldep->de_dirclust = dirclust;
297 ldep->de_diroffset = diroffset;
298 fc_purge(ldep, 0); /* init the fat cache for this denode */
301 * Insert the denode into the hash queue and lock the denode so it
302 * can't be accessed until we've read it in and have done what we
303 * need to it.
305 vn_lock(nvp, LK_EXCLUSIVE | LK_RETRY);
306 genfs_node_init(nvp, &msdosfs_genfsops);
307 msdosfs_hashins(ldep);
308 mutex_exit(&msdosfs_hashlock);
310 ldep->de_pmp = pmp;
311 ldep->de_devvp = pmp->pm_devvp;
312 ldep->de_refcnt = 1;
314 * Copy the directory entry into the denode area of the vnode.
316 if ((dirclust == MSDOSFSROOT
317 || (FAT32(pmp) && dirclust == pmp->pm_rootdirblk))
318 && diroffset == MSDOSFSROOT_OFS) {
320 * Directory entry for the root directory. There isn't one,
321 * so we manufacture one. We should probably rummage
322 * through the root directory and find a label entry (if it
323 * exists), and then use the time and date from that entry
324 * as the time and date for the root denode.
326 nvp->v_vflag |= VV_ROOT; /* should be further down XXX */
328 ldep->de_Attributes = ATTR_DIRECTORY;
329 if (FAT32(pmp))
330 ldep->de_StartCluster = pmp->pm_rootdirblk;
331 /* de_FileSize will be filled in further down */
332 else {
333 ldep->de_StartCluster = MSDOSFSROOT;
334 ldep->de_FileSize = pmp->pm_rootdirsize * pmp->pm_BytesPerSec;
337 * fill in time and date so that dos2unixtime() doesn't
338 * spit up when called from msdosfs_getattr() with root
339 * denode
341 ldep->de_CHun = 0;
342 ldep->de_CTime = 0x0000; /* 00:00:00 */
343 ldep->de_CDate = (0 << DD_YEAR_SHIFT) | (1 << DD_MONTH_SHIFT)
344 | (1 << DD_DAY_SHIFT);
345 /* Jan 1, 1980 */
346 ldep->de_ADate = ldep->de_CDate;
347 ldep->de_MTime = ldep->de_CTime;
348 ldep->de_MDate = ldep->de_CDate;
349 /* leave the other fields as garbage */
350 } else {
351 error = readep(pmp, dirclust, diroffset, &bp, &direntptr);
352 if (error) {
353 ldep->de_devvp = NULL;
354 ldep->de_Name[0] = SLOT_DELETED;
355 vput(nvp);
356 return (error);
358 DE_INTERNALIZE(ldep, direntptr);
359 brelse(bp, 0);
363 * Fill in a few fields of the vnode and finish filling in the
364 * denode. Then return the address of the found denode.
366 if (ldep->de_Attributes & ATTR_DIRECTORY) {
368 * Since DOS directory entries that describe directories
369 * have 0 in the filesize field, we take this opportunity
370 * to find out the length of the directory and plug it into
371 * the denode structure.
373 u_long size;
375 nvp->v_type = VDIR;
376 if (ldep->de_StartCluster != MSDOSFSROOT) {
377 error = pcbmap(ldep, CLUST_END, 0, &size, 0);
378 if (error == E2BIG) {
379 ldep->de_FileSize = de_cn2off(pmp, size);
380 error = 0;
381 } else
382 printf("deget(): pcbmap returned %d\n", error);
384 } else
385 nvp->v_type = VREG;
386 vref(ldep->de_devvp);
387 *depp = ldep;
388 uvm_vnp_setsize(nvp, ldep->de_FileSize);
389 return (0);
393 deupdat(struct denode *dep, int waitfor)
396 return (msdosfs_update(DETOV(dep), NULL, NULL,
397 waitfor ? UPDATE_WAIT : 0));
401 * Truncate the file described by dep to the length specified by length.
404 detrunc(struct denode *dep, u_long length, int flags, kauth_cred_t cred)
406 int error;
407 int allerror;
408 u_long eofentry;
409 u_long chaintofree = 0;
410 daddr_t bn, lastblock;
411 int boff;
412 int isadir = dep->de_Attributes & ATTR_DIRECTORY;
413 struct buf *bp;
414 struct msdosfsmount *pmp = dep->de_pmp;
416 #ifdef MSDOSFS_DEBUG
417 printf("detrunc(): file %s, length %lu, flags %x\n", dep->de_Name, length, flags);
418 #endif
421 * Disallow attempts to truncate the root directory since it is of
422 * fixed size. That's just the way dos filesystems are. We use
423 * the VROOT bit in the vnode because checking for the directory
424 * bit and a startcluster of 0 in the denode is not adequate to
425 * recognize the root directory at this point in a file or
426 * directory's life.
428 if ((DETOV(dep)->v_vflag & VV_ROOT) && !FAT32(pmp)) {
429 printf("detrunc(): can't truncate root directory, clust %ld, offset %ld\n",
430 dep->de_dirclust, dep->de_diroffset);
431 return (EINVAL);
434 uvm_vnp_setsize(DETOV(dep), length);
436 if (dep->de_FileSize < length)
437 return (deextend(dep, length, cred));
438 lastblock = de_clcount(pmp, length) - 1;
441 * If the desired length is 0 then remember the starting cluster of
442 * the file and set the StartCluster field in the directory entry
443 * to 0. If the desired length is not zero, then get the number of
444 * the last cluster in the shortened file. Then get the number of
445 * the first cluster in the part of the file that is to be freed.
446 * Then set the next cluster pointer in the last cluster of the
447 * file to CLUST_EOFE.
449 if (length == 0) {
450 chaintofree = dep->de_StartCluster;
451 dep->de_StartCluster = 0;
452 eofentry = ~0;
453 } else {
454 error = pcbmap(dep, lastblock, 0, &eofentry, 0);
455 if (error) {
456 #ifdef MSDOSFS_DEBUG
457 printf("detrunc(): pcbmap fails %d\n", error);
458 #endif
459 return (error);
463 fc_purge(dep, lastblock + 1);
466 * If the new length is not a multiple of the cluster size then we
467 * must zero the tail end of the new last cluster in case it
468 * becomes part of the file again because of a seek.
470 if ((boff = length & pmp->pm_crbomask) != 0) {
471 if (isadir) {
472 bn = cntobn(pmp, eofentry);
473 error = bread(pmp->pm_devvp, de_bn2kb(pmp, bn),
474 pmp->pm_bpcluster, NOCRED, B_MODIFY, &bp);
475 if (error) {
476 brelse(bp, 0);
477 #ifdef MSDOSFS_DEBUG
478 printf("detrunc(): bread fails %d\n", error);
479 #endif
480 return (error);
482 memset((char *)bp->b_data + boff, 0,
483 pmp->pm_bpcluster - boff);
484 if (flags & IO_SYNC)
485 bwrite(bp);
486 else
487 bdwrite(bp);
488 } else {
489 uvm_vnp_zerorange(DETOV(dep), length,
490 pmp->pm_bpcluster - boff);
495 * Write out the updated directory entry. Even if the update fails
496 * we free the trailing clusters.
498 dep->de_FileSize = length;
499 if (!isadir)
500 dep->de_flag |= DE_UPDATE|DE_MODIFIED;
501 vtruncbuf(DETOV(dep), lastblock + 1, 0, 0);
502 allerror = deupdat(dep, 1);
503 #ifdef MSDOSFS_DEBUG
504 printf("detrunc(): allerror %d, eofentry %lu\n",
505 allerror, eofentry);
506 #endif
509 * If we need to break the cluster chain for the file then do it
510 * now.
512 if (eofentry != ~0) {
513 error = fatentry(FAT_GET_AND_SET, pmp, eofentry,
514 &chaintofree, CLUST_EOFE);
515 if (error) {
516 #ifdef MSDOSFS_DEBUG
517 printf("detrunc(): fatentry errors %d\n", error);
518 #endif
519 return (error);
521 fc_setcache(dep, FC_LASTFC, de_cluster(pmp, length - 1),
522 eofentry);
526 * Now free the clusters removed from the file because of the
527 * truncation.
529 if (chaintofree != 0 && !MSDOSFSEOF(chaintofree, pmp->pm_fatmask))
530 freeclusterchain(pmp, chaintofree);
532 return (allerror);
536 * Extend the file described by dep to length specified by length.
539 deextend(struct denode *dep, u_long length, kauth_cred_t cred)
541 struct msdosfsmount *pmp = dep->de_pmp;
542 u_long count, osize;
543 int error;
546 * The root of a DOS filesystem cannot be extended.
548 if ((DETOV(dep)->v_vflag & VV_ROOT) && !FAT32(pmp))
549 return (EINVAL);
552 * Directories cannot be extended.
554 if (dep->de_Attributes & ATTR_DIRECTORY)
555 return (EISDIR);
557 if (length <= dep->de_FileSize)
558 panic("deextend: file too large");
561 * Compute the number of clusters to allocate.
563 count = de_clcount(pmp, length) - de_clcount(pmp, dep->de_FileSize);
564 if (count > 0) {
565 if (count > pmp->pm_freeclustercount)
566 return (ENOSPC);
567 error = extendfile(dep, count, NULL, NULL, DE_CLEAR);
568 if (error) {
569 /* truncate the added clusters away again */
570 (void) detrunc(dep, dep->de_FileSize, 0, cred);
571 return (error);
576 * Zero extend file range; uvm_vnp_zerorange() uses ubc_alloc() and a
577 * memset(); we set the write size so ubc won't read in file data that
578 * is zero'd later.
580 osize = dep->de_FileSize;
581 dep->de_FileSize = length;
582 uvm_vnp_setwritesize(DETOV(dep), (voff_t)dep->de_FileSize);
583 dep->de_flag |= DE_UPDATE|DE_MODIFIED;
584 uvm_vnp_zerorange(DETOV(dep), (off_t)osize,
585 (size_t)(dep->de_FileSize - osize));
586 uvm_vnp_setsize(DETOV(dep), (voff_t)dep->de_FileSize);
587 return (deupdat(dep, 1));
591 * Move a denode to its correct hash queue after the file it represents has
592 * been moved to a new directory.
594 void
595 reinsert(struct denode *dep)
598 * Fix up the denode cache. If the denode is for a directory,
599 * there is nothing to do since the hash is based on the starting
600 * cluster of the directory file and that hasn't changed. If for a
601 * file the hash is based on the location of the directory entry,
602 * so we must remove it from the cache and re-enter it with the
603 * hash based on the new location of the directory entry.
605 if (dep->de_Attributes & ATTR_DIRECTORY)
606 return;
607 mutex_enter(&msdosfs_hashlock);
608 msdosfs_hashrem(dep);
609 msdosfs_hashins(dep);
610 mutex_exit(&msdosfs_hashlock);
614 msdosfs_reclaim(void *v)
616 struct vop_reclaim_args /* {
617 struct vnode *a_vp;
618 } */ *ap = v;
619 struct vnode *vp = ap->a_vp;
620 struct denode *dep = VTODE(vp);
622 #ifdef MSDOSFS_DEBUG
623 printf("msdosfs_reclaim(): dep %p, file %s, refcnt %ld\n",
624 dep, dep->de_Name, dep->de_refcnt);
625 #endif
627 if (prtactive && vp->v_usecount > 1)
628 vprint("msdosfs_reclaim(): pushing active", vp);
630 * Remove the denode from its hash chain.
632 msdosfs_hashrem(dep);
634 * Purge old data structures associated with the denode.
636 cache_purge(vp);
637 if (dep->de_devvp) {
638 vrele(dep->de_devvp);
639 dep->de_devvp = 0;
641 #if 0 /* XXX */
642 dep->de_flag = 0;
643 #endif
644 genfs_node_destroy(vp);
645 pool_put(&msdosfs_denode_pool, dep);
646 vp->v_data = NULL;
647 return (0);
651 msdosfs_inactive(void *v)
653 struct vop_inactive_args /* {
654 struct vnode *a_vp;
655 bool *a_recycle;
656 } */ *ap = v;
657 struct vnode *vp = ap->a_vp;
658 struct denode *dep = VTODE(vp);
659 int error = 0;
661 #ifdef MSDOSFS_DEBUG
662 printf("msdosfs_inactive(): dep %p, de_Name[0] %x\n", dep, dep->de_Name[0]);
663 #endif
666 * Get rid of denodes related to stale file handles.
668 if (dep->de_Name[0] == SLOT_DELETED)
669 goto out;
672 * If the file has been deleted and it is on a read/write
673 * filesystem, then truncate the file, and mark the directory slot
674 * as empty. (This may not be necessary for the dos filesystem.)
676 #ifdef MSDOSFS_DEBUG
677 printf("msdosfs_inactive(): dep %p, refcnt %ld, mntflag %x %s\n",
678 dep, dep->de_refcnt, vp->v_mount->mnt_flag,
679 (vp->v_mount->mnt_flag & MNT_RDONLY) ? "MNT_RDONLY" : "");
680 #endif
681 if (dep->de_refcnt <= 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) {
682 if (dep->de_FileSize != 0) {
683 error = detrunc(dep, (u_long)0, 0, NOCRED);
685 dep->de_Name[0] = SLOT_DELETED;
687 deupdat(dep, 0);
688 out:
690 * If we are done with the denode, reclaim it
691 * so that it can be reused immediately.
693 #ifdef MSDOSFS_DEBUG
694 printf("msdosfs_inactive(): v_usecount %d, de_Name[0] %x\n",
695 vp->v_usecount, dep->de_Name[0]);
696 #endif
697 *ap->a_recycle = (dep->de_Name[0] == SLOT_DELETED);
698 VOP_UNLOCK(vp, 0);
699 return (error);
703 msdosfs_gop_alloc(struct vnode *vp, off_t off,
704 off_t len, int flags, kauth_cred_t cred)
706 return 0;
709 void
710 msdosfs_gop_markupdate(struct vnode *vp, int flags)
712 u_long mask = 0;
714 if ((flags & GOP_UPDATE_ACCESSED) != 0) {
715 mask = DE_ACCESS;
717 if ((flags & GOP_UPDATE_MODIFIED) != 0) {
718 mask |= DE_UPDATE;
720 if (mask) {
721 struct denode *dep = VTODE(vp);
723 dep->de_flag |= mask;