2 /* $NetBSD: msdosfs_vnops.c,v 1.68 1998/02/10 14:10:04 mrg Exp $ */
5 * SPDX-License-Identifier: BSD-4-Clause
7 * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
8 * Copyright (C) 1994, 1995, 1997 TooLs GmbH.
10 * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by TooLs GmbH.
23 * 4. The name of TooLs GmbH may not be used to endorse or promote products
24 * derived from this software without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
27 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 * Written by Paul Popelka (paulp@uts.amdahl.com)
40 * You can do anything you want with this software, just don't say you wrote
41 * it, and don't remove this notice.
43 * This software is provided "as is".
45 * The author supplies this software to be publicly redistributed on the
46 * understanding that the author is not responsible for the correct
47 * functioning of this software in any circumstances and is not liable for
48 * any damages caused by this software.
53 #include <sys/param.h>
54 #include <sys/systm.h>
55 #include <sys/resourcevar.h> /* defines plimit structure in proc struct */
56 #include <sys/kernel.h>
61 #include <sys/namei.h>
62 #include <sys/mount.h>
63 #include <sys/unistd.h>
64 #include <sys/vnode.h>
65 #include <sys/malloc.h>
66 #include <sys/dirent.h>
67 #include <sys/signalvar.h>
70 #include <vm/vm_extern.h>
71 #include <vm/vm_zone.h>
72 #include <vm/vnode_pager.h>
76 #include <machine/inttypes.h>
81 #include "msdosfsmount.h"
84 #define DOS_FILESIZE_MAX 0xffffffff
89 * In the ufs filesystem the inodes, superblocks, and indirect blocks are
90 * read/written using the vnode for the filesystem. Blocks that represent
91 * the contents of a file are read/written using the vnode for the file
92 * (including directories when they are read/written as files). This
93 * presents problems for the dos filesystem because data that should be in
94 * an inode (if dos had them) resides in the directory itself. Since we
95 * must update directory entries without the benefit of having the vnode
96 * for the directory we must use the vnode for the filesystem. This means
97 * that when a directory is actually read/written (via read, write, or
98 * readdir, or seek) we must use the vnode for the filesystem instead of
99 * the vnode for the directory as would happen in ufs. This is to insure we
100 * retrieve the correct block from the buffer cache since the hash value is
101 * based upon the vnode address and the desired block number.
105 * Create a regular file. On entry the directory to contain the file being
106 * created is locked. We must release before we return. We must also free
107 * the pathname buffer pointed at by cnp->cn_pnbuf, always on error, or
108 * only if the SAVESTART bit in cn_flags is clear on success.
111 msdosfs_create(struct vop_old_create_args *ap)
113 struct componentname *cnp = ap->a_cnp;
114 struct denode ndirent;
116 struct denode *pdep = VTODE(ap->a_dvp);
120 mprintf("msdosfs_create(cnp %p, vap %p\n", cnp, ap->a_vap);
123 * If this is the root directory and there is no space left we
124 * can't do anything. This is because the root directory can not
127 if (pdep->de_StartCluster == MSDOSFSROOT
128 && pdep->de_fndoffset >= pdep->de_FileSize) {
134 * Create a directory entry for the file, then call createde() to
135 * have it installed. NOTE: DOS files are always executable. We
136 * use the absence of the owner write bit to make the file
139 bzero(&ndirent, sizeof(ndirent));
140 error = uniqdosname(pdep, cnp, ndirent.de_Name);
144 ndirent.de_Attributes = (ap->a_vap->va_mode & VWRITE) ?
145 ATTR_ARCHIVE : ATTR_ARCHIVE | ATTR_READONLY;
146 ndirent.de_LowerCase = 0;
147 ndirent.de_StartCluster = 0;
148 ndirent.de_FileSize = 0;
149 ndirent.de_dev = pdep->de_dev;
150 ndirent.de_devvp = pdep->de_devvp;
151 ndirent.de_pmp = pdep->de_pmp;
152 ndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE;
154 DETIMES(&ndirent, &ts, &ts, &ts);
155 error = createde(&ndirent, pdep, &dep, cnp);
158 *ap->a_vpp = DETOV(dep);
165 static int msdosfs_mkdir(struct vop_old_mkdir_args *);
168 msdosfs_mknod(struct vop_old_mknod_args *ap)
170 switch (ap->a_vap->va_type) {
172 return (msdosfs_mkdir((struct vop_old_mkdir_args *)ap));
174 return (msdosfs_create((struct vop_old_create_args *)ap));
182 msdosfs_open(struct vop_open_args *ap)
184 return(vop_stdopen(ap));
188 msdosfs_close(struct vop_close_args *ap)
190 struct vnode *vp = ap->a_vp;
191 struct denode *dep = VTODE(vp);
194 if (VREFCNT(vp) > 1) {
196 DETIMES(dep, &ts, &ts, &ts);
198 return (vop_stdclose(ap));
202 msdosfs_access(struct vop_access_args *ap)
204 struct denode *dep = VTODE(ap->a_vp);
205 struct msdosfsmount *pmp = dep->de_pmp;
208 file_mode = (S_IXUSR|S_IXGRP|S_IXOTH) | (S_IRUSR|S_IRGRP|S_IROTH) |
209 ((dep->de_Attributes & ATTR_READONLY) ?
210 0 : (S_IWUSR|S_IWGRP|S_IWOTH));
211 file_mode &= (ap->a_vp->v_type == VDIR ? pmp->pm_dirmask : pmp->pm_mask);
213 return (vop_helper_access(ap, pmp->pm_uid, pmp->pm_gid, file_mode, 0));
217 msdosfs_getattr(struct vop_getattr_args *ap)
219 struct denode *dep = VTODE(ap->a_vp);
220 struct msdosfsmount *pmp = dep->de_pmp;
221 struct vattr *vap = ap->a_vap;
224 u_long dirsperblk = pmp->pm_BytesPerSec / sizeof(struct direntry);
228 DETIMES(dep, &ts, &ts, &ts);
229 vap->va_fsid = dev2udev(dep->de_dev);
231 * The following computation of the fileid must be the same as that
232 * used in msdosfs_readdir() to compute d_fileno. If not, pwd
235 if (dep->de_Attributes & ATTR_DIRECTORY) {
236 fileid = xcntobn(pmp, dep->de_StartCluster) * dirsperblk;
237 if (dep->de_StartCluster == MSDOSFSROOT)
240 fileid = xcntobn(pmp, dep->de_dirclust) * dirsperblk;
241 if (dep->de_dirclust == MSDOSFSROOT)
242 fileid = roottobn(pmp, 0) * dirsperblk;
243 fileid += dep->de_diroffset / sizeof(struct direntry);
245 vap->va_fileid = fileid;
246 if ((dep->de_Attributes & ATTR_READONLY) == 0)
247 mode = S_IRWXU|S_IRWXG|S_IRWXO;
249 mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
250 vap->va_mode = mode &
251 (ap->a_vp->v_type == VDIR ? pmp->pm_dirmask : pmp->pm_mask);
252 vap->va_uid = pmp->pm_uid;
253 vap->va_gid = pmp->pm_gid;
255 vap->va_rmajor = VNOVAL;
256 vap->va_rminor = VNOVAL;
257 vap->va_size = dep->de_FileSize;
258 dos2unixtime(dep->de_MDate, dep->de_MTime, 0, &vap->va_mtime);
259 if (pmp->pm_flags & MSDOSFSMNT_LONGNAME) {
260 dos2unixtime(dep->de_ADate, 0, 0, &vap->va_atime);
261 dos2unixtime(dep->de_CDate, dep->de_CTime, dep->de_CHun,
264 vap->va_atime = vap->va_mtime;
265 vap->va_ctime = vap->va_mtime;
268 if ((dep->de_Attributes & ATTR_ARCHIVE) == 0)
269 vap->va_flags |= SF_ARCHIVED;
271 vap->va_blocksize = pmp->pm_bpcluster;
273 (dep->de_FileSize + pmp->pm_crbomask) & ~pmp->pm_crbomask;
274 vap->va_type = ap->a_vp->v_type;
275 vap->va_filerev = dep->de_modrev;
280 msdosfs_setattr(struct vop_setattr_args *ap)
282 struct vnode *vp = ap->a_vp;
283 struct denode *dep = VTODE(vp);
284 struct msdosfsmount *pmp = dep->de_pmp;
285 struct vattr *vap = ap->a_vap;
286 struct ucred *cred = ap->a_cred;
289 mprintf("msdosfs_setattr(): vp %p, vap %p, cred %p\n", vp, vap, cred);
292 * Check for unsettable attributes.
294 if ((vap->va_type != VNON) || (vap->va_nlink != VNOVAL) ||
295 (vap->va_fsid != VNOVAL) || (vap->va_fileid != VNOVAL) ||
296 (vap->va_blocksize != VNOVAL) || (vap->va_rmajor != VNOVAL) ||
297 (vap->va_bytes != VNOVAL) || (vap->va_gen != VNOVAL)) {
298 mprintf("msdosfs_setattr(): returning EINVAL\n");
299 mprintf(" va_type %u, va_nlink %"PRIx64", va_fsid %x, va_fileid %"PRIx64"\n",
300 vap->va_type, vap->va_nlink, vap->va_fsid, vap->va_fileid);
301 mprintf(" va_blocksize %lx, va_rmajor %x, va_bytes %"PRIx64", va_gen %"PRIx64"\n",
302 vap->va_blocksize, vap->va_rmajor, vap->va_bytes,
304 mprintf(" va_uid %x, va_gid %x\n",
305 vap->va_uid, vap->va_gid);
308 if (vap->va_flags != VNOVAL) {
309 if (vp->v_mount->mnt_flag & MNT_RDONLY)
311 if (cred->cr_uid != pmp->pm_uid &&
312 (error = priv_check_cred(cred, PRIV_VFS_SETATTR, 0)))
315 * We are very inconsistent about handling unsupported
316 * attributes. We ignored the access time and the
317 * read and execute bits. We were strict for the other
320 * Here we are strict, stricter than ufs in not allowing
321 * users to attempt to set SF_SETTABLE bits or anyone to
322 * set unsupported bits. However, we ignore attempts to
323 * set ATTR_ARCHIVE for directories `cp -pr' from a more
324 * sensible file system attempts it a lot.
326 if (cred->cr_uid != 0) {
327 if (vap->va_flags & SF_SETTABLE)
330 if (vap->va_flags & ~SF_ARCHIVED)
332 if (vap->va_flags & SF_ARCHIVED)
333 dep->de_Attributes &= ~ATTR_ARCHIVE;
334 else if (!(dep->de_Attributes & ATTR_DIRECTORY))
335 dep->de_Attributes |= ATTR_ARCHIVE;
336 dep->de_flag |= DE_MODIFIED;
339 if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) {
343 if (vp->v_mount->mnt_flag & MNT_RDONLY)
346 if (uid == (uid_t)VNOVAL)
349 if (gid == (gid_t)VNOVAL)
351 if ((cred->cr_uid != pmp->pm_uid || uid != pmp->pm_uid ||
352 (gid != pmp->pm_gid && !groupmember(gid, cred))) &&
353 (error = priv_check_cred(cred, PRIV_VFS_SETATTR, 0)))
355 if (uid != pmp->pm_uid || gid != pmp->pm_gid)
359 if (vap->va_size != VNOVAL) {
361 * Disallow write attempts on read-only file systems;
362 * unless the file is a socket, fifo, or a block or
363 * character device resident on the file system.
365 switch (vp->v_type) {
371 if (vp->v_mount->mnt_flag & MNT_RDONLY)
377 error = detrunc(dep, vap->va_size, 0);
381 if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
382 if (vp->v_mount->mnt_flag & MNT_RDONLY)
384 if (cred->cr_uid != pmp->pm_uid &&
385 (error = priv_check_cred(cred, PRIV_VFS_SETATTR, 0)) &&
386 ((vap->va_vaflags & VA_UTIMES_NULL) == 0 ||
387 (error = VOP_EACCESS(vp, VWRITE, cred))))
389 if (vp->v_type != VDIR) {
390 if ((pmp->pm_flags & MSDOSFSMNT_NOWIN95) == 0 &&
391 vap->va_atime.tv_sec != VNOVAL) {
392 dep->de_flag &= ~DE_ACCESS;
393 unix2dostime(&vap->va_atime, &dep->de_ADate,
396 if (vap->va_mtime.tv_sec != VNOVAL) {
397 dep->de_flag &= ~DE_UPDATE;
398 unix2dostime(&vap->va_mtime, &dep->de_MDate,
399 &dep->de_MTime, NULL);
401 dep->de_Attributes |= ATTR_ARCHIVE;
402 dep->de_flag |= DE_MODIFIED;
406 * DOS files only have the ability to have their writability
407 * attribute set, so we use the owner write bit to set the readonly
410 if (vap->va_mode != (mode_t)VNOVAL) {
411 if (vp->v_mount->mnt_flag & MNT_RDONLY)
413 if (cred->cr_uid != pmp->pm_uid &&
414 (error = priv_check_cred(cred, PRIV_VFS_SETATTR, 0)))
416 if (vp->v_type != VDIR) {
417 /* We ignore the read and execute bits. */
418 if (vap->va_mode & VWRITE)
419 dep->de_Attributes &= ~ATTR_READONLY;
421 dep->de_Attributes |= ATTR_READONLY;
422 dep->de_Attributes |= ATTR_ARCHIVE;
423 dep->de_flag |= DE_MODIFIED;
426 return (deupdat(dep, 1));
430 msdosfs_read(struct vop_read_args *ap)
446 struct vnode *vp = ap->a_vp;
447 struct denode *dep = VTODE(vp);
448 struct msdosfsmount *pmp = dep->de_pmp;
449 struct uio *uio = ap->a_uio;
451 if (uio->uio_offset < 0)
454 if ((uoff_t)uio->uio_offset > DOS_FILESIZE_MAX)
457 * If they didn't ask for any data, then we are done.
459 orig_resid = uio->uio_resid;
463 seqcount = ap->a_ioflag >> IO_SEQSHIFT;
465 isadir = dep->de_Attributes & ATTR_DIRECTORY;
467 if (uio->uio_offset >= dep->de_FileSize)
471 * note: lbn is a cluster number, not a device block number.
473 lbn = de_off2cn(pmp, uio->uio_offset);
474 loffset = de_cn2doff(pmp, lbn);
477 * If we are operating on a directory file then be sure to
478 * do i/o with the vnode for the filesystem instead of the
479 * vnode for the directory.
483 * convert cluster # to block #. lbn is a
484 * device block number after this.
486 error = pcbmap(dep, lbn, &lbn, NULL, &blsize);
487 loffset = de_bntodoff(pmp, lbn);
488 if (error == E2BIG) {
493 error = bread(pmp->pm_devvp, loffset, blsize, &bp);
495 blsize = pmp->pm_bpcluster;
497 raoffset = de_cn2doff(pmp, rablock);
499 raoffset < dep->de_FileSize) {
500 rasize = pmp->pm_bpcluster;
501 error = breadn(vp, loffset, blsize,
502 &raoffset, &rasize, 1, &bp);
504 error = bread(vp, loffset, blsize, &bp);
511 on = uio->uio_offset & pmp->pm_crbomask;
512 diff = pmp->pm_bpcluster - on;
513 n = szmin(uio->uio_resid, diff);
514 diff = dep->de_FileSize - uio->uio_offset;
517 diff = blsize - bp->b_resid;
520 error = uiomovebp(bp, bp->b_data + on, (size_t)n, uio);
522 } while (error == 0 && uio->uio_resid > 0 && n != 0);
524 if (!isadir && (error == 0 || uio->uio_resid != orig_resid) &&
525 (vp->v_mount->mnt_flag & MNT_NOATIME) == 0)
526 dep->de_flag |= DE_ACCESS;
531 * Write data to a file or directory.
534 msdosfs_write(struct vop_write_args *ap)
544 int ioflag = ap->a_ioflag;
545 struct uio *uio = ap->a_uio;
546 struct thread *td = uio->uio_td;
547 struct vnode *vp = ap->a_vp;
548 struct vnode *thisvp;
549 struct denode *dep = VTODE(vp);
550 struct msdosfsmount *pmp = dep->de_pmp;
551 struct proc *p = (td ? td->td_proc : NULL);
552 struct lwp *lp = (td ? td->td_lwp : NULL);
554 mprintf("msdosfs_write(vp %p, uio %p, ioflag %x, cred %p\n",
555 vp, uio, ioflag, ap->a_cred);
556 mprintf("msdosfs_write(): diroff %lu, dirclust %lu, startcluster %lu\n",
557 dep->de_diroffset, dep->de_dirclust, dep->de_StartCluster);
559 switch (vp->v_type) {
561 if (ioflag & IO_APPEND)
562 uio->uio_offset = dep->de_FileSize;
568 panic("msdosfs_write(): bad file type");
571 if (uio->uio_offset < 0)
574 if (uio->uio_resid == 0)
578 * If they've exceeded their filesize limit, tell them about it.
581 ((uoff_t)uio->uio_offset + uio->uio_resid >
582 p->p_rlimit[RLIMIT_FSIZE].rlim_cur)) {
583 lwpsignal(p, lp, SIGXFSZ);
587 if ((uoff_t)uio->uio_offset > DOS_FILESIZE_MAX)
589 if ((uoff_t)uio->uio_offset + uio->uio_resid > DOS_FILESIZE_MAX)
593 * If the offset we are starting the write at is beyond the end of
594 * the file, then they've done a seek. Unix filesystems allow
595 * files with holes in them, DOS doesn't so we must fill the hole
596 * with zeroed blocks.
598 if (uio->uio_offset > dep->de_FileSize) {
599 error = deextend(dep, uio->uio_offset);
605 * Remember some values in case the write fails.
607 resid = uio->uio_resid;
608 osize = dep->de_FileSize;
611 * If we write beyond the end of the file, extend it to its ultimate
612 * size ahead of the time to hopefully get a contiguous area.
614 if (uio->uio_offset + resid > osize) {
615 count = de_clcount(pmp, uio->uio_offset + resid) -
616 de_clcount(pmp, osize);
617 error = extendfile(dep, count, NULL, NULL, 0);
618 if (error && (error != ENOSPC || (ioflag & IO_UNIT)))
620 lastcn = dep->de_fc[FC_LASTFC].fc_frcn;
622 lastcn = de_clcount(pmp, osize) - 1;
625 if (de_off2cn(pmp, uio->uio_offset) > lastcn) {
630 croffset = uio->uio_offset & pmp->pm_crbomask;
631 n = (int)szmin(uio->uio_resid, pmp->pm_bpcluster - croffset);
632 if (uio->uio_offset + n > dep->de_FileSize) {
633 dep->de_FileSize = uio->uio_offset + n;
634 /* The object size needs to be set before buffer is allocated */
635 vnode_pager_setsize(vp, dep->de_FileSize);
639 * If either the whole cluster gets written, or we write
640 * the cluster from its start beyond EOF, then no need to
641 * read data from disk.
643 * If UIO_NOCOPY is set we have to do a read-before-write
644 * to fill in any missing pieces of the buffer since no
645 * actual overwrite will occur.
647 cn = de_off2cn(pmp, uio->uio_offset);
648 if ((uio->uio_offset & pmp->pm_crbomask) == 0
649 && uio->uio_segflg != UIO_NOCOPY
650 && (de_off2cn(pmp, uio->uio_offset + uio->uio_resid)
651 > de_off2cn(pmp, uio->uio_offset)
652 || uio->uio_offset + uio->uio_resid >= dep->de_FileSize)) {
653 bp = getblk(thisvp, de_cn2doff(pmp, cn),
654 pmp->pm_bpcluster, 0, 0);
657 * Do the bmap now, since pcbmap needs buffers
658 * for the FAT table. (see msdosfs_strategy)
660 if (bp->b_bio2.bio_offset == NOOFFSET) {
661 daddr_t lblkno = de_off2cn(pmp, bp->b_loffset);
664 error = pcbmap(dep, lblkno,
665 &dblkno, NULL, NULL);
666 if (error || dblkno == (daddr_t)-1) {
667 bp->b_bio2.bio_offset = NOOFFSET;
669 bp->b_bio2.bio_offset = de_bntodoff(pmp,
673 if (bp->b_bio2.bio_offset == NOOFFSET) {
676 error = EIO; /* XXX */
681 * The block we need to write into exists, so read
684 error = bread(thisvp, de_cn2doff(pmp, cn),
685 pmp->pm_bpcluster, &bp);
693 * Should these vnode_pager_* functions be done on dir
698 * Copy the data from user space into the buf header.
700 error = uiomovebp(bp, bp->b_data + croffset, (size_t)n, uio);
707 * If they want this synchronous then write it and wait for
708 * it. Otherwise, if on a cluster boundary write it
709 * asynchronously so we can move on to the next block
710 * without delay. Otherwise do a delayed write because we
711 * may want to write somemore into the block later.
713 if (ioflag & IO_SYNC)
715 else if (n + croffset == pmp->pm_bpcluster)
719 dep->de_flag |= DE_UPDATE;
720 } while (error == 0 && uio->uio_resid > 0);
723 * If the write failed and they want us to, truncate the file back
724 * to the size it was before the write was attempted.
728 if (ioflag & IO_UNIT) {
729 detrunc(dep, osize, ioflag & IO_SYNC);
730 uio->uio_offset -= resid - uio->uio_resid;
731 uio->uio_resid = resid;
733 detrunc(dep, dep->de_FileSize, ioflag & IO_SYNC);
734 if (uio->uio_resid != resid)
737 } else if (ioflag & IO_SYNC)
738 error = deupdat(dep, 1);
743 * Flush the blocks of a file to disk.
745 * This function is worthless for vnodes that represent directories. Maybe we
746 * could just do a sync if they try an fsync on a directory file.
749 msdosfs_fsync(struct vop_fsync_args *ap)
751 struct vnode *vp = ap->a_vp;
754 * Flush all dirty buffers associated with a vnode.
759 vfsync(vp, ap->a_waitfor, 0, NULL, NULL);
761 if (ap->a_waitfor == MNT_WAIT && !RB_EMPTY(&vp->v_rbdirty_tree)) {
762 vprint("msdosfs_fsync: dirty", vp);
766 return (deupdat(VTODE(vp), ap->a_waitfor == MNT_WAIT));
770 msdosfs_remove(struct vop_old_remove_args *ap)
772 struct denode *dep = VTODE(ap->a_vp);
773 struct denode *ddep = VTODE(ap->a_dvp);
776 if (ap->a_vp->v_type == VDIR)
779 error = removede(ddep, dep);
780 mprintf("msdosfs_remove(), dep %p, v_refcnt 0x%08x\n",
781 dep, ap->a_vp->v_refcnt);
786 * DOS filesystems don't know what links are. But since we already called
787 * msdosfs_lookup() with create and lockparent, the parent is locked so we
788 * have to free it before we return the error.
791 msdosfs_link(struct vop_old_link_args *ap)
797 * Renames on files require moving the denode to a new hash queue since the
798 * denode's location is used to compute which hash queue to put the file
799 * in. Unless it is a rename in place. For example "mv a b".
801 * What follows is the basic algorithm:
804 * if (dest file exists) {
807 * if (dest and src in same directory) {
808 * rewrite name in existing directory slot
810 * write new entry in dest directory
811 * update offset and dirclust in denode
812 * move denode to new hash chain
813 * clear old directory entry
817 * if (dest directory exists) {
818 * if (dest is not empty) {
821 * remove dest directory
823 * if (dest and src in same directory) {
824 * rewrite name in existing entry
826 * be sure dest is not a child of src directory
827 * write entry in dest directory
828 * update "." and ".." in moved directory
829 * clear old directory entry for moved directory
834 * source's parent directory is unlocked
835 * source file or directory is unlocked
836 * destination's parent directory is locked
837 * destination file or directory is locked if it exists
840 * all denodes should be released
843 * I'm not sure how the memory containing the pathnames pointed at by the
844 * componentname structures is freed, there may be some memory bleeding
845 * for each rename done.
848 msdosfs_rename(struct vop_old_rename_args *ap)
850 struct vnode *tdvp = ap->a_tdvp;
851 struct vnode *fvp = ap->a_fvp;
852 struct vnode *fdvp = ap->a_fdvp;
853 struct vnode *tvp = ap->a_tvp;
854 struct componentname *tcnp = ap->a_tcnp;
855 struct componentname *fcnp = ap->a_fcnp;
856 struct denode *ip, *xp, *dp, *zp;
857 u_char toname[11], oldname[11];
858 u_long from_diroffset, to_diroffset;
860 int doingdirectory = 0, newparent = 0;
864 struct msdosfsmount *pmp;
865 struct direntry *dotdotp;
868 pmp = VFSTOMSDOSFS(fdvp->v_mount);
871 * Check for cross-device rename.
873 if ((fvp->v_mount != tdvp->v_mount) ||
874 (tvp && (fvp->v_mount != tvp->v_mount))) {
889 * If source and dest are the same, do nothing.
897 * fvp, fdvp are unlocked, tvp, tdvp are locked. Lock fvp and note
898 * that we have to unlock it to use the abortit target.
900 error = vn_lock(fvp, LK_EXCLUSIVE | LK_FAILRECLAIM);
907 * Be sure we are not renaming ".", "..", or an alias of ".". This
908 * leads to a crippled directory tree. It's pretty tough to do a
909 * "ls" or "pwd" with the "." directory entry missing, and "cd .."
910 * doesn't work if the ".." entry is missing.
912 if (ip->de_Attributes & ATTR_DIRECTORY) {
914 * Avoid ".", "..", and aliases of "." for obvious reasons.
916 if ((fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.') ||
918 (fcnp->cn_flags & CNP_ISDOTDOT) ||
919 (tcnp->cn_flags & CNP_ISDOTDOT) ||
920 (ip->de_flag & DE_RENAME)) {
925 ip->de_flag |= DE_RENAME;
930 * fvp locked, fdvp unlocked, tvp, tdvp locked. DE_RENAME only
931 * set if doingdirectory. We will get fvp unlocked in fairly
932 * short order. dp and xp must be setup and fvp must be unlocked
933 * for the out and bad targets to work properly.
936 xp = tvp ? VTODE(tvp) : NULL;
939 * Remember direntry place to use for destination
941 to_diroffset = dp->de_fndoffset;
942 to_count = dp->de_fndcnt;
945 * If ".." must be changed (ie the directory gets a new
946 * parent) then the source directory must not be in the
947 * directory hierarchy above the target, as this would
948 * orphan everything below the source directory. Also
949 * the user must have write permission in the source so
950 * as to be able to change "..". We must repeat the call
951 * to namei, as the parent directory is unlocked by the
952 * call to doscheckpath().
954 error = VOP_EACCESS(fvp, VWRITE, tcnp->cn_cred);
956 if (VTODE(fdvp)->de_StartCluster != VTODE(tdvp)->de_StartCluster)
960 * ok. fvp, fdvp unlocked, tvp, tdvp locked. tvp may be NULL.
961 * DE_RENAME only set if doingdirectory.
963 if (doingdirectory && newparent) {
964 if (error) /* write access check above */
971 * checkpath vput's tdvp (VTOI(dp)) on return no matter what,
972 * get an extra ref so we wind up with just an unlocked, ref'd
973 * tdvp. The 'out' target skips tvp and tdvp cleanups (tdvp
974 * isn't locked so we can't use the out target).
977 error = doscheckpath(ip, dp);
978 tcnp->cn_flags |= CNP_PDIRUNLOCK;
984 * relookup no longer messes with the ref count. tdvp must
985 * be unlocked on entry and on success will be locked on
988 error = relookup(tdvp, &tvp, tcnp);
990 if (tcnp->cn_flags & CNP_PDIRUNLOCK)
998 * tvp and tdvp are now locked again.
1001 xp = tvp ? VTODE(tvp) : NULL;
1005 * tvp and tdvp are now locked again, the 'bad' target can be used
1006 * to clean them up again. Delete an existant target and clean
1007 * up tvp. Set xp to NULL to indicate that tvp has been cleaned up.
1011 * Target must be empty if a directory and have no links
1012 * to it. Also, ensure source and target are compatible
1013 * (both directories, or both not directories).
1015 if (xp->de_Attributes & ATTR_DIRECTORY) {
1016 if (!dosdirempty(xp)) {
1020 if (!doingdirectory) {
1024 } else if (doingdirectory) {
1028 error = removede(dp, xp);
1037 * Convert the filename in tcnp into a dos filename. We copy this
1038 * into the denode and directory entry for the destination
1041 error = uniqdosname(VTODE(tdvp), tcnp, toname);
1046 * Since from wasn't locked at various places above, we have to do
1047 * a relookup here. If the target and source are the same directory
1048 * we have to unlock the target directory in order to safely relookup
1049 * the source, because relookup expects its directory to be unlocked.
1051 * Note that ap->a_fvp is still valid and ref'd. Any cleanup must
1052 * now take that into account.
1054 * The tdvp locking issues make this a real mess.
1056 fcnp->cn_flags &= ~CNP_MODMASK;
1057 fcnp->cn_flags |= CNP_LOCKPARENT;
1060 error = relookup(fdvp, &fvp, fcnp);
1061 if (error || fvp == NULL) {
1063 * From name has disappeared. Note: fdvp might == tdvp.
1065 * DE_RENAME is only set if doingdirectory.
1068 panic("rename: lost dir entry");
1069 if (fcnp->cn_flags & CNP_PDIRUNLOCK)
1082 * No error occured. tdvp, fdvp and fvp are all locked. If
1083 * newparent was 0 be aware that fdvp == tdvp. tvp has been cleaned
1084 * up. ap->a_fvp is still refd.
1088 from_diroffset = zp->de_fndoffset;
1091 * Ensure that the directory entry still exists and has not
1092 * changed till now. If the source is a file the entry may
1093 * have been unlinked or renamed. In either case there is
1094 * no further work to be done. If the source is a directory
1095 * then it cannot have been rmdir'ed or renamed; this is
1096 * prohibited by the DE_RENAME flag.
1098 * DE_RENAME is only set if doingdirectory.
1102 panic("rename: lost dir entry");
1105 u_long new_dirclust;
1106 u_long new_diroffset;
1109 * First write a new entry in the destination
1110 * directory and mark the entry in the source directory
1111 * as deleted. Then move the denode to the correct hash
1112 * chain for its new location in the filesystem. And, if
1113 * we moved a directory, then update its .. entry to point
1114 * to the new parent directory.
1116 bcopy(ip->de_Name, oldname, 11);
1117 bcopy(toname, ip->de_Name, 11); /* update denode */
1118 dp->de_fndoffset = to_diroffset;
1119 dp->de_fndcnt = to_count;
1120 error = createde(ip, dp, NULL, tcnp);
1122 bcopy(oldname, ip->de_Name, 11);
1126 zp->de_fndoffset = from_diroffset;
1127 error = removede(zp, ip);
1129 /* XXX should really panic here, fs is corrupt */
1132 if (!doingdirectory) {
1133 error = pcbmap(dp, de_cluster(pmp, to_diroffset),
1134 NULL, &new_dirclust, NULL);
1136 /* XXX should really panic here, fs is corrupt */
1139 if (new_dirclust == MSDOSFSROOT)
1140 new_diroffset = to_diroffset;
1142 new_diroffset = to_diroffset & pmp->pm_crbomask;
1143 msdosfs_reinsert(ip, new_dirclust, new_diroffset);
1148 * If we moved a directory to a new parent directory, then we must
1149 * fixup the ".." entry in the moved directory.
1151 if (doingdirectory && newparent) {
1152 cn = ip->de_StartCluster;
1153 if (cn == MSDOSFSROOT) {
1154 /* this should never happen */
1155 panic("msdosfs_rename(): updating .. in root directory?");
1157 bn = xcntobn(pmp, cn);
1159 error = bread(pmp->pm_devvp, de_bntodoff(pmp, bn),
1160 pmp->pm_bpcluster, &bp);
1162 /* XXX should really panic here, fs is corrupt */
1166 dotdotp = (struct direntry *)bp->b_data + 1;
1167 putushort(dotdotp->deStartCluster, dp->de_StartCluster);
1169 putushort(dotdotp->deHighClust, dp->de_StartCluster >> 16);
1172 /* XXX should really panic here, fs is corrupt */
1178 * done case fvp, fdvp, tdvp are locked. ap->a_fvp is refd
1182 ip->de_flag &= ~DE_RENAME; /* XXX fvp not locked */
1193 * 'bad' target: xp governs tvp. tvp and tdvp arel ocked, fdvp and fvp
1194 * are not locked. ip points to fvp's inode which may have DE_RENAME
1203 * 'out' target: tvp and tdvp have already been cleaned up.
1206 ip->de_flag &= ~DE_RENAME;
1214 struct direntry dot;
1215 struct direntry dotdot;
1216 } dosdirtemplate = {
1217 { ". ", /* the . entry */
1218 ATTR_DIRECTORY, /* file attribute */
1220 0, { 0, 0 }, { 0, 0 }, /* create time & date */
1221 { 0, 0 }, /* access date */
1222 { 0, 0 }, /* high bits of start cluster */
1223 { 210, 4 }, { 210, 4 }, /* modify time & date */
1224 { 0, 0 }, /* startcluster */
1225 { 0, 0, 0, 0 } /* filesize */
1227 { ".. ", /* the .. entry */
1228 ATTR_DIRECTORY, /* file attribute */
1230 0, { 0, 0 }, { 0, 0 }, /* create time & date */
1231 { 0, 0 }, /* access date */
1232 { 0, 0 }, /* high bits of start cluster */
1233 { 210, 4 }, { 210, 4 }, /* modify time & date */
1234 { 0, 0 }, /* startcluster */
1235 { 0, 0, 0, 0 } /* filesize */
1240 msdosfs_mkdir(struct vop_old_mkdir_args *ap)
1242 struct componentname *cnp = ap->a_cnp;
1244 struct denode *pdep = VTODE(ap->a_dvp);
1245 struct direntry *denp;
1246 struct msdosfsmount *pmp = pdep->de_pmp;
1248 u_long newcluster, pcl;
1251 struct denode ndirent;
1255 * If this is the root directory and there is no space left we
1256 * can't do anything. This is because the root directory can not
1259 if (pdep->de_StartCluster == MSDOSFSROOT
1260 && pdep->de_fndoffset >= pdep->de_FileSize) {
1266 * Allocate a cluster to hold the about to be created directory.
1268 error = clusteralloc(pmp, 0, 1, CLUST_EOFE, &newcluster, NULL);
1272 bzero(&ndirent, sizeof(ndirent));
1273 ndirent.de_pmp = pmp;
1274 ndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE;
1276 DETIMES(&ndirent, &ts, &ts, &ts);
1279 * Now fill the cluster with the "." and ".." entries. And write
1280 * the cluster to disk. This way it is there for the parent
1281 * directory to be pointing at if there were a crash.
1283 bn = xcntobn(pmp, newcluster);
1284 /* always succeeds */
1285 bp = getblk(pmp->pm_devvp, de_bntodoff(pmp, bn),
1286 pmp->pm_bpcluster, 0, 0);
1287 bzero(bp->b_data, pmp->pm_bpcluster);
1288 bcopy(&dosdirtemplate, bp->b_data, sizeof(dosdirtemplate));
1289 denp = (struct direntry *)bp->b_data;
1290 putushort(denp[0].deStartCluster, newcluster);
1291 putushort(denp[0].deCDate, ndirent.de_CDate);
1292 putushort(denp[0].deCTime, ndirent.de_CTime);
1293 denp[0].deCHundredth = ndirent.de_CHun;
1294 putushort(denp[0].deADate, ndirent.de_ADate);
1295 putushort(denp[0].deMDate, ndirent.de_MDate);
1296 putushort(denp[0].deMTime, ndirent.de_MTime);
1297 pcl = pdep->de_StartCluster;
1298 if (FAT32(pmp) && pcl == pmp->pm_rootdirblk)
1300 putushort(denp[1].deStartCluster, pcl);
1301 putushort(denp[1].deCDate, ndirent.de_CDate);
1302 putushort(denp[1].deCTime, ndirent.de_CTime);
1303 denp[1].deCHundredth = ndirent.de_CHun;
1304 putushort(denp[1].deADate, ndirent.de_ADate);
1305 putushort(denp[1].deMDate, ndirent.de_MDate);
1306 putushort(denp[1].deMTime, ndirent.de_MTime);
1308 putushort(denp[0].deHighClust, newcluster >> 16);
1309 putushort(denp[1].deHighClust, pdep->de_StartCluster >> 16);
1317 * Now build up a directory entry pointing to the newly allocated
1318 * cluster. This will be written to an empty slot in the parent
1321 error = uniqdosname(pdep, cnp, ndirent.de_Name);
1325 ndirent.de_Attributes = ATTR_DIRECTORY;
1326 ndirent.de_LowerCase = 0;
1327 ndirent.de_StartCluster = newcluster;
1328 ndirent.de_FileSize = 0;
1329 ndirent.de_dev = pdep->de_dev;
1330 ndirent.de_devvp = pdep->de_devvp;
1331 error = createde(&ndirent, pdep, &dep, cnp);
1334 *ap->a_vpp = DETOV(dep);
1338 clusterfree(pmp, newcluster, NULL);
1344 msdosfs_rmdir(struct vop_old_rmdir_args *ap)
1346 struct vnode *vp = ap->a_vp;
1347 struct vnode *dvp = ap->a_dvp;
1348 struct denode *ip, *dp;
1355 * Verify the directory is empty (and valid).
1356 * (Rmdir ".." won't be valid since
1357 * ".." will contain a reference to
1358 * the current directory and thus be
1362 if (!dosdirempty(ip) || ip->de_flag & DE_RENAME) {
1367 * Delete the entry from the directory. For dos filesystems this
1368 * gets rid of the directory entry on disk, the in memory copy
1369 * still exists but the de_refcnt is <= 0. This prevents it from
1370 * being found by deget(). When the vput() on dep is done we give
1371 * up access and eventually msdosfs_reclaim() will be called which
1372 * will remove it from the denode cache.
1374 error = removede(dp, ip);
1378 * This is where we decrement the link count in the parent
1379 * directory. Since dos filesystems don't do this we just purge
1384 * Truncate the directory that is being deleted.
1386 error = detrunc(ip, (u_long)0, IO_SYNC);
1388 vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
1394 * DOS filesystems don't know what symlinks are.
1397 msdosfs_symlink(struct vop_old_symlink_args *ap)
1399 return (EOPNOTSUPP);
1403 msdosfs_readdir(struct vop_readdir_args *ap)
1417 struct msdosfsmount *pmp;
1418 struct direntry *dentp;
1419 struct uio *uio = ap->a_uio;
1420 off_t *cookies = NULL;
1427 char *d_name_storage = NULL;
1428 char *d_name = NULL;
1430 error = vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM);
1434 dep = VTODE(ap->a_vp);
1437 mprintf("msdosfs_readdir(): vp %p, uio %p, cred %p, eofflagp %p\n",
1438 ap->a_vp, uio, ap->a_cred, ap->a_eofflag);
1441 * msdosfs_readdir() won't operate properly on regular files since
1442 * it does i/o only with the the filesystem vnode, and hence can
1443 * retrieve the wrong block from the buffer cache for a plain file.
1444 * So, fail attempts to readdir() on a plain file.
1446 if ((dep->de_Attributes & ATTR_DIRECTORY) == 0) {
1452 * If the user buffer is smaller than the size of one dos directory
1453 * entry or the file offset is not a multiple of the size of a
1454 * directory entry, then we fail the read.
1456 off = offset = uio->uio_offset;
1457 if (uio->uio_resid < sizeof(struct direntry) ||
1458 (offset & (sizeof(struct direntry) - 1))) {
1463 if (ap->a_ncookies) {
1464 ncookies = uio->uio_resid / 16 + 1;
1465 if (ncookies > 1024)
1467 cookies = kmalloc(ncookies * sizeof(off_t), M_TEMP, M_WAITOK);
1468 *ap->a_cookies = cookies;
1469 *ap->a_ncookies = ncookies;
1472 dirsperblk = pmp->pm_BytesPerSec / sizeof(struct direntry);
1475 * If they are reading from the root directory then, we simulate
1476 * the . and .. entries since these don't exist in the root
1477 * directory. We also set the offset bias to make up for having to
1478 * simulate these entries. By this I mean that at file offset 64 we
1479 * read the first entry in the root directory that lives on disk.
1481 if (dep->de_StartCluster == MSDOSFSROOT
1482 || (FAT32(pmp) && dep->de_StartCluster == pmp->pm_rootdirblk)) {
1483 bias = 2 * sizeof(struct direntry);
1484 if (offset < bias) {
1485 for (n = (int)offset / sizeof(struct direntry); n < 2;
1488 d_ino = xcntobn(pmp, pmp->pm_rootdirblk)
1496 } else if (n == 1) {
1500 if (vop_write_dirent(&error, uio, d_ino, d_type,
1505 offset += sizeof(struct direntry);
1508 *cookies++ = offset;
1509 if (--ncookies <= 0)
1516 d_name_storage = kmalloc(WIN_MAXLEN, M_TEMP, M_WAITOK);
1520 while (uio->uio_resid > 0) {
1521 lbn = de_off2cn(pmp, offset - bias);
1522 on = (offset - bias) & pmp->pm_crbomask;
1523 n = szmin(pmp->pm_bpcluster - on, uio->uio_resid);
1524 diff = dep->de_FileSize - (offset - bias);
1528 error = pcbmap(dep, lbn, &bn, &cn, &blsize);
1531 error = bread(pmp->pm_devvp, de_bntodoff(pmp, bn), blsize, &bp);
1534 kfree(d_name_storage, M_TEMP);
1537 n = min(n, blsize - bp->b_resid);
1540 * Convert from dos directory entries to fs-independent
1541 * directory entries.
1543 for (dentp = (struct direntry *)(bp->b_data + on);
1544 (char *)dentp < bp->b_data + on + n;
1545 dentp++, offset += sizeof(struct direntry)) {
1546 d_name = d_name_storage;
1549 * If this is an unused entry, we can stop.
1551 if (dentp->deName[0] == SLOT_EMPTY) {
1556 * Skip deleted entries.
1558 if (dentp->deName[0] == SLOT_DELETED) {
1564 * Handle Win95 long directory entries
1566 if (dentp->deAttributes == ATTR_WIN95) {
1567 if (pmp->pm_flags & MSDOSFSMNT_SHORTNAME)
1569 chksum = win2unixfn(&nb,
1570 (struct winentry *)dentp,
1576 * Skip volume labels
1578 if (dentp->deAttributes & ATTR_VOLUME) {
1584 * This computation of d_ino must match
1585 * the computation of va_fileid in
1588 if (dentp->deAttributes & ATTR_DIRECTORY) {
1589 d_ino = getushort(dentp->deStartCluster);
1591 d_ino |= getushort(dentp->deHighClust) << 16;
1592 /* if this is the root directory */
1593 if (d_ino != MSDOSFSROOT)
1594 d_ino = xcntobn(pmp, d_ino) * dirsperblk;
1595 else if (FAT32(pmp))
1596 d_ino = xcntobn(pmp, pmp->pm_rootdirblk)
1602 d_ino = offset / sizeof(struct direntry);
1605 if (chksum != winChksum(dentp->deName)) {
1606 d_namlen = dos2unixfn(dentp->deName,
1608 dentp->deLowerCase |
1609 ((pmp->pm_flags & MSDOSFSMNT_SHORTNAME) ?
1610 (LCASE_BASE | LCASE_EXT) : 0),
1614 mbnambuf_flush(&nb, d_name, &d_namlen);
1617 if (vop_write_dirent(&error, uio, d_ino, d_type,
1618 d_namlen, d_name)) {
1628 *cookies++ = offset + sizeof(struct direntry);
1629 if (--ncookies <= 0) {
1634 off = offset + sizeof(struct direntry);
1639 if (d_name_storage != NULL)
1640 kfree(d_name_storage, M_TEMP);
1642 /* Subtract unused cookies */
1644 *ap->a_ncookies -= ncookies;
1646 uio->uio_offset = off;
1649 * Set the eofflag (NFS uses it)
1651 if (ap->a_eofflag) {
1652 if (dep->de_FileSize - (offset - bias) <= 0)
1658 vn_unlock(ap->a_vp);
1663 * vp - address of vnode file the file
1664 * bn - which cluster we are interested in mapping to a filesystem block number.
1665 * vpp - returns the vnode for the block special file holding the filesystem
1666 * containing the file of interest
1667 * bnp - address of where to return the filesystem relative block number
1670 msdosfs_bmap(struct vop_bmap_args *ap)
1672 struct denode *dep = VTODE(ap->a_vp);
1673 struct msdosfsmount *pmp = dep->de_pmp;
1678 if (ap->a_doffsetp == NULL)
1682 * Sequential clusters should be counted here.
1689 KKASSERT(((int)ap->a_loffset & ((1 << pmp->pm_cnshift) - 1)) == 0);
1690 lbn = de_off2cn(pmp, ap->a_loffset);
1691 error = pcbmap(dep, lbn, &dbn, NULL, NULL);
1692 if (error || dbn == (daddr_t)-1) {
1693 *ap->a_doffsetp = NOOFFSET;
1695 *ap->a_doffsetp = de_bntodoff(pmp, dbn);
1701 msdosfs_strategy(struct vop_strategy_args *ap)
1703 struct bio *bio = ap->a_bio;
1705 struct buf *bp = bio->bio_buf;
1706 struct vnode *vp = ap->a_vp;
1707 struct denode *dep = VTODE(vp);
1708 struct msdosfsmount *pmp = dep->de_pmp;
1712 if (vp->v_type == VBLK || vp->v_type == VCHR)
1713 panic("msdosfs_strategy: spec");
1715 * If we don't already know the filesystem relative block number
1716 * then get it using pcbmap(). If pcbmap() returns the block
1717 * number as -1 then we've got a hole in the file. DOS filesystems
1718 * don't allow files with holes, so we shouldn't ever see this.
1720 nbio = push_bio(bio);
1721 if (nbio->bio_offset == NOOFFSET) {
1722 error = pcbmap(dep, de_off2cn(pmp, bio->bio_offset),
1723 &dblkno, NULL, NULL);
1725 bp->b_error = error;
1726 bp->b_flags |= B_ERROR;
1727 /* I/O was never started on nbio, must biodone(bio) */
1731 if (dblkno == (daddr_t)-1) {
1732 nbio->bio_offset = NOOFFSET;
1735 nbio->bio_offset = de_bntodoff(pmp, dblkno);
1738 if (nbio->bio_offset == NOOFFSET) {
1739 /* I/O was never started on nbio, must biodone(bio) */
1744 * Read/write the block from/to the disk that contains the desired
1747 vn_strategy(dep->de_devvp, nbio);
1752 msdosfs_print(struct vop_print_args *ap)
1754 struct denode *dep = VTODE(ap->a_vp);
1756 kprintf("tag VT_MSDOSFS, startcluster %lu, dircluster %lu, "
1757 "diroffset %lu, dev %d, %d",
1758 dep->de_StartCluster, dep->de_dirclust, dep->de_diroffset,
1759 major(dep->de_dev), minor(dep->de_dev));
1760 lockmgr_printinfo(&ap->a_vp->v_lock);
1765 msdosfs_pathconf(struct vop_pathconf_args *ap)
1767 struct msdosfsmount *pmp = VTODE(ap->a_vp)->de_pmp;
1769 switch (ap->a_name) {
1770 case _PC_CHOWN_RESTRICTED:
1773 case _PC_FILESIZEBITS:
1774 *ap->a_retval = FAT12(pmp) ? 32 : 33;
1781 pmp->pm_flags & MSDOSFSMNT_LONGNAME ? WIN_MAXLEN : 12;
1787 *ap->a_retval = PATH_MAX;
1795 /* Global vfs data structures for msdosfs */
1796 struct vop_ops msdosfs_vnode_vops = {
1797 .vop_default = vop_defaultop,
1798 .vop_access = msdosfs_access,
1799 .vop_bmap = msdosfs_bmap,
1800 .vop_old_lookup = msdosfs_lookup,
1801 .vop_open = msdosfs_open,
1802 .vop_close = msdosfs_close,
1803 .vop_old_create = msdosfs_create,
1804 .vop_fsync = msdosfs_fsync,
1805 .vop_getattr = msdosfs_getattr,
1806 .vop_inactive = msdosfs_inactive,
1807 .vop_old_link = msdosfs_link,
1808 .vop_old_mkdir = msdosfs_mkdir,
1809 .vop_old_mknod = msdosfs_mknod,
1810 .vop_pathconf = msdosfs_pathconf,
1811 .vop_print = msdosfs_print,
1812 .vop_read = msdosfs_read,
1813 .vop_readdir = msdosfs_readdir,
1814 .vop_reclaim = msdosfs_reclaim,
1815 .vop_old_remove = msdosfs_remove,
1816 .vop_old_rename = msdosfs_rename,
1817 .vop_old_rmdir = msdosfs_rmdir,
1818 .vop_setattr = msdosfs_setattr,
1819 .vop_strategy = msdosfs_strategy,
1820 .vop_old_symlink = msdosfs_symlink,
1821 .vop_write = msdosfs_write,
1822 .vop_getpages = vop_stdgetpages,
1823 .vop_putpages = vop_stdputpages