CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mlelstv Date: Sat May 4 05:49:39 UTC 2024 Modified Files: src/sys/fs/msdosfs: msdosfs_rename.c Log Message: >From genfs_rename.c: * XXX Want a better equality test. `tcnp->cn_cred == cred' * hoses p2k because puffs transmits the creds separately and * allocates distinct but equivalent structures for them. Fixes rename crash in rump_msdos. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/fs/msdosfs/msdosfs_rename.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_rename.c diff -u src/sys/fs/msdosfs/msdosfs_rename.c:1.3 src/sys/fs/msdosfs/msdosfs_rename.c:1.4 --- src/sys/fs/msdosfs/msdosfs_rename.c:1.3 Sat Oct 23 16:58:17 2021 +++ src/sys/fs/msdosfs/msdosfs_rename.c Sat May 4 05:49:39 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_rename.c,v 1.3 2021/10/23 16:58:17 thorpej Exp $ */ +/* $NetBSD: msdosfs_rename.c,v 1.4 2024/05/04 05:49:39 mlelstv Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_rename.c,v 1.3 2021/10/23 16:58:17 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_rename.c,v 1.4 2024/05/04 05:49:39 mlelstv Exp $"); #include #include @@ -127,7 +127,7 @@ msdosfs_rename(void *v) KASSERT(tdvp->v_type == VDIR); cred = fcnp->cn_cred; - KASSERT(tcnp->cn_cred == cred); + KASSERT(kauth_cred_uidmatch(cred, tcnp->cn_cred)); /* * Sanitize our world from the VFS insanity. Unlock the target
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mlelstv Date: Sat May 4 05:49:39 UTC 2024 Modified Files: src/sys/fs/msdosfs: msdosfs_rename.c Log Message: >From genfs_rename.c: * XXX Want a better equality test. `tcnp->cn_cred == cred' * hoses p2k because puffs transmits the creds separately and * allocates distinct but equivalent structures for them. Fixes rename crash in rump_msdos. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/fs/msdosfs/msdosfs_rename.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mrg Date: Fri Aug 18 21:05:44 UTC 2023 Modified Files: src/sys/fs/msdosfs: msdosfs_vnops.c Log Message: fix the previous to not fail to include the extension in lookups. copy deExtension into the final 3 bytes. previously, this was found by having them next to each other in the containing structure, but as separate strings. thanks to miod for pointing this out. To generate a diff of this commit: cvs rdiff -u -r1.111 -r1.112 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vnops.c diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.111 src/sys/fs/msdosfs/msdosfs_vnops.c:1.112 --- src/sys/fs/msdosfs/msdosfs_vnops.c:1.111 Mon Aug 14 05:41:09 2023 +++ src/sys/fs/msdosfs/msdosfs_vnops.c Fri Aug 18 21:05:44 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vnops.c,v 1.111 2023/08/14 05:41:09 mrg Exp $ */ +/* $NetBSD: msdosfs_vnops.c,v 1.112 2023/08/18 21:05:44 mrg Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.111 2023/08/14 05:41:09 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.112 2023/08/18 21:05:44 mrg Exp $"); #include #include @@ -1168,7 +1168,10 @@ msdosfs_readdir(void *v) memcpy(deName, dentp->deName, sizeof dentp->deName); -memset([8], 0, 3); +memcpy(deName + 8, dentp->deExtension, + sizeof dentp->deExtension); +assert(sizeof(deName) == sizeof(dentp->deName) + + sizeof(dentp->deExtension)); dirbuf->d_namlen = msdosfs_dos2unixfn(deName, (u_char *)dirbuf->d_name,
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mrg Date: Fri Aug 18 21:05:44 UTC 2023 Modified Files: src/sys/fs/msdosfs: msdosfs_vnops.c Log Message: fix the previous to not fail to include the extension in lookups. copy deExtension into the final 3 bytes. previously, this was found by having them next to each other in the containing structure, but as separate strings. thanks to miod for pointing this out. To generate a diff of this commit: cvs rdiff -u -r1.111 -r1.112 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mrg Date: Mon Aug 14 05:41:09 UTC 2023 Modified Files: src/sys/fs/msdosfs: msdosfs_vnops.c Log Message: when calling a function that needs more bytes than we have, create a stack variable long enough and use that instead. found by GCC 12. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mrg Date: Mon Aug 14 05:41:09 UTC 2023 Modified Files: src/sys/fs/msdosfs: msdosfs_vnops.c Log Message: when calling a function that needs more bytes than we have, create a stack variable long enough and use that instead. found by GCC 12. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vnops.c diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.110 src/sys/fs/msdosfs/msdosfs_vnops.c:1.111 --- src/sys/fs/msdosfs/msdosfs_vnops.c:1.110 Sat Oct 23 16:58:17 2021 +++ src/sys/fs/msdosfs/msdosfs_vnops.c Mon Aug 14 05:41:09 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vnops.c,v 1.110 2021/10/23 16:58:17 thorpej Exp $ */ +/* $NetBSD: msdosfs_vnops.c,v 1.111 2023/08/14 05:41:09 mrg Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.110 2021/10/23 16:58:17 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.111 2023/08/14 05:41:09 mrg Exp $"); #include #include @@ -1163,12 +1163,17 @@ msdosfs_readdir(void *v) offset / sizeof(struct direntry); dirbuf->d_type = DT_REG; } - if (chksum != msdosfs_winChksum(dentp->deName)) + if (chksum != msdosfs_winChksum(dentp->deName)) { +char deName[11]; + +memcpy(deName, dentp->deName, + sizeof dentp->deName); +memset([8], 0, 3); dirbuf->d_namlen = -msdosfs_dos2unixfn(dentp->deName, -(u_char *)dirbuf->d_name, -pmp->pm_flags & MSDOSFSMNT_SHORTNAME); - else +msdosfs_dos2unixfn(deName, +(u_char *)dirbuf->d_name, +pmp->pm_flags & MSDOSFSMNT_SHORTNAME); + } else dirbuf->d_name[dirbuf->d_namlen] = 0; namlen = dirbuf->d_namlen; chksum = -1;
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: andvar Date: Mon Feb 13 23:14:21 UTC 2023 Modified Files: src/sys/fs/msdosfs: msdosfs_conv.c Log Message: s/chacters/characters/ in comments. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/fs/msdosfs/msdosfs_conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_conv.c diff -u src/sys/fs/msdosfs/msdosfs_conv.c:1.18 src/sys/fs/msdosfs/msdosfs_conv.c:1.19 --- src/sys/fs/msdosfs/msdosfs_conv.c:1.18 Sat Oct 23 16:58:17 2021 +++ src/sys/fs/msdosfs/msdosfs_conv.c Mon Feb 13 23:14:21 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_conv.c,v 1.18 2021/10/23 16:58:17 thorpej Exp $ */ +/* $NetBSD: msdosfs_conv.c,v 1.19 2023/02/13 23:14:21 andvar Exp $ */ /*- * Copyright (C) 1995, 1997 Wolfgang Solfrank. @@ -58,7 +58,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.18 2021/10/23 16:58:17 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.19 2023/02/13 23:14:21 andvar Exp $"); /* * System include files. @@ -866,7 +866,7 @@ ucs2utf8str(const u_int16_t *in, int n, /* * Convert UTF8 string into UCS-2 string - * return total number of output chacters + * return total number of output characters */ static int utf8ucs2str(const u_int8_t *in, int n, u_int16_t *out, int m) @@ -920,7 +920,7 @@ ucs2char8str(const u_int16_t *in, int n, /* * Convert 8bit character string into UCS-2 string - * return total number of output chacters + * return total number of output characters */ static int char8ucs2str(const u_int8_t *in, int n, u_int16_t *out, int m)
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: andvar Date: Mon Feb 13 23:14:21 UTC 2023 Modified Files: src/sys/fs/msdosfs: msdosfs_conv.c Log Message: s/chacters/characters/ in comments. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/fs/msdosfs/msdosfs_conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Sat Apr 16 07:58:21 UTC 2022 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Lock vnode for vinvalbuf(). To generate a diff of this commit: cvs rdiff -u -r1.137 -r1.138 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.137 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.138 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.137 Sat Oct 23 16:58:17 2021 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Sat Apr 16 07:58:21 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.137 2021/10/23 16:58:17 thorpej Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.138 2022/04/16 07:58:21 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.137 2021/10/23 16:58:17 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.138 2022/04/16 07:58:21 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -472,7 +472,10 @@ msdosfs_mountfs(struct vnode *devvp, str u_long fatbytes, fatblocksecs; /* Flush out any old buffers remaining from a previous use. */ - if ((error = vinvalbuf(devvp, V_SAVE, l->l_cred, l, 0, 0)) != 0) + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); + error = vinvalbuf(devvp, V_SAVE, l->l_cred, l, 0, 0); + VOP_UNLOCK(devvp); + if (error) return (error); ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Sat Apr 16 07:58:21 UTC 2022 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Lock vnode for vinvalbuf(). To generate a diff of this commit: cvs rdiff -u -r1.137 -r1.138 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Sat Oct 23 07:45:03 UTC 2021 Modified Files: src/sys/fs/msdosfs: denode.h msdosfs_rename.c Log Message: Convert msdosfs_rename() to use genfs_sane_rename(). Based on work by Taylor R Campbell. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/fs/msdosfs/denode.h cvs rdiff -u -r1.1 -r1.2 src/sys/fs/msdosfs/msdosfs_rename.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/denode.h diff -u src/sys/fs/msdosfs/denode.h:1.27 src/sys/fs/msdosfs/denode.h:1.28 --- src/sys/fs/msdosfs/denode.h:1.27 Sat Oct 23 07:38:33 2021 +++ src/sys/fs/msdosfs/denode.h Sat Oct 23 07:45:03 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: denode.h,v 1.27 2021/10/23 07:38:33 hannken Exp $ */ +/* $NetBSD: denode.h,v 1.28 2021/10/23 07:45:03 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -318,7 +318,6 @@ int deget(struct msdosfsmount *, u_long, #endif int detrunc(struct denode *, u_long, int, struct kauth_cred *); int deupdat(struct denode *, int); -int doscheckpath(struct denode *, struct denode *); int dosdirempty(struct denode *); int readde(struct denode *, struct buf **, struct direntry **); int readep(struct msdosfsmount *, u_long, u_long, Index: src/sys/fs/msdosfs/msdosfs_rename.c diff -u src/sys/fs/msdosfs/msdosfs_rename.c:1.1 src/sys/fs/msdosfs/msdosfs_rename.c:1.2 --- src/sys/fs/msdosfs/msdosfs_rename.c:1.1 Sat Oct 23 07:41:37 2021 +++ src/sys/fs/msdosfs/msdosfs_rename.c Sat Oct 23 07:45:03 2021 @@ -1,10 +1,11 @@ -/* $NetBSD: msdosfs_rename.c,v 1.1 2021/10/23 07:41:37 hannken Exp $ */ +/* $NetBSD: msdosfs_rename.c,v 1.2 2021/10/23 07:45:03 hannken Exp $ */ /*- - * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. - * Copyright (C) 1994, 1995, 1997 TooLs GmbH. + * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. - * Original code by Paul Popelka (pa...@uts.amdahl.com) (see below). + * + * This code is derived from software contributed to The NetBSD Foundation + * by Taylor R Campbell. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -14,60 +15,36 @@ * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in the *documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - *must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - *derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Written by Paul Popelka (pa...@uts.amdahl.com) - * - * You can do anything you want with this software, just don't say you wrote - * it, and don't remove this notice. - * - * This software is provided "as is". - * - * The author supplies this software to be publicly redistributed on the - * understanding that the author is not responsible for the correct - * functioning of this software in any circumstances and is not liable for - * any damages caused by this software. * - * October 1992 + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ +/* + * MS-DOS FS Rename + */ + +#include
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Sat Oct 23 07:45:03 UTC 2021 Modified Files: src/sys/fs/msdosfs: denode.h msdosfs_rename.c Log Message: Convert msdosfs_rename() to use genfs_sane_rename(). Based on work by Taylor R Campbell. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/fs/msdosfs/denode.h cvs rdiff -u -r1.1 -r1.2 src/sys/fs/msdosfs/msdosfs_rename.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: ryoon Date: Thu Feb 11 00:15:55 UTC 2021 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Enable to mount Raspberry Pi Pico's USB mass storage partition Fix PR kern/55985. O.k. by thorpej@. Pull-up to netbsd-8 and netbsd-9. To generate a diff of this commit: cvs rdiff -u -r1.135 -r1.136 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: ryoon Date: Thu Feb 11 00:15:55 UTC 2021 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Enable to mount Raspberry Pi Pico's USB mass storage partition Fix PR kern/55985. O.k. by thorpej@. Pull-up to netbsd-8 and netbsd-9. To generate a diff of this commit: cvs rdiff -u -r1.135 -r1.136 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.135 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.136 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.135 Mon Apr 13 19:23:17 2020 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Thu Feb 11 00:15:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.135 2020/04/13 19:23:17 ad Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.136 2021/02/11 00:15:55 ryoon Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.135 2020/04/13 19:23:17 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.136 2021/02/11 00:15:55 ryoon Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -520,6 +520,13 @@ msdosfs_mountfs(struct vnode *devvp, str b50 = (struct byte_bpb50 *)bsp->bs50.bsBPB; b710 = (struct byte_bpb710 *)bsp->bs710.bsBPB; +#if 0 + /* + * Some FAT partition, for example Raspberry Pi Pico's + * USB mass storage, does not have exptected BOOTSIGs. + * According to FreeBSD's comment, some PC-9800/9821 + * FAT floppy disks have similar problems. + */ if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) { if (bsp->bs50.bsBootSectSig0 != BOOTSIG0 || bsp->bs50.bsBootSectSig1 != BOOTSIG1) { @@ -530,6 +537,7 @@ msdosfs_mountfs(struct vnode *devvp, str goto error_exit; } } +#endif pmp = malloc(sizeof(*pmp), M_MSDOSFSMNT, M_WAITOK|M_ZERO); pmp->pm_mountp = mp;
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mrg Date: Mon Sep 7 01:35:25 UTC 2020 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: avoid an uninit warning with GCC 9. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mrg Date: Mon Sep 7 01:35:25 UTC 2020 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: avoid an uninit warning with GCC 9. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_fat.c diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.34 src/sys/fs/msdosfs/msdosfs_fat.c:1.35 --- src/sys/fs/msdosfs/msdosfs_fat.c:1.34 Mon Sep 3 16:29:34 2018 +++ src/sys/fs/msdosfs/msdosfs_fat.c Mon Sep 7 01:35:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_fat.c,v 1.34 2018/09/03 16:29:34 riastradh Exp $ */ +/* $NetBSD: msdosfs_fat.c,v 1.35 2020/09/07 01:35:25 mrg Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -52,7 +52,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.34 2018/09/03 16:29:34 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.35 2020/09/07 01:35:25 mrg Exp $"); /* * kernel include files. @@ -895,6 +895,7 @@ freeclusterchain(struct msdosfsmount *pm u_long bn, bo, bsize, byteoffset; u_long readcn, lbn = -1; + bn = 0; /* XXXgcc */ while (cluster >= CLUST_FIRST && cluster <= pmp->pm_maxcluster) { byteoffset = FATOFS(pmp, cluster); fatblock(pmp, byteoffset, , , );
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: kamil Date: Wed Jul 25 22:07:59 UTC 2018 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: Avoid undefined behavior semantics in msdosfs_fat.c Do not change signedness bit with left shift. While there avoid signed integer overflow. Address both issues with using unsigned type. msdosfs_fat.c:512:42, left shift of 1 by 31 places cannot be represented in type 'int' msdosfs_fat.c:521:44, left shift of 1 by 31 places cannot be represented in type 'int' msdosfs_fat.c:744:14, left shift of 1 by 31 places cannot be represented in type 'int' msdosfs_fat.c:744:24, signed integer overflow: -2147483648 - 1 cannot be represented in type 'int [20]' msdosfs_fat.c:840:13, left shift of 1 by 31 places cannot be represented in type 'int' msdosfs_fat.c:840:36, signed integer overflow: -2147483648 - 1 cannot be represented in type 'int [20]' Detected with micro-UBSan in the user mode. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: kamil Date: Wed Jul 25 22:07:59 UTC 2018 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: Avoid undefined behavior semantics in msdosfs_fat.c Do not change signedness bit with left shift. While there avoid signed integer overflow. Address both issues with using unsigned type. msdosfs_fat.c:512:42, left shift of 1 by 31 places cannot be represented in type 'int' msdosfs_fat.c:521:44, left shift of 1 by 31 places cannot be represented in type 'int' msdosfs_fat.c:744:14, left shift of 1 by 31 places cannot be represented in type 'int' msdosfs_fat.c:744:24, signed integer overflow: -2147483648 - 1 cannot be represented in type 'int [20]' msdosfs_fat.c:840:13, left shift of 1 by 31 places cannot be represented in type 'int' msdosfs_fat.c:840:36, signed integer overflow: -2147483648 - 1 cannot be represented in type 'int [20]' Detected with micro-UBSan in the user mode. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_fat.c diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.32 src/sys/fs/msdosfs/msdosfs_fat.c:1.33 --- src/sys/fs/msdosfs/msdosfs_fat.c:1.32 Sat Jan 27 03:54:01 2018 +++ src/sys/fs/msdosfs/msdosfs_fat.c Wed Jul 25 22:07:59 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_fat.c,v 1.32 2018/01/27 03:54:01 sevan Exp $ */ +/* $NetBSD: msdosfs_fat.c,v 1.33 2018/07/25 22:07:59 kamil Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -52,7 +52,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.32 2018/01/27 03:54:01 sevan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.33 2018/07/25 22:07:59 kamil Exp $"); /* * kernel include files. @@ -409,7 +409,7 @@ updatefats(struct msdosfsmount *pmp, str if (pmp->pm_freeclustercount && (pmp->pm_inusemap[cn / N_INUSEBITS] - & (1 << (cn % N_INUSEBITS { + & (1U << (cn % N_INUSEBITS { /* * The cluster indicated in FSInfo isn't free * any longer. Got get a new free one. @@ -509,7 +509,7 @@ static inline void usemap_alloc(struct msdosfsmount *pmp, u_long cn) { - pmp->pm_inusemap[cn / N_INUSEBITS] |= 1 << (cn % N_INUSEBITS); + pmp->pm_inusemap[cn / N_INUSEBITS] |= 1U << (cn % N_INUSEBITS); pmp->pm_freeclustercount--; } @@ -518,7 +518,7 @@ usemap_free(struct msdosfsmount *pmp, u_ { pmp->pm_freeclustercount++; - pmp->pm_inusemap[cn / N_INUSEBITS] &= ~(1 << (cn % N_INUSEBITS)); + pmp->pm_inusemap[cn / N_INUSEBITS] &= ~(1U << (cn % N_INUSEBITS)); } int @@ -741,7 +741,7 @@ chainlength(struct msdosfsmount *pmp, u_ idx = start / N_INUSEBITS; start %= N_INUSEBITS; map = pmp->pm_inusemap[idx]; - map &= ~((1 << start) - 1); + map &= ~((1U << start) - 1); if (map) { len = ffs(map) - 1 - start; return (len > count ? count : len); @@ -837,7 +837,7 @@ clusteralloc(struct msdosfsmount *pmp, u for (cn = newst; cn <= pmp->pm_maxcluster;) { idx = cn / N_INUSEBITS; map = pmp->pm_inusemap[idx]; - map |= (1 << (cn % N_INUSEBITS)) - 1; + map |= (1U << (cn % N_INUSEBITS)) - 1; if (map != (u_int)-1) { cn = idx * N_INUSEBITS + ffs(map^(u_int)-1) - 1; if ((l = chainlength(pmp, cn, count)) >= count) @@ -854,7 +854,7 @@ clusteralloc(struct msdosfsmount *pmp, u for (cn = 0; cn < newst;) { idx = cn / N_INUSEBITS; map = pmp->pm_inusemap[idx]; - map |= (1 << (cn % N_INUSEBITS)) - 1; + map |= (1U << (cn % N_INUSEBITS)) - 1; if (map != (u_int)-1) { cn = idx * N_INUSEBITS + ffs(map^(u_int)-1) - 1; if ((l = chainlength(pmp, cn, count)) >= count)
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: sevan Date: Sat Jan 27 03:54:01 UTC 2018 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: Need strings.h for ffs() Resolves implict declaration warning of ffs() when building tools via build.sh To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_fat.c diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.31 src/sys/fs/msdosfs/msdosfs_fat.c:1.32 --- src/sys/fs/msdosfs/msdosfs_fat.c:1.31 Sat May 7 16:43:02 2016 +++ src/sys/fs/msdosfs/msdosfs_fat.c Sat Jan 27 03:54:01 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_fat.c,v 1.31 2016/05/07 16:43:02 mlelstv Exp $ */ +/* $NetBSD: msdosfs_fat.c,v 1.32 2018/01/27 03:54:01 sevan Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -52,7 +52,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.31 2016/05/07 16:43:02 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.32 2018/01/27 03:54:01 sevan Exp $"); /* * kernel include files. @@ -69,6 +69,7 @@ __KERNEL_RCSID(0, "$NetBSD: msdosfs_fat. #include #include /* to define vattr structure */ #else +#include #include #endif
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: sevan Date: Sat Jan 27 03:54:01 UTC 2018 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: Need strings.h for ffs() Resolves implict declaration warning of ffs() when building tools via build.sh To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mlelstv Date: Mon Nov 27 15:02:05 UTC 2017 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: relax sanity check. It's ok to have more FAT sectors than needed. To generate a diff of this commit: cvs rdiff -u -r1.128 -r1.129 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.128 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.129 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.128 Sun Aug 20 11:48:15 2017 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Mon Nov 27 15:02:05 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.128 2017/08/20 11:48:15 mlelstv Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.129 2017/11/27 15:02:05 mlelstv Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.128 2017/08/20 11:48:15 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.129 2017/11/27 15:02:05 mlelstv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -724,8 +724,8 @@ msdosfs_mountfs(struct vnode *devvp, str fatbytes = (pmp->pm_maxcluster+1) * pmp->pm_fatmult / pmp->pm_fatdiv; fatblocksecs = howmany(fatbytes, pmp->pm_BytesPerSec); - if (pmp->pm_FATsecs != fatblocksecs) { - DPRINTF("FATsecs %lu != real %lu\n", pmp->pm_FATsecs, + if (pmp->pm_FATsecs < fatblocksecs) { + DPRINTF("FATsecs %lu < real %lu\n", pmp->pm_FATsecs, fatblocksecs); error = EINVAL; goto error_exit;
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mlelstv Date: Mon Nov 27 15:02:05 UTC 2017 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: relax sanity check. It's ok to have more FAT sectors than needed. To generate a diff of this commit: cvs rdiff -u -r1.128 -r1.129 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mlelstv Date: Sun Aug 20 11:48:15 UTC 2017 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Add more sanity checks for BPB parameters. Handle FAT12 format for media with sectors >= 32kByte. Does fix PR 52485. To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.127 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.128 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.127 Mon Apr 17 08:32:00 2017 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Sun Aug 20 11:48:15 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.127 2017/04/17 08:32:00 hannken Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.128 2017/08/20 11:48:15 mlelstv Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.127 2017/04/17 08:32:00 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.128 2017/08/20 11:48:15 mlelstv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -467,6 +467,7 @@ msdosfs_mountfs(struct vnode *devvp, str int ronly, error, BlkPerSec; uint64_t psize; unsigned secsize; + u_long fatbytes, fatblocksecs; /* Flush out any old buffers remaining from a previous use. */ if ((error = vinvalbuf(devvp, V_SAVE, l->l_cred, l, 0, 0)) != 0) @@ -710,12 +711,40 @@ msdosfs_mountfs(struct vnode *devvp, str pmp->pm_fatdiv = 1; } } - if (FAT12(pmp)) - pmp->pm_fatblocksize = 3 * pmp->pm_BytesPerSec; - else + + /* validate cluster count against FAT */ + if ((pmp->pm_maxcluster & pmp->pm_fatmask) != pmp->pm_maxcluster) { + DPRINTF("maxcluster %lu outside of mask %#lx\n", + pmp->pm_maxcluster, pmp->pm_fatmask); + error = EINVAL; + goto error_exit; + } + + /* validate FAT size */ + fatbytes = (pmp->pm_maxcluster+1) * pmp->pm_fatmult / pmp->pm_fatdiv; + fatblocksecs = howmany(fatbytes, pmp->pm_BytesPerSec); + + if (pmp->pm_FATsecs != fatblocksecs) { + DPRINTF("FATsecs %lu != real %lu\n", pmp->pm_FATsecs, + fatblocksecs); + error = EINVAL; + goto error_exit; + } + + if (FAT12(pmp)) { + /* + * limit block size to what is needed to read a FAT block + * to not exceed MAXBSIZE + */ + pmp->pm_fatblocksec = min(3, fatblocksecs); + pmp->pm_fatblocksize = pmp->pm_fatblocksec + * pmp->pm_BytesPerSec; + } else { pmp->pm_fatblocksize = MAXBSIZE; + pmp->pm_fatblocksec = pmp->pm_fatblocksize + / pmp->pm_BytesPerSec; + } - pmp->pm_fatblocksec = pmp->pm_fatblocksize / pmp->pm_BytesPerSec; pmp->pm_bnshift = ffs(pmp->pm_BytesPerSec) - 1; /*
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mlelstv Date: Sun Aug 20 11:48:15 UTC 2017 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Add more sanity checks for BPB parameters. Handle FAT12 format for media with sectors >= 32kByte. Does fix PR 52485. To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Wed Mar 1 10:41:28 UTC 2017 Modified Files: src/sys/fs/msdosfs: msdosfs_denode.c msdosfs_vfsops.c msdosfs_vnops.c Log Message: Remove now redundant calls to fstrans_start()/fstrans_done(). To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/fs/msdosfs/msdosfs_denode.c cvs rdiff -u -r1.123 -r1.124 src/sys/fs/msdosfs/msdosfs_vfsops.c cvs rdiff -u -r1.96 -r1.97 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_denode.c diff -u src/sys/fs/msdosfs/msdosfs_denode.c:1.52 src/sys/fs/msdosfs/msdosfs_denode.c:1.53 --- src/sys/fs/msdosfs/msdosfs_denode.c:1.52 Sat Aug 20 12:37:07 2016 +++ src/sys/fs/msdosfs/msdosfs_denode.c Wed Mar 1 10:41:28 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_denode.c,v 1.52 2016/08/20 12:37:07 hannken Exp $ */ +/* $NetBSD: msdosfs_denode.c,v 1.53 2017/03/01 10:41:28 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,12 +48,11 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.52 2016/08/20 12:37:07 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.53 2017/03/01 10:41:28 hannken Exp $"); #include #include #include -#include #include #include #include @@ -537,10 +536,8 @@ msdosfs_reclaim(void *v) struct vnode *a_vp; } */ *ap = v; struct vnode *vp = ap->a_vp; - struct mount *mp = vp->v_mount; struct denode *dep = VTODE(vp); - fstrans_start(mp, FSTRANS_LAZY); #ifdef MSDOSFS_DEBUG printf("msdosfs_reclaim(): dep %p, file %s, refcnt %ld\n", dep, dep->de_Name, dep->de_refcnt); @@ -566,7 +563,6 @@ msdosfs_reclaim(void *v) vp->v_data = NULL; mutex_exit(vp->v_interlock); pool_put(_denode_pool, dep); - fstrans_done(mp); return (0); } @@ -578,7 +574,6 @@ msdosfs_inactive(void *v) bool *a_recycle; } */ *ap = v; struct vnode *vp = ap->a_vp; - struct mount *mp = vp->v_mount; struct denode *dep = VTODE(vp); int error = 0; @@ -586,7 +581,6 @@ msdosfs_inactive(void *v) printf("msdosfs_inactive(): dep %p, de_Name[0] %x\n", dep, dep->de_Name[0]); #endif - fstrans_start(mp, FSTRANS_LAZY); /* * Get rid of denodes related to stale file handles. */ @@ -623,7 +617,6 @@ out: #endif *ap->a_recycle = (dep->de_Name[0] == SLOT_DELETED); VOP_UNLOCK(vp); - fstrans_done(mp); return (error); } Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.123 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.124 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.123 Wed Feb 22 09:50:13 2017 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Wed Mar 1 10:41:28 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.123 2017/02/22 09:50:13 hannken Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.124 2017/03/01 10:41:28 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.123 2017/02/22 09:50:13 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.124 2017/03/01 10:41:28 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -69,7 +69,6 @@ __KERNEL_RCSID(0, "$NetBSD: msdosfs_vfso #include #include #include -#include #include #include #include @@ -1002,7 +1001,6 @@ msdosfs_sync(struct mount *mp, int waitf /* update FATs here */ } } - fstrans_start(mp, FSTRANS_SHARED); /* * Write back each (modified) denode. */ @@ -1031,7 +1029,6 @@ msdosfs_sync(struct mount *mp, int waitf waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0)) != 0) allerror = error; VOP_UNLOCK(pmp->pm_devvp); - fstrans_done(mp); return (allerror); } Index: src/sys/fs/msdosfs/msdosfs_vnops.c diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.96 src/sys/fs/msdosfs/msdosfs_vnops.c:1.97 --- src/sys/fs/msdosfs/msdosfs_vnops.c:1.96 Mon Feb 1 16:53:23 2016 +++ src/sys/fs/msdosfs/msdosfs_vnops.c Wed Mar 1 10:41:28 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vnops.c,v 1.96 2016/02/01 16:53:23 christos Exp $ */ +/* $NetBSD: msdosfs_vnops.c,v 1.97 2017/03/01 10:41:28 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.96 2016/02/01 16:53:23 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.97 2017/03/01 10:41:28 hannken Exp $"); #include #include @@ -60,7 +60,6 @@ __KERNEL_RCSID(0, "$NetBSD: msdosfs_vnop #include #include #include -#include #include #include #include @@ -120,7 +119,6 @@ msdosfs_create(void *v) printf("msdosfs_create(cnp %p, vap %p\n", cnp, ap->a_vap); #endif - fstrans_start(ap->a_dvp->v_mount, FSTRANS_SHARED); /* * If this is the root directory and there is no space left we * can't do anything. This is because the root directory can not @@
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Wed Mar 1 10:41:28 UTC 2017 Modified Files: src/sys/fs/msdosfs: msdosfs_denode.c msdosfs_vfsops.c msdosfs_vnops.c Log Message: Remove now redundant calls to fstrans_start()/fstrans_done(). To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/fs/msdosfs/msdosfs_denode.c cvs rdiff -u -r1.123 -r1.124 src/sys/fs/msdosfs/msdosfs_vfsops.c cvs rdiff -u -r1.96 -r1.97 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Fri Feb 17 08:27:20 UTC 2017 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Take vnode lock for VOP_FSYNC(). To generate a diff of this commit: cvs rdiff -u -r1.119 -r1.120 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.119 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.120 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.119 Wed Dec 14 15:48:54 2016 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Fri Feb 17 08:27:20 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.119 2016/12/14 15:48:54 hannken Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.120 2017/02/17 08:27:20 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.119 2016/12/14 15:48:54 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.120 2017/02/17 08:27:20 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -1032,9 +1032,11 @@ msdosfs_sync(struct mount *mp, int waitf /* * Force stale file system control information to be flushed. */ + vn_lock(pmp->pm_devvp, LK_EXCLUSIVE | LK_RETRY); if ((error = VOP_FSYNC(pmp->pm_devvp, cred, waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0)) != 0) allerror = error; + VOP_UNLOCK(pmp->pm_devvp); fstrans_done(mp); return (allerror); }
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Fri Feb 17 08:27:20 UTC 2017 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Take vnode lock for VOP_FSYNC(). To generate a diff of this commit: cvs rdiff -u -r1.119 -r1.120 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: maya Date: Sat Jan 14 17:17:53 UTC 2017 Modified Files: src/sys/fs/msdosfs: denode.h Log Message: Be explicit about how we're placing part of the on-disk name into the extension, so it doesn't appear like we are overrunning an array. Appeases coverity, NFC. ok riastradh To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/fs/msdosfs/denode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: maya Date: Sat Jan 14 17:17:53 UTC 2017 Modified Files: src/sys/fs/msdosfs: denode.h Log Message: Be explicit about how we're placing part of the on-disk name into the extension, so it doesn't appear like we are overrunning an array. Appeases coverity, NFC. ok riastradh To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/fs/msdosfs/denode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/denode.h diff -u src/sys/fs/msdosfs/denode.h:1.24 src/sys/fs/msdosfs/denode.h:1.25 --- src/sys/fs/msdosfs/denode.h:1.24 Tue Jul 8 09:21:52 2014 +++ src/sys/fs/msdosfs/denode.h Sat Jan 14 17:17:53 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: denode.h,v 1.24 2014/07/08 09:21:52 hannken Exp $ */ +/* $NetBSD: denode.h,v 1.25 2017/01/14 17:17:53 maya Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -212,7 +212,8 @@ struct denode { #define DE_INTERNALIZE32(dep, dp) \ ((dep)->de_StartCluster |= getushort((dp)->deHighClust) << 16) #define DE_INTERNALIZE(dep, dp)\ - (memcpy((dep)->de_Name, (dp)->deName, 11), \ + (memcpy((dep)->de_Name, (dp)->deName, 8), \ + memcpy((dep)->de_Name+8, (dp)->deExtension, 3),\ (dep)->de_Attributes = (dp)->deAttributes, \ (dep)->de_CHun = (dp)->deCHundredth, \ (dep)->de_CTime = getushort((dp)->deCTime), \ @@ -229,7 +230,8 @@ struct denode { #define DE_EXTERNALIZE16(dp, dep) \ putushort((dp)->deHighClust, 0) #define DE_EXTERNALIZE(dp, dep)\ - (memcpy((dp)->deName, (dep)->de_Name, 11), \ + (memcpy((dp)->deName, (dep)->de_Name, 8), \ + memcpy((dp)->deExtension, (dep)->de_Name+8, 3),\ (dp)->deAttributes = (dep)->de_Attributes, \ (dp)->deCHundredth = (dep)->de_CHun, \ putushort((dp)->deCTime, (dep)->de_CTime), \
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: nonaka Date: Thu Jun 30 09:34:01 UTC 2016 Modified Files: src/sys/fs/msdosfs: msdosfs_conv.c Log Message: Fix false positives when comparing long file names that have the same first 13 (or some multiple thereof) characters. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/fs/msdosfs/msdosfs_conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_conv.c diff -u src/sys/fs/msdosfs/msdosfs_conv.c:1.16 src/sys/fs/msdosfs/msdosfs_conv.c:1.17 --- src/sys/fs/msdosfs/msdosfs_conv.c:1.16 Sun Mar 6 07:33:25 2016 +++ src/sys/fs/msdosfs/msdosfs_conv.c Thu Jun 30 09:34:01 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_conv.c,v 1.16 2016/03/06 07:33:25 mlelstv Exp $ */ +/* $NetBSD: msdosfs_conv.c,v 1.17 2016/06/30 09:34:01 nonaka Exp $ */ /*- * Copyright (C) 1995, 1997 Wolfgang Solfrank. @@ -58,7 +58,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.16 2016/03/06 07:33:25 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.17 2016/06/30 09:34:01 nonaka Exp $"); /* * System include files. @@ -621,6 +621,8 @@ winChkName(const u_char *un, int unlen, if (i >= len + 1) return -1; + if ((wep->weCnt & WIN_LAST) && (len - i > WIN_CHARS)) + return -1; /* * Fetch name segment from directory entry
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: nonaka Date: Thu Jun 30 09:34:01 UTC 2016 Modified Files: src/sys/fs/msdosfs: msdosfs_conv.c Log Message: Fix false positives when comparing long file names that have the same first 13 (or some multiple thereof) characters. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/fs/msdosfs/msdosfs_conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mlelstv Date: Sat May 7 16:43:02 UTC 2016 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: fix DEBUG build To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_fat.c diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.30 src/sys/fs/msdosfs/msdosfs_fat.c:1.31 --- src/sys/fs/msdosfs/msdosfs_fat.c:1.30 Tue May 3 18:17:28 2016 +++ src/sys/fs/msdosfs/msdosfs_fat.c Sat May 7 16:43:02 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_fat.c,v 1.30 2016/05/03 18:17:28 mlelstv Exp $ */ +/* $NetBSD: msdosfs_fat.c,v 1.31 2016/05/07 16:43:02 mlelstv Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -52,7 +52,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.30 2016/05/03 18:17:28 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.31 2016/05/07 16:43:02 mlelstv Exp $"); /* * kernel include files. @@ -279,7 +279,7 @@ pcbmap(struct denode *dep, u_long findcn */ if (cn < CLUST_FIRST || cn > pmp->pm_maxcluster) { DPRINTF(("%s(cn, %lu not in %lu..%lu)\n", __func__, -cn, CLUST_FIRST, pmp->pm_maxcluster)); +cn, (u_long)CLUST_FIRST, pmp->pm_maxcluster)); if (bp) brelse(bp, 0); return (EINVAL);
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mlelstv Date: Sat May 7 16:43:02 UTC 2016 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: fix DEBUG build To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mlelstv Date: Tue May 3 18:17:29 UTC 2016 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: Validate FAT entries to avoid some panics caused by a corrupted FAT. Also print FAT write errors when mount is synchronous (-o sync). This reveals problems caused by a write protected disklabel on sector 1. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_fat.c diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.29 src/sys/fs/msdosfs/msdosfs_fat.c:1.30 --- src/sys/fs/msdosfs/msdosfs_fat.c:1.29 Sat Mar 28 19:24:05 2015 +++ src/sys/fs/msdosfs/msdosfs_fat.c Tue May 3 18:17:28 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_fat.c,v 1.29 2015/03/28 19:24:05 maxv Exp $ */ +/* $NetBSD: msdosfs_fat.c,v 1.30 2016/05/03 18:17:28 mlelstv Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -52,7 +52,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.29 2015/03/28 19:24:05 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.30 2016/05/03 18:17:28 mlelstv Exp $"); /* * kernel include files. @@ -273,6 +273,18 @@ pcbmap(struct denode *dep, u_long findcn */ if (cn >= (CLUST_RSRVD & pmp->pm_fatmask)) goto hiteof; + + /* + * Also stop when cluster is not in the filesystem + */ + if (cn < CLUST_FIRST || cn > pmp->pm_maxcluster) { + DPRINTF(("%s(cn, %lu not in %lu..%lu)\n", __func__, +cn, CLUST_FIRST, pmp->pm_maxcluster)); + if (bp) +brelse(bp, 0); + return (EINVAL); + } + byteoffset = FATOFS(pmp, cn); fatblock(pmp, byteoffset, , , ); if (bn != bp_bn) { @@ -383,7 +395,7 @@ fc_purge(struct denode *dep, u_int frcn) void updatefats(struct msdosfsmount *pmp, struct buf *bp, u_long fatbn) { - int i; + int i, error; struct buf *bpn; DPRINTF(("%s(pmp %p, bp %p, fatbn %lu)\n", __func__, pmp, bp, fatbn)); @@ -448,9 +460,12 @@ updatefats(struct msdosfsmount *pmp, str bpn = getblk(pmp->pm_devvp, de_bn2kb(pmp, fatbn), bp->b_bcount, 0, 0); memcpy(bpn->b_data, bp->b_data, bp->b_bcount); - if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT) -bwrite(bpn); - else + if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT) { +error = bwrite(bpn); +if (error) + printf("%s: copy FAT %d (error=%d)\n", + __func__, i, error); + } else bdwrite(bpn); } } @@ -458,9 +473,12 @@ updatefats(struct msdosfsmount *pmp, str /* * Write out the first (or current) FAT last. */ - if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT) - bwrite(bp); - else + if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT) { + error = bwrite(bp); + if (error) + printf("%s: write FAT (error=%d)\n", +__func__, error); + } else bdwrite(bp); /* * Maybe update fsinfo sector here?
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mlelstv Date: Tue May 3 18:17:29 UTC 2016 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: Validate FAT entries to avoid some panics caused by a corrupted FAT. Also print FAT write errors when mount is synchronous (-o sync). This reveals problems caused by a write protected disklabel on sector 1. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mlelstv Date: Sun Mar 6 07:33:25 UTC 2016 Modified Files: src/sys/fs/msdosfs: msdosfs_conv.c Log Message: Use KASSERT for conditions that cannot be met with current parameters. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/fs/msdosfs/msdosfs_conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mlelstv Date: Sun Mar 6 07:33:25 UTC 2016 Modified Files: src/sys/fs/msdosfs: msdosfs_conv.c Log Message: Use KASSERT for conditions that cannot be met with current parameters. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/fs/msdosfs/msdosfs_conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_conv.c diff -u src/sys/fs/msdosfs/msdosfs_conv.c:1.15 src/sys/fs/msdosfs/msdosfs_conv.c:1.16 --- src/sys/fs/msdosfs/msdosfs_conv.c:1.15 Sat Feb 6 10:40:58 2016 +++ src/sys/fs/msdosfs/msdosfs_conv.c Sun Mar 6 07:33:25 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_conv.c,v 1.15 2016/02/06 10:40:58 mlelstv Exp $ */ +/* $NetBSD: msdosfs_conv.c,v 1.16 2016/03/06 07:33:25 mlelstv Exp $ */ /*- * Copyright (C) 1995, 1997 Wolfgang Solfrank. @@ -52,8 +52,13 @@ #include "nbtool_config.h" #endif +#ifndef _KERNEL +#include +#define KASSERT(x) assert(x) +#endif + #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.15 2016/02/06 10:40:58 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.16 2016/03/06 07:33:25 mlelstv Exp $"); /* * System include files. @@ -685,8 +690,8 @@ win2unixfn(struct winentry *wep, struct len = utf8 ? ucs2utf8str(wn, WIN_CHARS, buf, sizeof(buf)) : ucs2char8str(wn, WIN_CHARS, buf, sizeof(buf)); - if ((size_t)len > sizeof(dp->d_name) - 1) - return -1; + KASSERT(len >= 0); + KASSERT((size_t)len <= MIN(sizeof(buf), sizeof(dp->d_name)-1)); /* * Prepend name segment to directory entry @@ -702,6 +707,9 @@ win2unixfn(struct winentry *wep, struct *namlen += len; if (*namlen > sizeof(dp->d_name) - 1) *namlen = sizeof(dp->d_name) - 1; + + KASSERT(*namlen >= len); + memmove(>d_name[len], >d_name[0], *namlen - len); memcpy(dp->d_name, buf, len);
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: joerg Date: Sat Feb 6 14:11:58 UTC 2016 Modified Files: src/sys/fs/msdosfs: msdosfs_unicode.c Log Message: Toolify. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/fs/msdosfs/msdosfs_unicode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_unicode.c diff -u src/sys/fs/msdosfs/msdosfs_unicode.c:1.1 src/sys/fs/msdosfs/msdosfs_unicode.c:1.2 --- src/sys/fs/msdosfs/msdosfs_unicode.c:1.1 Sat Feb 6 10:40:58 2016 +++ src/sys/fs/msdosfs/msdosfs_unicode.c Sat Feb 6 14:11:58 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_unicode.c,v 1.1 2016/02/06 10:40:58 mlelstv Exp $ */ +/* $NetBSD: msdosfs_unicode.c,v 1.2 2016/02/06 14:11:58 joerg Exp $ */ /* * Unicode 5.0 case folding derived from @@ -52,6 +52,10 @@ * */ +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include #include
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: joerg Date: Sat Feb 6 14:11:58 UTC 2016 Modified Files: src/sys/fs/msdosfs: msdosfs_unicode.c Log Message: Toolify. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/fs/msdosfs/msdosfs_unicode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: martin Date: Mon Feb 1 10:37:57 UTC 2016 Modified Files: src/sys/fs/msdosfs: msdosfs_conv.c Log Message: Avoid unsigned/signed comparision warning to fix the build. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/fs/msdosfs/msdosfs_conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_conv.c diff -u src/sys/fs/msdosfs/msdosfs_conv.c:1.12 src/sys/fs/msdosfs/msdosfs_conv.c:1.13 --- src/sys/fs/msdosfs/msdosfs_conv.c:1.12 Mon Feb 1 02:59:33 2016 +++ src/sys/fs/msdosfs/msdosfs_conv.c Mon Feb 1 10:37:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_conv.c,v 1.12 2016/02/01 02:59:33 christos Exp $ */ +/* $NetBSD: msdosfs_conv.c,v 1.13 2016/02/01 10:37:57 martin Exp $ */ /*- * Copyright (C) 1995, 1997 Wolfgang Solfrank. @@ -62,7 +62,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.12 2016/02/01 02:59:33 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.13 2016/02/01 10:37:57 martin Exp $"); /* * System include files. @@ -1592,7 +1592,7 @@ win2unixfn(struct winentry *wep, struct */ len = utf8 ? ucs2utf8str(wn, WIN_CHARS, buf, sizeof(buf)) : ucs2char8str(wn, WIN_CHARS, buf, sizeof(buf)); - if (len > sizeof(dp->d_name) - 1) + if (len < 0 || (size_t)len > sizeof(dp->d_name) - 1) return -1; /*
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: martin Date: Mon Feb 1 10:37:57 UTC 2016 Modified Files: src/sys/fs/msdosfs: msdosfs_conv.c Log Message: Avoid unsigned/signed comparision warning to fix the build. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/fs/msdosfs/msdosfs_conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Mon Feb 1 16:53:24 UTC 2016 Modified Files: src/sys/fs/msdosfs: msdosfs_conv.c msdosfs_vnops.c Log Message: - split a long line. - remove extra test. - move d_namlen setting to msdosfs_vnops.c to avoid the ifdef. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/fs/msdosfs/msdosfs_conv.c cvs rdiff -u -r1.95 -r1.96 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_conv.c diff -u src/sys/fs/msdosfs/msdosfs_conv.c:1.13 src/sys/fs/msdosfs/msdosfs_conv.c:1.14 --- src/sys/fs/msdosfs/msdosfs_conv.c:1.13 Mon Feb 1 05:37:57 2016 +++ src/sys/fs/msdosfs/msdosfs_conv.c Mon Feb 1 11:53:23 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_conv.c,v 1.13 2016/02/01 10:37:57 martin Exp $ */ +/* $NetBSD: msdosfs_conv.c,v 1.14 2016/02/01 16:53:23 christos Exp $ */ /*- * Copyright (C) 1995, 1997 Wolfgang Solfrank. @@ -62,7 +62,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.13 2016/02/01 10:37:57 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.14 2016/02/01 16:53:23 christos Exp $"); /* * System include files. @@ -1590,9 +1590,10 @@ win2unixfn(struct winentry *wep, struct /* * Translate ucs-2 to UNIX name */ - len = utf8 ? ucs2utf8str(wn, WIN_CHARS, buf, sizeof(buf)) : ucs2char8str(wn, WIN_CHARS, buf, sizeof(buf)); + len = utf8 ? ucs2utf8str(wn, WIN_CHARS, buf, sizeof(buf)) + : ucs2char8str(wn, WIN_CHARS, buf, sizeof(buf)); - if (len < 0 || (size_t)len > sizeof(dp->d_name) - 1) + if ((size_t)len > sizeof(dp->d_name) - 1) return -1; /* @@ -1612,10 +1613,6 @@ win2unixfn(struct winentry *wep, struct memmove(>d_name[len], >d_name[0], *namlen - len); memcpy(dp->d_name, buf, len); -#ifdef __NetBSD__ - dp->d_namlen = *namlen; -#endif - return chksum; } Index: src/sys/fs/msdosfs/msdosfs_vnops.c diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.95 src/sys/fs/msdosfs/msdosfs_vnops.c:1.96 --- src/sys/fs/msdosfs/msdosfs_vnops.c:1.95 Sun Jan 31 21:59:33 2016 +++ src/sys/fs/msdosfs/msdosfs_vnops.c Mon Feb 1 11:53:23 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vnops.c,v 1.95 2016/02/01 02:59:33 christos Exp $ */ +/* $NetBSD: msdosfs_vnops.c,v 1.96 2016/02/01 16:53:23 christos Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.95 2016/02/01 02:59:33 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.96 2016/02/01 16:53:23 christos Exp $"); #include #include @@ -1544,6 +1544,8 @@ msdosfs_readdir(void *v) chksum = win2unixfn((struct winentry *)dentp, dirbuf, chksum, , pmp->pm_flags & MSDOSFSMNT_UTF8); +if (chksum != -1) + dirbuf->d_namlen = namlen; continue; }
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Mon Feb 1 16:53:24 UTC 2016 Modified Files: src/sys/fs/msdosfs: msdosfs_conv.c msdosfs_vnops.c Log Message: - split a long line. - remove extra test. - move d_namlen setting to msdosfs_vnops.c to avoid the ifdef. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/fs/msdosfs/msdosfs_conv.c cvs rdiff -u -r1.95 -r1.96 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Mon Feb 1 02:59:33 UTC 2016 Modified Files: src/sys/fs/msdosfs: direntry.h msdosfs_conv.c msdosfs_vnops.c Log Message: We can't depend on dp->d_namlen existing for the parts that are used in makefs(8). To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/fs/msdosfs/direntry.h cvs rdiff -u -r1.11 -r1.12 src/sys/fs/msdosfs/msdosfs_conv.c cvs rdiff -u -r1.94 -r1.95 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/direntry.h diff -u src/sys/fs/msdosfs/direntry.h:1.10 src/sys/fs/msdosfs/direntry.h:1.11 --- src/sys/fs/msdosfs/direntry.h:1.10 Sat Jan 30 04:59:27 2016 +++ src/sys/fs/msdosfs/direntry.h Sun Jan 31 21:59:33 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: direntry.h,v 1.10 2016/01/30 09:59:27 mlelstv Exp $ */ +/* $NetBSD: direntry.h,v 1.11 2016/02/01 02:59:33 christos Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -140,7 +140,7 @@ int unix2winfn(const unsigned char *un, int winChkName(const unsigned char *un, int unlen, struct winentry *wep, int chksum, int utf8); int win2unixfn(struct winentry *wep, struct dirent *dp, int chksum, - int utf8); + uint16_t *namlen, int utf8); uint8_t winChksum(uint8_t *name); int winSlotCnt(const unsigned char *un, int unlen, int utf8); #endif /* _KERNEL || MAKEFS */ Index: src/sys/fs/msdosfs/msdosfs_conv.c diff -u src/sys/fs/msdosfs/msdosfs_conv.c:1.11 src/sys/fs/msdosfs/msdosfs_conv.c:1.12 --- src/sys/fs/msdosfs/msdosfs_conv.c:1.11 Sat Jan 30 04:59:27 2016 +++ src/sys/fs/msdosfs/msdosfs_conv.c Sun Jan 31 21:59:33 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_conv.c,v 1.11 2016/01/30 09:59:27 mlelstv Exp $ */ +/* $NetBSD: msdosfs_conv.c,v 1.12 2016/02/01 02:59:33 christos Exp $ */ /*- * Copyright (C) 1995, 1997 Wolfgang Solfrank. @@ -62,7 +62,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.11 2016/01/30 09:59:27 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.12 2016/02/01 02:59:33 christos Exp $"); /* * System include files. @@ -1549,7 +1549,8 @@ winChkName(const u_char *un, int unlen, * Returns the checksum or -1 if impossible */ int -win2unixfn(struct winentry *wep, struct dirent *dp, int chksum, int utf8) +win2unixfn(struct winentry *wep, struct dirent *dp, int chksum, +uint16_t *namlen, int utf8) { u_int16_t wn[WIN_CHARS], *p; u_int8_t buf[WIN_CHARS*3]; @@ -1564,7 +1565,7 @@ win2unixfn(struct winentry *wep, struct */ if (wep->weCnt & WIN_LAST) { chksum = wep->weChksum; - dp->d_namlen = 0; + *namlen = 0; } else if (chksum != wep->weChksum) chksum = -1; if (chksum == -1) @@ -1591,6 +1592,9 @@ win2unixfn(struct winentry *wep, struct */ len = utf8 ? ucs2utf8str(wn, WIN_CHARS, buf, sizeof(buf)) : ucs2char8str(wn, WIN_CHARS, buf, sizeof(buf)); + if (len > sizeof(dp->d_name) - 1) + return -1; + /* * Prepend name segment to directory entry * @@ -1602,12 +1606,16 @@ win2unixfn(struct winentry *wep, struct * are silently discarded. This could also end in multiple * files using the same (truncated) name. */ - dp->d_namlen += len; - if (dp->d_namlen > sizeof(dp->d_name)-1) - dp->d_namlen = sizeof(dp->d_name)-1; - memmove(>d_name[len], >d_name[0], dp->d_namlen - len); + *namlen += len; + if (*namlen > sizeof(dp->d_name) - 1) + *namlen = sizeof(dp->d_name) - 1; + memmove(>d_name[len], >d_name[0], *namlen - len); memcpy(dp->d_name, buf, len); +#ifdef __NetBSD__ + dp->d_namlen = *namlen; +#endif + return chksum; } Index: src/sys/fs/msdosfs/msdosfs_vnops.c diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.94 src/sys/fs/msdosfs/msdosfs_vnops.c:1.95 --- src/sys/fs/msdosfs/msdosfs_vnops.c:1.94 Sat Jan 30 04:59:27 2016 +++ src/sys/fs/msdosfs/msdosfs_vnops.c Sun Jan 31 21:59:33 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vnops.c,v 1.94 2016/01/30 09:59:27 mlelstv Exp $ */ +/* $NetBSD: msdosfs_vnops.c,v 1.95 2016/02/01 02:59:33 christos Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.94 2016/01/30 09:59:27 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.95 2016/02/01 02:59:33 christos Exp $"); #include #include @@ -1394,6 +1394,7 @@ msdosfs_readdir(void *v) int ncookies = 0, nc = 0; off_t offset, uio_off; int chksum = -1; + uint16_t namlen; #ifdef MSDOSFS_DEBUG printf("msdosfs_readdir(): vp %p, uio %p, cred %p, eofflagp %p\n", @@ -1541,7 +1542,8 @@ msdosfs_readdir(void *v) if (pmp->pm_flags & MSDOSFSMNT_SHORTNAME) continue; chksum = win2unixfn((struct winentry *)dentp, -dirbuf, chksum, pmp->pm_flags & MSDOSFSMNT_UTF8); +dirbuf, chksum, , +pmp->pm_flags & MSDOSFSMNT_UTF8); continue; } @@ -1584,6 +1586,7 @@
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Mon Feb 1 02:59:33 UTC 2016 Modified Files: src/sys/fs/msdosfs: direntry.h msdosfs_conv.c msdosfs_vnops.c Log Message: We can't depend on dp->d_namlen existing for the parts that are used in makefs(8). To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/fs/msdosfs/direntry.h cvs rdiff -u -r1.11 -r1.12 src/sys/fs/msdosfs/msdosfs_conv.c cvs rdiff -u -r1.94 -r1.95 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: dholland Date: Fri Jan 22 22:53:36 UTC 2016 Modified Files: src/sys/fs/msdosfs: bpb.h direntry.h Log Message: u_int{8,16,32}_t -> uint{8,16,32}_t, also u_int -> unsigned and u_char -> unsigned char. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/fs/msdosfs/bpb.h \ src/sys/fs/msdosfs/direntry.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/bpb.h diff -u src/sys/fs/msdosfs/bpb.h:1.7 src/sys/fs/msdosfs/bpb.h:1.8 --- src/sys/fs/msdosfs/bpb.h:1.7 Sun Nov 4 17:57:59 2012 +++ src/sys/fs/msdosfs/bpb.h Fri Jan 22 22:53:36 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: bpb.h,v 1.7 2012/11/04 17:57:59 jakllsch Exp $ */ +/* $NetBSD: bpb.h,v 1.8 2016/01/22 22:53:36 dholland Exp $ */ /* * Written by Paul Popelka (pa...@uts.amdahl.com) @@ -23,17 +23,17 @@ * BIOS Parameter Block (BPB) for DOS 3.3 */ struct bpb33 { - u_int16_t bpbBytesPerSec; /* bytes per sector */ - u_int8_t bpbSecPerClust; /* sectors per cluster */ - u_int16_t bpbResSectors; /* number of reserved sectors */ - u_int8_t bpbFATs; /* number of FATs */ - u_int16_t bpbRootDirEnts; /* number of root directory entries */ - u_int16_t bpbSectors; /* total number of sectors */ - u_int8_t bpbMedia; /* media descriptor */ - u_int16_t bpbFATsecs; /* number of sectors per FAT */ - u_int16_t bpbSecPerTrack; /* sectors per track */ - u_int16_t bpbHeads; /* number of heads */ - u_int16_t bpbHiddenSecs; /* number of hidden sectors */ + uint16_t bpbBytesPerSec; /* bytes per sector */ + uint8_t bpbSecPerClust; /* sectors per cluster */ + uint16_t bpbResSectors; /* number of reserved sectors */ + uint8_t bpbFATs; /* number of FATs */ + uint16_t bpbRootDirEnts; /* number of root directory entries */ + uint16_t bpbSectors; /* total number of sectors */ + uint8_t bpbMedia; /* media descriptor */ + uint16_t bpbFATsecs; /* number of sectors per FAT */ + uint16_t bpbSecPerTrack; /* sectors per track */ + uint16_t bpbHeads; /* number of heads */ + uint16_t bpbHiddenSecs; /* number of hidden sectors */ }; /* @@ -41,46 +41,46 @@ struct bpb33 { * and bpbHugeSectors is not in the 3.3 bpb. */ struct bpb50 { - u_int16_t bpbBytesPerSec; /* bytes per sector */ - u_int8_t bpbSecPerClust; /* sectors per cluster */ - u_int16_t bpbResSectors; /* number of reserved sectors */ - u_int8_t bpbFATs; /* number of FATs */ - u_int16_t bpbRootDirEnts; /* number of root directory entries */ - u_int16_t bpbSectors; /* total number of sectors */ - u_int8_t bpbMedia; /* media descriptor */ - u_int16_t bpbFATsecs; /* number of sectors per FAT */ - u_int16_t bpbSecPerTrack; /* sectors per track */ - u_int16_t bpbHeads; /* number of heads */ - u_int32_t bpbHiddenSecs; /* # of hidden sectors */ - u_int32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */ + uint16_t bpbBytesPerSec; /* bytes per sector */ + uint8_t bpbSecPerClust; /* sectors per cluster */ + uint16_t bpbResSectors; /* number of reserved sectors */ + uint8_t bpbFATs; /* number of FATs */ + uint16_t bpbRootDirEnts; /* number of root directory entries */ + uint16_t bpbSectors; /* total number of sectors */ + uint8_t bpbMedia; /* media descriptor */ + uint16_t bpbFATsecs; /* number of sectors per FAT */ + uint16_t bpbSecPerTrack; /* sectors per track */ + uint16_t bpbHeads; /* number of heads */ + uint32_t bpbHiddenSecs; /* # of hidden sectors */ + uint32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */ }; /* * BPB for DOS 7.10 (FAT32). This one has a few extensions to bpb50. */ struct bpb710 { - u_int16_t bpbBytesPerSec; /* bytes per sector */ - u_int8_t bpbSecPerClust; /* sectors per cluster */ - u_int16_t bpbResSectors; /* number of reserved sectors */ - u_int8_t bpbFATs; /* number of FATs */ - u_int16_t bpbRootDirEnts; /* number of root directory entries */ - u_int16_t bpbSectors; /* total number of sectors */ - u_int8_t bpbMedia; /* media descriptor */ - u_int16_t bpbFATsecs; /* number of sectors per FAT */ - u_int16_t bpbSecPerTrack; /* sectors per track */ - u_int16_t bpbHeads; /* number of heads */ - u_int32_t bpbHiddenSecs; /* # of hidden sectors */ - u_int32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */ - u_int32_t bpbBigFATsecs; /* like bpbFATsecs for FAT32 */ - u_int16_t bpbExtFlags; /* extended flags: */ + uint16_t bpbBytesPerSec; /* bytes per sector */ + uint8_t bpbSecPerClust; /* sectors per cluster */ + uint16_t bpbResSectors; /* number of reserved sectors */ + uint8_t bpbFATs; /* number of FATs */ + uint16_t bpbRootDirEnts; /* number of root directory entries */ + uint16_t bpbSectors; /* total number of sectors */ + uint8_t bpbMedia; /* media descriptor */ + uint16_t bpbFATsecs; /* number of sectors per FAT */ + uint16_t bpbSecPerTrack; /* sectors per track */ + uint16_t bpbHeads; /* number of heads */ + uint32_t bpbHiddenSecs; /* # of hidden sectors */ + uint32_t bpbHugeSectors; /* # of sectors
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: dholland Date: Fri Jan 22 22:53:36 UTC 2016 Modified Files: src/sys/fs/msdosfs: bpb.h direntry.h Log Message: u_int{8,16,32}_t -> uint{8,16,32}_t, also u_int -> unsigned and u_char -> unsigned char. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/fs/msdosfs/bpb.h \ src/sys/fs/msdosfs/direntry.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: dholland Date: Fri Jan 22 22:48:18 UTC 2016 Modified Files: src/sys/fs/msdosfs: bootsect.h Log Message: u_int8_t -> uint8_t To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/fs/msdosfs/bootsect.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/bootsect.h diff -u src/sys/fs/msdosfs/bootsect.h:1.5 src/sys/fs/msdosfs/bootsect.h:1.6 --- src/sys/fs/msdosfs/bootsect.h:1.5 Sun Nov 4 17:57:59 2012 +++ src/sys/fs/msdosfs/bootsect.h Fri Jan 22 22:48:18 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: bootsect.h,v 1.5 2012/11/04 17:57:59 jakllsch Exp $ */ +/* $NetBSD: bootsect.h,v 1.6 2016/01/22 22:48:18 dholland Exp $ */ /* * Written by Paul Popelka (pa...@uts.amdahl.com) @@ -24,13 +24,13 @@ * first sector of a partitioned hard disk. */ struct bootsector33 { - u_int8_t bsJump[3]; /* jump inst E9 or EBxx90 */ + uint8_t bsJump[3]; /* jump inst E9 or EBxx90 */ int8_t bsOemName[8]; /* OEM name and version */ int8_t bsBPB[19]; /* BIOS parameter block */ int8_t bsDriveNumber; /* drive number (0x80) */ int8_t bsBootCode[479]; /* pad so struct is 512b */ - u_int8_t bsBootSectSig0; - u_int8_t bsBootSectSig1; + uint8_t bsBootSectSig0; + uint8_t bsBootSectSig1; #define BOOTSIG0 0x55 #define BOOTSIG1 0xaa }; @@ -46,25 +46,25 @@ struct extboot { }; struct bootsector50 { - u_int8_t bsJump[3]; /* jump inst E9 or EBxx90 */ + uint8_t bsJump[3]; /* jump inst E9 or EBxx90 */ int8_t bsOemName[8]; /* OEM name and version */ int8_t bsBPB[25]; /* BIOS parameter block */ int8_t bsExt[26]; /* Bootsector Extension */ int8_t bsBootCode[448]; /* pad so structure is 512b */ - u_int8_t bsBootSectSig0; - u_int8_t bsBootSectSig1; + uint8_t bsBootSectSig0; + uint8_t bsBootSectSig1; #define BOOTSIG0 0x55 #define BOOTSIG1 0xaa }; struct bootsector710 { - u_int8_t bsJump[3]; /* jump inst E9 or EBxx90 */ + uint8_t bsJump[3]; /* jump inst E9 or EBxx90 */ int8_t bsOEMName[8]; /* OEM name and version */ int8_t bsBPB[53]; /* BIOS parameter block */ int8_t bsExt[26]; /* Bootsector Extension */ int8_t bsBootCode[420]; /* pad so structure is 512b */ - u_int8_t bsBootSectSig0; - u_int8_t bsBootSectSig1; + uint8_t bsBootSectSig0; + uint8_t bsBootSectSig1; #define BOOTSIG0 0x55 #define BOOTSIG1 0xaa }; @@ -76,7 +76,7 @@ struct bootsector710 { */ #if 0 struct bootsec_atari { - u_int8_t bsBranch[2]; /* branch inst if auto-boot */ + uint8_t bsBranch[2]; /* branch inst if auto-boot */ int8_t bsFiller[6]; /* anything or nothing */ int8_t bsSerial[3]; /* serial no. for mediachange */ int8_t bsBPB[19]; /* BIOS parameter block */
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: dholland Date: Fri Jan 22 22:48:18 UTC 2016 Modified Files: src/sys/fs/msdosfs: bootsect.h Log Message: u_int8_t -> uint8_t To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/fs/msdosfs/bootsect.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Fri Jan 23 02:39:48 UTC 2015 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: add some more paranoid checks about secsize and struct use. To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.115 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.116 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.115 Fri Jul 18 13:24:34 2014 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Thu Jan 22 21:39:48 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.115 2014/07/18 17:24:34 maxv Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.116 2015/01/23 02:39:48 christos Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.115 2014/07/18 17:24:34 maxv Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.116 2015/01/23 02:39:48 christos Exp $); #if defined(_KERNEL_OPT) #include opt_compat_netbsd.h @@ -510,6 +510,11 @@ msdosfs_mountfs(struct vnode *devvp, str * Read the boot sector of the filesystem, and then check the * boot signature. If not a dos boot sector then error out. */ + if (secsize sizeof(*b50)) { + DPRINTF((50 bootsec %u\n, secsize)); + error = EINVAL; + goto error_exit; + } if ((error = bread(devvp, 0, secsize, NOCRED, 0, bp)) != 0) goto error_exit; bsp = (union bootsector *)bp-b_data; @@ -551,6 +556,11 @@ msdosfs_mountfs(struct vnode *devvp, str pmp-pm_HiddenSects = getulong(b50-bpbHiddenSecs); pmp-pm_HugeSectors = getulong(b50-bpbHugeSectors); } else { + if (secsize sizeof(*b33)) { + DPRINTF((33 bootsec %u\n, secsize)); + error = EINVAL; + goto error_exit; + } pmp-pm_HiddenSects = getushort(b33-bpbHiddenSecs); pmp-pm_HugeSectors = pmp-pm_Sectors; } @@ -579,6 +589,11 @@ msdosfs_mountfs(struct vnode *devvp, str } if (pmp-pm_RootDirEnts == 0) { + if (secsize sizeof(*b710)) { + DPRINTF((710 bootsec %u\n, secsize)); + error = EINVAL; + goto error_exit; + } unsigned short FSVers = getushort(b710-bpbFSVers); unsigned short ExtFlags = getushort(b710-bpbExtFlags); /* @@ -650,6 +665,11 @@ msdosfs_mountfs(struct vnode *devvp, str pmp-pm_fatblk = pmp-pm_ResSectors; if (FAT32(pmp)) { + if (secsize sizeof(*b710)) { + DPRINTF((710 bootsec %u\n, secsize)); + error = EINVAL; + goto error_exit; + } pmp-pm_rootdirblk = getulong(b710-bpbRootClust); pmp-pm_firstcluster = pmp-pm_fatblk + (pmp-pm_FATs * pmp-pm_FATsecs);
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Fri Jan 23 02:39:48 UTC 2015 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: add some more paranoid checks about secsize and struct use. To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Fri Jan 23 03:33:58 UTC 2015 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: catch up with DPRINTF change To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Fri Jan 23 03:33:58 UTC 2015 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: catch up with DPRINTF change To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.116 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.117 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.116 Thu Jan 22 21:39:48 2015 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Thu Jan 22 22:33:58 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.116 2015/01/23 02:39:48 christos Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.117 2015/01/23 03:33:58 christos Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.116 2015/01/23 02:39:48 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.117 2015/01/23 03:33:58 christos Exp $); #if defined(_KERNEL_OPT) #include opt_compat_netbsd.h @@ -511,7 +511,7 @@ msdosfs_mountfs(struct vnode *devvp, str * boot signature. If not a dos boot sector then error out. */ if (secsize sizeof(*b50)) { - DPRINTF((50 bootsec %u\n, secsize)); + DPRINTF(50 bootsec %u\n, secsize); error = EINVAL; goto error_exit; } @@ -557,7 +557,7 @@ msdosfs_mountfs(struct vnode *devvp, str pmp-pm_HugeSectors = getulong(b50-bpbHugeSectors); } else { if (secsize sizeof(*b33)) { - DPRINTF((33 bootsec %u\n, secsize)); + DPRINTF(33 bootsec %u\n, secsize); error = EINVAL; goto error_exit; } @@ -590,7 +590,7 @@ msdosfs_mountfs(struct vnode *devvp, str if (pmp-pm_RootDirEnts == 0) { if (secsize sizeof(*b710)) { - DPRINTF((710 bootsec %u\n, secsize)); + DPRINTF(710 bootsec %u\n, secsize); error = EINVAL; goto error_exit; } @@ -666,7 +666,7 @@ msdosfs_mountfs(struct vnode *devvp, str pmp-pm_fatblk = pmp-pm_ResSectors; if (FAT32(pmp)) { if (secsize sizeof(*b710)) { - DPRINTF((710 bootsec %u\n, secsize)); + DPRINTF(710 bootsec %u\n, secsize); error = EINVAL; goto error_exit; }
Re: CVS commit: src/sys/fs/msdosfs
On Sun, Jul 13, 2014 at 04:34:59PM +0200, Martin Husemann wrote: On Sun, Jul 13, 2014 at 04:31:58PM +0200, Martin Husemann wrote: Why does lsof define _KERNEL ? Let me rephrase: we provide the userland important stuff when either _KERNEL or MAKEFS is defined - maybe MAKEFS should be renamed and lsof could use the new define instead of _KERNEL. MSDOSFS_MOUNT_USERLAND_DEFS or something. or _KMEM_USER ? David -- David Laight: da...@l8s.co.uk
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: maxv Date: Fri Jul 18 17:24:34 UTC 2014 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Make DPRINTF more understandable, and replace my previous #ifdef DIAGNOSTIC... To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.114 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.115 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.114 Wed Jul 16 20:09:00 2014 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Fri Jul 18 17:24:34 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.114 2014/07/16 20:09:00 maxv Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.115 2014/07/18 17:24:34 maxv Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.114 2014/07/16 20:09:00 maxv Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.115 2014/07/18 17:24:34 maxv Exp $); #if defined(_KERNEL_OPT) #include opt_compat_netbsd.h @@ -88,9 +88,9 @@ __KERNEL_RCSID(0, $NetBSD: msdosfs_vfso MODULE(MODULE_CLASS_VFS, msdos, NULL); #ifdef MSDOSFS_DEBUG -#define DPRINTF(a) uprintf a +#define DPRINTF(fmt, ...) uprintf(%s(): fmt \n, __func__, ##__VA_ARGS__) #else -#define DPRINTF(a) +#define DPRINTF(fmt, ...) #endif #define GEMDOSFS_BSIZE 512 @@ -337,7 +337,7 @@ msdosfs_mount(struct mount *mp, const ch /* not yet implemented */ error = EOPNOTSUPP; if (error) { - DPRINTF((vflush %d\n, error)); + DPRINTF(vflush %d, error); return (error); } if ((pmp-pm_flags MSDOSFSMNT_RONLY) @@ -357,14 +357,14 @@ msdosfs_mount(struct mount *mp, const ch KAUTH_SYSTEM_MOUNT, KAUTH_REQ_SYSTEM_MOUNT_DEVICE, mp, devvp, KAUTH_ARG(VREAD | VWRITE)); VOP_UNLOCK(devvp); - DPRINTF((KAUTH_REQ_SYSTEM_MOUNT_DEVICE %d\n, error)); + DPRINTF(KAUTH_REQ_SYSTEM_MOUNT_DEVICE %d, error); if (error) return (error); pmp-pm_flags = ~MSDOSFSMNT_RONLY; } if (args-fspec == NULL) { - DPRINTF((missing fspec\n)); + DPRINTF(missing fspec); return EINVAL; } } @@ -375,17 +375,17 @@ msdosfs_mount(struct mount *mp, const ch error = namei_simple_user(args-fspec, NSM_FOLLOW_NOEMULROOT, devvp); if (error != 0) { - DPRINTF((namei %d\n, error)); + DPRINTF(namei %d, error); return (error); } if (devvp-v_type != VBLK) { - DPRINTF((not block\n)); + DPRINTF(not block); vrele(devvp); return (ENOTBLK); } if (bdevsw_lookup(devvp-v_rdev) == NULL) { - DPRINTF((no block switch\n)); + DPRINTF(no block switch); vrele(devvp); return (ENXIO); } @@ -401,7 +401,7 @@ msdosfs_mount(struct mount *mp, const ch KAUTH_REQ_SYSTEM_MOUNT_DEVICE, mp, devvp, KAUTH_ARG(accessmode)); VOP_UNLOCK(devvp); if (error) { - DPRINTF((KAUTH_REQ_SYSTEM_MOUNT_DEVICE %d\n, error)); + DPRINTF(KAUTH_REQ_SYSTEM_MOUNT_DEVICE %d, error); vrele(devvp); return (error); } @@ -416,12 +416,12 @@ msdosfs_mount(struct mount *mp, const ch error = VOP_OPEN(devvp, xflags, FSCRED); VOP_UNLOCK(devvp); if (error) { - DPRINTF((VOP_OPEN %d\n, error)); + DPRINTF(VOP_OPEN %d, error); goto fail; } error = msdosfs_mountfs(devvp, mp, l, args); if (error) { - DPRINTF((msdosfs_mountfs %d\n, error)); + DPRINTF(msdosfs_mountfs %d, error); vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); (void) VOP_CLOSE(devvp, xflags, NOCRED); VOP_UNLOCK(devvp); @@ -433,14 +433,13 @@ msdosfs_mount(struct mount *mp, const ch } else { vrele(devvp); if (devvp != pmp-pm_devvp) { - DPRINTF((devvp %p pmp %p\n, - devvp, pmp-pm_devvp)); + DPRINTF(devvp %p pmp %p, devvp, pmp-pm_devvp); return (EINVAL); /* needs translation */ } } if ((error = update_mp(mp, args)) != 0) { msdosfs_unmount(mp, MNT_FORCE); - DPRINTF((update_mp %d\n, error)); + DPRINTF(update_mp %d, error); return error; } @@ -494,17 +493,14 @@ msdosfs_mountfs(struct vnode *devvp, str error = 0; } if (secsize DEV_BSIZE) { -#ifdef DIAGNOSTIC /* XXX: to be converted to DPRINTF */ - printf(%s(): Invalid block secsize (%d DEV_BSIZE)\n, __func__, - secsize); -#endif + DPRINTF(Invalid block secsize (%d DEV_BSIZE), secsize); error = EINVAL; goto error_exit; } if (argp-flags MSDOSFSMNT_GEMDOSFS) { if (secsize != GEMDOSFS_BSIZE) { - DPRINTF((Invalid block secsize %d for GEMDOS\n, secsize)); + DPRINTF(Invalid block secsize %d for GEMDOS, secsize); error = EINVAL; goto error_exit; } @@ -524,9 +520,9 @@ msdosfs_mountfs(struct vnode *devvp, str if (!(argp-flags MSDOSFSMNT_GEMDOSFS)) { if (bsp-bs50.bsBootSectSig0 != BOOTSIG0 || bsp-bs50.bsBootSectSig1 != BOOTSIG1) { - DPRINTF((bootsig0 %d bootsig1 %d\n, + DPRINTF(bootsig0 %d bootsig1
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: maxv Date: Fri Jul 18 17:24:34 UTC 2014 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Make DPRINTF more understandable, and replace my previous #ifdef DIAGNOSTIC... To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: maxv Date: Wed Jul 16 20:09:00 UTC 2014 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Limit the minimum size of a disk sector to 512 bytes, to prevent memory overflow on extremely low secsize. This normally conforms to the old standard (for which there doesn't seem to be a clear spec). Since 2011, IDEMA's Advanced Format standardizes it to 4k, so this change won't cause any trouble on new devices. Put the printf under DIAGNOSTIC temporarily to see if someone complains. after a quick discussion on tech-kern To generate a diff of this commit: cvs rdiff -u -r1.113 -r1.114 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.113 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.114 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.113 Tue Jul 15 11:43:54 2014 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Wed Jul 16 20:09:00 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.113 2014/07/15 11:43:54 christos Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.114 2014/07/16 20:09:00 maxv Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.113 2014/07/15 11:43:54 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.114 2014/07/16 20:09:00 maxv Exp $); #if defined(_KERNEL_OPT) #include opt_compat_netbsd.h @@ -493,6 +493,14 @@ msdosfs_mountfs(struct vnode *devvp, str psize = 0; error = 0; } + if (secsize DEV_BSIZE) { +#ifdef DIAGNOSTIC /* XXX: to be converted to DPRINTF */ + printf(%s(): Invalid block secsize (%d DEV_BSIZE)\n, __func__, + secsize); +#endif + error = EINVAL; + goto error_exit; + } if (argp-flags MSDOSFSMNT_GEMDOSFS) { if (secsize != GEMDOSFS_BSIZE) {
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: maxv Date: Wed Jul 16 20:09:00 UTC 2014 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Limit the minimum size of a disk sector to 512 bytes, to prevent memory overflow on extremely low secsize. This normally conforms to the old standard (for which there doesn't seem to be a clear spec). Since 2011, IDEMA's Advanced Format standardizes it to 4k, so this change won't cause any trouble on new devices. Put the printf under DIAGNOSTIC temporarily to see if someone complains. after a quick discussion on tech-kern To generate a diff of this commit: cvs rdiff -u -r1.113 -r1.114 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Tue Jul 15 11:43:54 UTC 2014 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Correct the bread size of struct fsinfo from Gerald Lee at DELL dot com To generate a diff of this commit: cvs rdiff -u -r1.112 -r1.113 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.112 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.113 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.112 Wed Jul 9 05:00:18 2014 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Tue Jul 15 07:43:54 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.112 2014/07/09 09:00:18 maxv Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.113 2014/07/15 11:43:54 christos Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.112 2014/07/09 09:00:18 maxv Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.113 2014/07/15 11:43:54 christos Exp $); #if defined(_KERNEL_OPT) #include opt_compat_netbsd.h @@ -741,6 +741,7 @@ msdosfs_mountfs(struct vnode *devvp, str */ if (pmp-pm_fsinfo) { struct fsinfo *fp; + const int rdsz = roundup(sizeof(*fp), pmp-pm_BytesPerSec); /* * XXX If the fsinfo block is stored on media with @@ -748,7 +749,7 @@ msdosfs_mountfs(struct vnode *devvp, str * padded at the end or in the middle? */ if ((error = bread(devvp, de_bn2kb(pmp, pmp-pm_fsinfo), - pmp-pm_BytesPerSec, NOCRED, 0, bp)) != 0) + rdsz, NOCRED, 0, bp)) != 0) goto error_exit; fp = (struct fsinfo *)bp-b_data; if (!memcmp(fp-fsisig1, RRaA, 4)
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Tue Jul 15 11:43:54 UTC 2014 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Correct the bread size of struct fsinfo from Gerald Lee at DELL dot com To generate a diff of this commit: cvs rdiff -u -r1.112 -r1.113 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys/fs/msdosfs
On Sun, Jul 13, 2014 at 04:34:59PM +0200, Martin Husemann wrote: On Sun, Jul 13, 2014 at 04:31:58PM +0200, Martin Husemann wrote: Why does lsof define _KERNEL ? Let me rephrase: we provide the userland important stuff when either _KERNEL or MAKEFS is defined - maybe MAKEFS should be renamed and lsof could use the new define instead of _KERNEL. MSDOSFS_MOUNT_USERLAND_DEFS or something. lsof inherently want to mess with the kernel details, i.e. to try to rediscover the original path name used to open a file etc. Joerg
Re: CVS commit: src/sys/fs/msdosfs
On Mon, Jul 14, 2014 at 10:26:58AM +0200, Joerg Sonnenberger wrote: MSDOSFS_MOUNT_USERLAND_DEFS or something. lsof inherently want to mess with the kernel details, i.e. to try to rediscover the original path name used to open a file etc. Yes, but some other parts in that file are really kernel only (and currently #ifdef'd on !MAKEFS, which is just a strange name). Martin
Re: CVS commit: src/sys/fs/msdosfs
On Tue, Jul 08, 2014 at 09:21:52AM +, Juergen Hannken-Illjes wrote: Module Name: src Committed By: hannken Date: Tue Jul 8 09:21:52 UTC 2014 Modified Files: src/sys/fs/msdosfs: denode.h msdosfs_denode.c msdosfs_lookup.c msdosfs_vfsops.c msdosfs_vnops.c msdosfsmount.h Log Message: Change msdosfs from hashlist to vcache: - Use (dir_cluster, dir_offset, dir_generation) as key, where dir_generation is non-zero and unique for unlinked but open nodes. - Change deget() to return a vnode as it is unsafe to return a referenced but unlocked denode. This broke sysutils/lsof, can you please take a look? /usr/include/msdosfs/msdosfsmount.h:255:12: error: a parameter list without types is only allowed in a function definition VFS_PROTOS(msdosfs); Joerg
Re: CVS commit: src/sys/fs/msdosfs
On 13 Jul 2014, at 15:36, Joerg Sonnenberger jo...@britannica.bec.de wrote: On Tue, Jul 08, 2014 at 09:21:52AM +, Juergen Hannken-Illjes wrote: Module Name: src Committed By:hannken Date:Tue Jul 8 09:21:52 UTC 2014 Modified Files: src/sys/fs/msdosfs: denode.h msdosfs_denode.c msdosfs_lookup.c msdosfs_vfsops.c msdosfs_vnops.c msdosfsmount.h Log Message: Change msdosfs from hashlist to vcache: - Use (dir_cluster, dir_offset, dir_generation) as key, where dir_generation is non-zero and unique for unlinked but open nodes. - Change deget() to return a vnode as it is unsafe to return a referenced but unlocked denode. This broke sysutils/lsof, can you please take a look? /usr/include/msdosfs/msdosfsmount.h:255:12: error: a parameter list without types is only allowed in a function definition VFS_PROTOS(msdosfs); Maybe a patch to lsof/dialects/n+obsd/dlsof.h like #if defined (NETBSDV) #define VFS_PROTOS(dummy) /**/ #endif before including msdosfsmount.h? -- J. Hannken-Illjes - hann...@eis.cs.tu-bs.de - TU Braunschweig (Germany)
Re: CVS commit: src/sys/fs/msdosfs
On Sun, Jul 13, 2014 at 04:15:47PM +0200, J. Hannken-Illjes wrote: Maybe a patch to lsof/dialects/n+obsd/dlsof.h like #if defined (NETBSDV) #define VFS_PROTOS(dummy) /**/ #endif before including msdosfsmount.h? Why does lsof define _KERNEL ? Martin
Re: CVS commit: src/sys/fs/msdosfs
On Sun, Jul 13, 2014 at 04:31:58PM +0200, Martin Husemann wrote: Why does lsof define _KERNEL ? Let me rephrase: we provide the userland important stuff when either _KERNEL or MAKEFS is defined - maybe MAKEFS should be renamed and lsof could use the new define instead of _KERNEL. MSDOSFS_MOUNT_USERLAND_DEFS or something. Martin
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: maxv Date: Wed Jul 9 09:00:18 UTC 2014 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Minor changes: - malloc()+memset() - malloc(|M_ZERO) - rename 'vers' to 'FSVers' - declare 'ExtFlags' instead of calling getushort() two times To generate a diff of this commit: cvs rdiff -u -r1.111 -r1.112 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.111 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.112 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.111 Wed Jul 9 08:43:54 2014 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Wed Jul 9 09:00:18 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.111 2014/07/09 08:43:54 maxv Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.112 2014/07/09 09:00:18 maxv Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.111 2014/07/09 08:43:54 maxv Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.112 2014/07/09 09:00:18 maxv Exp $); #if defined(_KERNEL_OPT) #include opt_compat_netbsd.h @@ -524,8 +524,7 @@ msdosfs_mountfs(struct vnode *devvp, str } } - pmp = malloc(sizeof *pmp, M_MSDOSFSMNT, M_WAITOK); - memset(pmp, 0, sizeof *pmp); + pmp = malloc(sizeof(*pmp), M_MSDOSFSMNT, M_WAITOK|M_ZERO); pmp-pm_mountp = mp; /* @@ -576,15 +575,16 @@ msdosfs_mountfs(struct vnode *devvp, str } if (pmp-pm_RootDirEnts == 0) { - unsigned short vers = getushort(b710-bpbFSVers); + unsigned short FSVers = getushort(b710-bpbFSVers); + unsigned short ExtFlags = getushort(b710-bpbExtFlags); /* * Some say that bsBootSectSig[23] must be zero, but * Windows does not require this and some digital cameras * do not set these to zero. Therefore, do not insist. */ - if (pmp-pm_Sectors || pmp-pm_FATsecs || vers) { - DPRINTF((sectors %d fatsecs %lu vers %d\n, - pmp-pm_Sectors, pmp-pm_FATsecs, vers)); + if (pmp-pm_Sectors || pmp-pm_FATsecs || FSVers) { + DPRINTF((Sectors %d FATsecs %lu FSVers %d\n, + pmp-pm_Sectors, pmp-pm_FATsecs, FSVers)); error = EINVAL; goto error_exit; } @@ -593,20 +593,18 @@ msdosfs_mountfs(struct vnode *devvp, str pmp-pm_fatdiv = 1; pmp-pm_FATsecs = getulong(b710-bpbBigFATsecs); - /* mirrorring is enabled if the FATMIRROR bit is not set */ - if ((getushort(b710-bpbExtFlags) FATMIRROR) == 0) + /* Mirroring is enabled if the FATMIRROR bit is not set. */ + if ((ExtFlags FATMIRROR) == 0) pmp-pm_flags |= MSDOSFS_FATMIRROR; else - pmp-pm_curfat = getushort(b710-bpbExtFlags) FATNUM; + pmp-pm_curfat = ExtFlags FATNUM; } else pmp-pm_flags |= MSDOSFS_FATMIRROR; if (argp-flags MSDOSFSMNT_GEMDOSFS) { if (FAT32(pmp)) { + /* GEMDOS doesn't know FAT32. */ DPRINTF((FAT32 for GEMDOS\n)); - /* - * GEMDOS doesn't know FAT32. - */ error = EINVAL; goto error_exit; }
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: maxv Date: Wed Jul 9 09:00:18 UTC 2014 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Minor changes: - malloc()+memset() - malloc(|M_ZERO) - rename 'vers' to 'FSVers' - declare 'ExtFlags' instead of calling getushort() two times To generate a diff of this commit: cvs rdiff -u -r1.111 -r1.112 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Tue Jul 8 09:21:52 UTC 2014 Modified Files: src/sys/fs/msdosfs: denode.h msdosfs_denode.c msdosfs_lookup.c msdosfs_vfsops.c msdosfs_vnops.c msdosfsmount.h Log Message: Change msdosfs from hashlist to vcache: - Use (dir_cluster, dir_offset, dir_generation) as key, where dir_generation is non-zero and unique for unlinked but open nodes. - Change deget() to return a vnode as it is unsafe to return a referenced but unlocked denode. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/fs/msdosfs/denode.h cvs rdiff -u -r1.49 -r1.50 src/sys/fs/msdosfs/msdosfs_denode.c cvs rdiff -u -r1.32 -r1.33 src/sys/fs/msdosfs/msdosfs_lookup.c cvs rdiff -u -r1.108 -r1.109 src/sys/fs/msdosfs/msdosfs_vfsops.c cvs rdiff -u -r1.89 -r1.90 src/sys/fs/msdosfs/msdosfs_vnops.c cvs rdiff -u -r1.19 -r1.20 src/sys/fs/msdosfs/msdosfsmount.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/denode.h diff -u src/sys/fs/msdosfs/denode.h:1.23 src/sys/fs/msdosfs/denode.h:1.24 --- src/sys/fs/msdosfs/denode.h:1.23 Sat Jan 26 19:45:02 2013 +++ src/sys/fs/msdosfs/denode.h Tue Jul 8 09:21:52 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: denode.h,v 1.23 2013/01/26 19:45:02 christos Exp $ */ +/* $NetBSD: denode.h,v 1.24 2014/07/08 09:21:52 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -153,15 +153,21 @@ struct fatcache { * This is the in memory variant of a dos directory entry. It is usually * contained within a vnode. */ +struct denode_key { + u_long dk_dirclust; /* cluster of the directory file containing this entry */ + u_long dk_diroffset; /* offset of this entry in the directory cluster */ + void *dk_dirgen; /* non zero and unique for unlinked nodes */ +}; struct denode { struct genfs_node de_gnode; - LIST_ENTRY(denode) de_hash; struct vnode *de_vnode; /* addr of vnode we are part of */ struct vnode *de_devvp; /* vnode of blk dev we live on */ u_long de_flag; /* flag bits */ dev_t de_dev; /* device where direntry lives */ - u_long de_dirclust; /* cluster of the directory file containing this entry */ - u_long de_diroffset; /* offset of this entry in the directory cluster */ + struct denode_key de_key; +#define de_dirclust de_key.dk_dirclust +#define de_diroffset de_key.dk_diroffset +#define de_dirgen de_key.dk_dirgen u_long de_fndoffset; /* offset of found dir entry */ int de_fndcnt; /* number of slots before de_fndoffset */ long de_refcnt; /* reference count */ @@ -303,7 +309,11 @@ int msdosfs_update(struct vnode *, const int createde(struct denode *, struct denode *, struct denode **, struct componentname *); int deextend(struct denode *, u_long, struct kauth_cred *); +#ifdef MAKEFS int deget(struct msdosfsmount *, u_long, u_long, struct denode **); +#else +int deget(struct msdosfsmount *, u_long, u_long, struct vnode **); +#endif int detrunc(struct denode *, u_long, int, struct kauth_cred *); int deupdat(struct denode *, int); int doscheckpath(struct denode *, struct denode *); @@ -311,7 +321,6 @@ int dosdirempty(struct denode *); int readde(struct denode *, struct buf **, struct direntry **); int readep(struct msdosfsmount *, u_long, u_long, struct buf **, struct direntry **); -void reinsert(struct denode *); int removede(struct denode *, struct denode *); int uniqdosname(struct denode *, struct componentname *, u_char *); int findwin95(struct denode *); Index: src/sys/fs/msdosfs/msdosfs_denode.c diff -u src/sys/fs/msdosfs/msdosfs_denode.c:1.49 src/sys/fs/msdosfs/msdosfs_denode.c:1.50 --- src/sys/fs/msdosfs/msdosfs_denode.c:1.49 Fri May 30 08:42:35 2014 +++ src/sys/fs/msdosfs/msdosfs_denode.c Tue Jul 8 09:21:52 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_denode.c,v 1.49 2014/05/30 08:42:35 hannken Exp $ */ +/* $NetBSD: msdosfs_denode.c,v 1.50 2014/07/08 09:21:52 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.49 2014/05/30 08:42:35 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.50 2014/07/08 09:21:52 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -72,14 +72,6 @@ __KERNEL_RCSID(0, $NetBSD: msdosfs_deno #include fs/msdosfs/denode.h #include fs/msdosfs/fat.h -LIST_HEAD(ihashhead, denode) *dehashtbl; -u_long dehash; /* size of hash table - 1 */ -#define DEHASH(dev, dcl, doff) \ -(((dev) + (dcl) + (doff) / sizeof(struct direntry)) dehash) - -kmutex_t msdosfs_ihash_lock; -kmutex_t msdosfs_hashlock; - struct pool msdosfs_denode_pool; extern int prtactive; @@ -138,10 +130,6 @@ static const struct genfs_ops msdosfs_ge .gop_markupdate = msdosfs_gop_markupdate, }; -static struct denode *msdosfs_hashget(dev_t, u_long, u_long, int); -static void msdosfs_hashins(struct denode *); -static void
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: maxv Date: Tue Jul 8 19:34:47 UTC 2014 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: - Perform sanity checks not just for GEMDOSFS, but for all FAT devices. This also fixes a division-by-zero bug that could crash the system. - Define GEMDOSFS_BSIZE instead of a hard-coded 512 value, and remove 'bsize'. - Rename 'tmp' to 'BlkPerSec'. From me, FreeBSD, OpenBSD and the FAT specification. ok christos@ To generate a diff of this commit: cvs rdiff -u -r1.109 -r1.110 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.109 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.110 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.109 Tue Jul 8 09:21:52 2014 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Tue Jul 8 19:34:47 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.109 2014/07/08 09:21:52 hannken Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.110 2014/07/08 19:34:47 maxv Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.109 2014/07/08 09:21:52 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.110 2014/07/08 19:34:47 maxv Exp $); #if defined(_KERNEL_OPT) #include opt_compat_netbsd.h @@ -93,6 +93,8 @@ MODULE(MODULE_CLASS_VFS, msdos, NULL); #define DPRINTF(a) #endif +#define GEMDOSFS_BSIZE 512 + #define MSDOSFS_NAMEMAX(pmp) \ (pmp)-pm_flags MSDOSFSMNT_LONGNAME ? WIN_MAXLEN : 12 @@ -466,8 +468,7 @@ msdosfs_mountfs(struct vnode *devvp, str struct byte_bpb50 *b50; struct byte_bpb710 *b710; uint8_t SecPerClust; - int ronly, error, tmp; - int bsize; + int ronly, error, BlkPerSec; uint64_t psize; unsigned secsize; @@ -496,14 +497,12 @@ msdosfs_mountfs(struct vnode *devvp, str } if (argp-flags MSDOSFSMNT_GEMDOSFS) { - bsize = secsize; - if (bsize != 512) { - DPRINTF((Invalid block bsize %d for GEMDOS\n, bsize)); + if (secsize != GEMDOSFS_BSIZE) { + DPRINTF((Invalid block secsize %d for GEMDOS\n, secsize)); error = EINVAL; goto error_exit; } - } else - bsize = 0; + } /* * Read the boot sector of the filesystem, and then check the @@ -547,19 +546,6 @@ msdosfs_mountfs(struct vnode *devvp, str pmp-pm_Heads = getushort(b50-bpbHeads); pmp-pm_Media = b50-bpbMedia; - if (!(argp-flags MSDOSFSMNT_GEMDOSFS)) { - /* XXX - We should probably check more values here */ - if (!pmp-pm_BytesPerSec || !SecPerClust - || pmp-pm_SecPerTrack 63) { - DPRINTF((bytespersec %d secperclust %d - secpertrack %d\n, - pmp-pm_BytesPerSec, SecPerClust, - pmp-pm_SecPerTrack)); - error = EINVAL; - goto error_exit; - } - } - if (pmp-pm_Sectors == 0) { pmp-pm_HiddenSects = getulong(b50-bpbHiddenSecs); pmp-pm_HugeSectors = getulong(b50-bpbHugeSectors); @@ -568,6 +554,29 @@ msdosfs_mountfs(struct vnode *devvp, str pmp-pm_HugeSectors = pmp-pm_Sectors; } + /* + * Sanity checks, from the FAT specification: + * - sectors per cluster: = 1, power of 2 + * - logical sector size: = 1, power of 2 + * - cluster size:= max FS block size + * - number of sectors: = 1 + */ + if ((SecPerClust == 0) || !powerof2(SecPerClust) || + (pmp-pm_BytesPerSec == 0) || !powerof2(pmp-pm_BytesPerSec) || + (SecPerClust * pmp-pm_BytesPerSec MAXBSIZE) || + (pmp-pm_HugeSectors == 0)) { + DPRINTF((consistency checks\n)); + error = EINVAL; + goto error_exit; + } + + if (!(argp-flags MSDOSFSMNT_GEMDOSFS) + (pmp-pm_SecPerTrack 63)) { + DPRINTF((SecPerTrack %d\n, pmp-pm_SecPerTrack)); + error = EINVAL; + goto error_exit; + } + if (pmp-pm_RootDirEnts == 0) { unsigned short vers = getushort(b710-bpbFSVers); /* @@ -606,17 +615,12 @@ msdosfs_mountfs(struct vnode *devvp, str /* * Check a few values (could do some more): - * - logical sector size: power of 2, = block size - * - sectors per cluster: power of 2, = 1 - * - number of sectors: = 1, = size of partition + * - logical sector size: = block size + * - number of sectors: = size of partition */ - if ( (SecPerClust == 0) - || (SecPerClust (SecPerClust - 1)) - || (pmp-pm_BytesPerSec bsize) - || (pmp-pm_BytesPerSec (pmp-pm_BytesPerSec - 1)) - || (pmp-pm_HugeSectors == 0) - || (pmp-pm_HugeSectors * (pmp-pm_BytesPerSec / bsize) - psize)) { + if ((pmp-pm_BytesPerSec GEMDOSFS_BSIZE) || + (pmp-pm_HugeSectors * + (pmp-pm_BytesPerSec / GEMDOSFS_BSIZE) psize)) { DPRINTF((consistency checks for GEMDOS\n)); error = EINVAL; goto error_exit; @@ -627,14 +631,14 @@ msdosfs_mountfs(struct vnode *devvp, str * always be the same as the number of bytes per disk block * Let's pretend it is. */ - tmp = pmp-pm_BytesPerSec /
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Tue Jul 8 09:21:52 UTC 2014 Modified Files: src/sys/fs/msdosfs: denode.h msdosfs_denode.c msdosfs_lookup.c msdosfs_vfsops.c msdosfs_vnops.c msdosfsmount.h Log Message: Change msdosfs from hashlist to vcache: - Use (dir_cluster, dir_offset, dir_generation) as key, where dir_generation is non-zero and unique for unlinked but open nodes. - Change deget() to return a vnode as it is unsafe to return a referenced but unlocked denode. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/fs/msdosfs/denode.h cvs rdiff -u -r1.49 -r1.50 src/sys/fs/msdosfs/msdosfs_denode.c cvs rdiff -u -r1.32 -r1.33 src/sys/fs/msdosfs/msdosfs_lookup.c cvs rdiff -u -r1.108 -r1.109 src/sys/fs/msdosfs/msdosfs_vfsops.c cvs rdiff -u -r1.89 -r1.90 src/sys/fs/msdosfs/msdosfs_vnops.c cvs rdiff -u -r1.19 -r1.20 src/sys/fs/msdosfs/msdosfsmount.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: maxv Date: Tue Jul 8 19:34:47 UTC 2014 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: - Perform sanity checks not just for GEMDOSFS, but for all FAT devices. This also fixes a division-by-zero bug that could crash the system. - Define GEMDOSFS_BSIZE instead of a hard-coded 512 value, and remove 'bsize'. - Rename 'tmp' to 'BlkPerSec'. From me, FreeBSD, OpenBSD and the FAT specification. ok christos@ To generate a diff of this commit: cvs rdiff -u -r1.109 -r1.110 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Fri May 30 08:42:35 UTC 2014 Modified Files: src/sys/fs/msdosfs: msdosfs_denode.c Log Message: msdosfs_reclaim(): add missing fstrans and protect change of v_data with v_interlock as msdosfs_sync() now needs it. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/fs/msdosfs/msdosfs_denode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_denode.c diff -u src/sys/fs/msdosfs/msdosfs_denode.c:1.48 src/sys/fs/msdosfs/msdosfs_denode.c:1.49 --- src/sys/fs/msdosfs/msdosfs_denode.c:1.48 Thu Dec 20 08:03:42 2012 +++ src/sys/fs/msdosfs/msdosfs_denode.c Fri May 30 08:42:35 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_denode.c,v 1.48 2012/12/20 08:03:42 hannken Exp $ */ +/* $NetBSD: msdosfs_denode.c,v 1.49 2014/05/30 08:42:35 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.48 2012/12/20 08:03:42 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.49 2014/05/30 08:42:35 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -671,8 +671,10 @@ msdosfs_reclaim(void *v) struct vnode *a_vp; } */ *ap = v; struct vnode *vp = ap-a_vp; + struct mount *mp = vp-v_mount; struct denode *dep = VTODE(vp); + fstrans_start(mp, FSTRANS_LAZY); #ifdef MSDOSFS_DEBUG printf(msdosfs_reclaim(): dep %p, file %s, refcnt %ld\n, dep, dep-de_Name, dep-de_refcnt); @@ -694,9 +696,15 @@ msdosfs_reclaim(void *v) #if 0 /* XXX */ dep-de_flag = 0; #endif + /* + * To interlock with msdosfs_sync(). + */ genfs_node_destroy(vp); - pool_put(msdosfs_denode_pool, dep); + mutex_enter(vp-v_interlock); vp-v_data = NULL; + mutex_exit(vp-v_interlock); + pool_put(msdosfs_denode_pool, dep); + fstrans_done(mp); return (0); }
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Fri May 30 08:42:35 UTC 2014 Modified Files: src/sys/fs/msdosfs: msdosfs_denode.c Log Message: msdosfs_reclaim(): add missing fstrans and protect change of v_data with v_interlock as msdosfs_sync() now needs it. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/fs/msdosfs/msdosfs_denode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Mon Mar 17 09:35:59 UTC 2014 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Change msdosfs_sync() to use vfs_vnode_iterator. To generate a diff of this commit: cvs rdiff -u -r1.104 -r1.105 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.104 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.105 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.104 Tue Feb 25 18:30:10 2014 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Mon Mar 17 09:35:59 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.104 2014/02/25 18:30:10 pooka Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.105 2014/03/17 09:35:59 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.104 2014/02/25 18:30:10 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.105 2014/03/17 09:35:59 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_compat_netbsd.h @@ -946,7 +946,8 @@ msdosfs_statvfs(struct mount *mp, struct int msdosfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred) { - struct vnode *vp, *mvp; + struct vnode *vp; + struct vnode_iterator *marker; struct denode *dep; struct msdosfsmount *pmp = VFSTOMSDOSFS(mp); int error, allerror = 0; @@ -962,46 +963,32 @@ msdosfs_sync(struct mount *mp, int waitf /* update FATs here */ } } - /* Allocate a marker vnode. */ - mvp = vnalloc(mp); fstrans_start(mp, FSTRANS_SHARED); /* * Write back each (modified) denode. */ - mutex_enter(mntvnode_lock); -loop: - for (vp = TAILQ_FIRST(mp-mnt_vnodelist); vp; vp = vunmark(mvp)) { - vmark(mvp, vp); - if (vp-v_mount != mp || vismarker(vp)) + vfs_vnode_iterator_init(mp, marker); + while (vfs_vnode_iterator_next(marker, vp)) { + error = vn_lock(vp, LK_EXCLUSIVE); + if (error) { + vrele(vp); continue; - mutex_enter(vp-v_interlock); + } dep = VTODE(vp); if (waitfor == MNT_LAZY || vp-v_type == VNON || dep == NULL || (((dep-de_flag (DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0) (LIST_EMPTY(vp-v_dirtyblkhd) UVM_OBJ_IS_CLEAN(vp-v_uobj { - mutex_exit(vp-v_interlock); - continue; - } - mutex_exit(mntvnode_lock); - error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT); - if (error) { - mutex_enter(mntvnode_lock); - if (error == ENOENT) { -(void)vunmark(mvp); -goto loop; - } + vput(vp); continue; } if ((error = VOP_FSYNC(vp, cred, waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0)) != 0) allerror = error; vput(vp); - mutex_enter(mntvnode_lock); } - mutex_exit(mntvnode_lock); - vnfree(mvp); + vfs_vnode_iterator_destroy(marker); /* * Force stale file system control information to be flushed.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Mon Mar 17 09:35:59 UTC 2014 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Change msdosfs_sync() to use vfs_vnode_iterator. To generate a diff of this commit: cvs rdiff -u -r1.104 -r1.105 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mlelstv Date: Tue Dec 24 16:51:24 UTC 2013 Modified Files: src/sys/fs/msdosfs: msdosfs_lookup.c Log Message: don't treat adjacent members as a larger array Coverity CID 977367 To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/fs/msdosfs/msdosfs_lookup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_lookup.c diff -u src/sys/fs/msdosfs/msdosfs_lookup.c:1.29 src/sys/fs/msdosfs/msdosfs_lookup.c:1.30 --- src/sys/fs/msdosfs/msdosfs_lookup.c:1.29 Sat Jan 26 16:51:51 2013 +++ src/sys/fs/msdosfs/msdosfs_lookup.c Tue Dec 24 16:51:24 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_lookup.c,v 1.29 2013/01/26 16:51:51 christos Exp $ */ +/* $NetBSD: msdosfs_lookup.c,v 1.30 2013/12/24 16:51:24 mlelstv Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -52,7 +52,7 @@ #endif #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_lookup.c,v 1.29 2013/01/26 16:51:51 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_lookup.c,v 1.30 2013/12/24 16:51:24 mlelstv Exp $); #include sys/param.h @@ -300,8 +300,10 @@ msdosfs_lookup(void *v) * Check for a checksum or name match */ chksum_ok = (chksum == winChksum(dep-deName)); -if (!chksum_ok - (!olddos || memcmp(dosfilename, dep-deName, 11))) { +if (!chksum_ok ( + !olddos || + memcmp(dosfilename[0],dep-deName,8) || + memcmp(dosfilename[8],dep-deExtension,3))) { chksum = -1; continue; }
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: mlelstv Date: Tue Dec 24 16:51:24 UTC 2013 Modified Files: src/sys/fs/msdosfs: msdosfs_lookup.c Log Message: don't treat adjacent members as a larger array Coverity CID 977367 To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/fs/msdosfs/msdosfs_lookup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Sat Nov 2 10:30:18 UTC 2013 Modified Files: src/sys/fs/msdosfs: msdosfs_vnops.c Log Message: Stop using v_mount of an unreferenced vnode -- save the mount while the vnode has a reference. To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vnops.c diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.86 src/sys/fs/msdosfs/msdosfs_vnops.c:1.87 --- src/sys/fs/msdosfs/msdosfs_vnops.c:1.86 Mon Mar 18 19:35:37 2013 +++ src/sys/fs/msdosfs/msdosfs_vnops.c Sat Nov 2 10:30:18 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vnops.c,v 1.86 2013/03/18 19:35:37 plunky Exp $ */ +/* $NetBSD: msdosfs_vnops.c,v 1.87 2013/11/02 10:30:18 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.86 2013/03/18 19:35:37 plunky Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.87 2013/11/02 10:30:18 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -829,6 +829,7 @@ msdosfs_rename(void *v) struct vnode *tdvp = ap-a_tdvp; struct vnode *fvp = ap-a_fvp; struct vnode *fdvp = ap-a_fdvp; + struct mount *mp = fdvp-v_mount; struct componentname *tcnp = ap-a_tcnp; struct componentname *fcnp = ap-a_fcnp; struct denode *ip, *xp, *dp, *zp; @@ -906,7 +907,7 @@ abortit: } VN_KNOTE(fdvp, NOTE_WRITE); /* XXXLUKEM/XXX: right place? */ - fstrans_start(fdvp-v_mount, FSTRANS_SHARED); + fstrans_start(mp, FSTRANS_SHARED); /* * When the target exists, both the directory * and target vnodes are returned locked. @@ -993,7 +994,7 @@ abortit: * file/directory. */ if ((error = uniqdosname(VTODE(tdvp), tcnp, toname)) != 0) { - fstrans_done(fdvp-v_mount); + fstrans_done(mp); goto abortit; } @@ -1009,7 +1010,7 @@ abortit: VOP_UNLOCK(fdvp); vrele(ap-a_fvp); vrele(tdvp); - fstrans_done(fdvp-v_mount); + fstrans_done(mp); return (error); } if (fvp == NULL) { @@ -1021,7 +1022,7 @@ abortit: vput(fdvp); vrele(ap-a_fvp); vrele(tdvp); - fstrans_done(fdvp-v_mount); + fstrans_done(mp); return 0; } VOP_UNLOCK(fdvp); @@ -1129,7 +1130,7 @@ bad: ip-de_flag = ~DE_RENAME; vrele(fdvp); vrele(fvp); - fstrans_done(fdvp-v_mount); + fstrans_done(mp); return (error); /* XXX: uuuh */ @@ -1291,6 +1292,7 @@ msdosfs_rmdir(void *v) } */ *ap = v; struct vnode *vp = ap-a_vp; struct vnode *dvp = ap-a_dvp; + struct mount *mp = dvp-v_mount; struct componentname *cnp = ap-a_cnp; struct denode *ip, *dp; int error; @@ -1305,7 +1307,7 @@ msdosfs_rmdir(void *v) vput(vp); return (EINVAL); } - fstrans_start(ap-a_dvp-v_mount, FSTRANS_SHARED); + fstrans_start(mp, FSTRANS_SHARED); /* * Verify the directory is empty (and valid). * (Rmdir .. won't be valid since @@ -1347,7 +1349,7 @@ out: if (dvp) vput(dvp); vput(vp); - fstrans_done(ap-a_dvp-v_mount); + fstrans_done(mp); return (error); }
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Sat Nov 2 10:30:18 UTC 2013 Modified Files: src/sys/fs/msdosfs: msdosfs_vnops.c Log Message: Stop using v_mount of an unreferenced vnode -- save the mount while the vnode has a reference. To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Sun Oct 20 00:01:55 UTC 2013 Modified Files: src/sys/fs/msdosfs: direntry.h Log Message: provide a function to access the name and extension as a single array as opposed depend on array index overflow. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/fs/msdosfs/direntry.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/direntry.h diff -u src/sys/fs/msdosfs/direntry.h:1.6 src/sys/fs/msdosfs/direntry.h:1.7 --- src/sys/fs/msdosfs/direntry.h:1.6 Fri Jan 25 19:21:49 2013 +++ src/sys/fs/msdosfs/direntry.h Sat Oct 19 20:01:55 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: direntry.h,v 1.6 2013/01/26 00:21:49 christos Exp $ */ +/* $NetBSD: direntry.h,v 1.7 2013/10/20 00:01:55 christos Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -78,6 +78,12 @@ struct direntry { u_int8_t deFileSize[4]; /* size of file in bytes */ }; +static __inline uint8_t +msdos_dirchar(const struct direntry *de, size_t i) { + return i sizeof(de-deName) ? de-deName[i] : + de-deExtension[i - sizeof(de-deName)]; +} + /* * Structure of a Win95 long name directory entry */
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Sun Oct 20 00:01:55 UTC 2013 Modified Files: src/sys/fs/msdosfs: direntry.h Log Message: provide a function to access the name and extension as a single array as opposed depend on array index overflow. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/fs/msdosfs/direntry.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: jakllsch Date: Mon Apr 15 14:11:00 UTC 2013 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Don't attempt to mount file system with clusters larger than MAXBSIZE. To generate a diff of this commit: cvs rdiff -u -r1.100 -r1.101 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.100 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.101 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.100 Sun Nov 4 17:57:59 2012 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Mon Apr 15 14:10:59 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.100 2012/11/04 17:57:59 jakllsch Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.101 2013/04/15 14:10:59 jakllsch Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.100 2012/11/04 17:57:59 jakllsch Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.101 2013/04/15 14:10:59 jakllsch Exp $); #if defined(_KERNEL_OPT) #include opt_compat_netbsd.h @@ -727,6 +727,18 @@ msdosfs_mountfs(struct vnode *devvp, str } /* + * Cluster size must be within limit of MAXBSIZE. + * Many FAT filesystems will not have clusters larger than + * 32KiB due to limits in Windows versions before Vista. + */ + if (pmp-pm_bpcluster MAXBSIZE) { + DPRINTF((bpcluster %lu MAXBSIZE %d\n, + pmp-pm_bpcluster, MAXBSIZE)); + error = EINVAL; + goto error_exit; + } + + /* * Release the bootsector buffer. */ brelse(bp, BC_AGE);
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: jakllsch Date: Mon Apr 15 14:11:00 UTC 2013 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Don't attempt to mount file system with clusters larger than MAXBSIZE. To generate a diff of this commit: cvs rdiff -u -r1.100 -r1.101 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Sun Jan 27 20:15:58 UTC 2013 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: tidy up debugging printfs; no functional change. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_fat.c diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.25 src/sys/fs/msdosfs/msdosfs_fat.c:1.26 --- src/sys/fs/msdosfs/msdosfs_fat.c:1.25 Sat Jan 26 11:51:51 2013 +++ src/sys/fs/msdosfs/msdosfs_fat.c Sun Jan 27 15:15:58 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_fat.c,v 1.25 2013/01/26 16:51:51 christos Exp $ */ +/* $NetBSD: msdosfs_fat.c,v 1.26 2013/01/27 20:15:58 christos Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -52,7 +52,7 @@ #endif #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.25 2013/01/26 16:51:51 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.26 2013/01/27 20:15:58 christos Exp $); /* * kernel include files. @@ -97,6 +97,11 @@ int fc_wherefrom, fc_whereto, fc_lastclu int pm_fatblocksize; #ifdef MSDOSFS_DEBUG +#define DPRINTF(a) printf a +#else +#define DPRINTF(a) +#endif +#ifdef MSDOSFS_DEBUG void print_fat_stats(void); void @@ -199,6 +204,7 @@ pcbmap(struct denode *dep, u_long findcn return (0); cn = dep-de_StartCluster; + DPRINTF((%s(start cluster=%lu)\n, __func__, cn)); /* * The file that makes up the root directory is contiguous, * permanently allocated, of fixed size, and is not made up of @@ -210,6 +216,8 @@ pcbmap(struct denode *dep, u_long findcn if (de_cn2off(pmp, findcn) = dep-de_FileSize) { if (cnp) *cnp = de_bn2cn(pmp, pmp-pm_rootdirsize); +DPRINTF((%s(root, %lu ETOOBIG)\n, __func__, +de_cn2off(pmp, findcn))); return (E2BIG); } if (bnp) @@ -219,10 +227,14 @@ pcbmap(struct denode *dep, u_long findcn if (sp) *sp = min(pmp-pm_bpcluster, dep-de_FileSize - de_cn2off(pmp, findcn)); + DPRINTF((%s(root, bn=%lu, cn=%u)\n, __func__, + pmp-pm_rootdirblk + de_cn2bn(pmp, findcn), + MSDOSFSROOT)); return (0); } else { /* just an empty file */ if (cnp) *cnp = 0; + DPRINTF((%s(root, empty ETOOBIG)\n, __func__)); return (E2BIG); } } @@ -240,6 +252,8 @@ pcbmap(struct denode *dep, u_long findcn */ i = 0; fc_lookup(dep, findcn, i, cn); + DPRINTF((%s(bpcluster=%lu i=%lu cn=%lu\n, __func__, pmp-pm_bpcluster, + i, cn)); if ((bn = findcn - i) = LMMAX) { fc_largedistance++; fc_wherefrom = i; @@ -265,6 +279,7 @@ pcbmap(struct denode *dep, u_long findcn error = bread(pmp-pm_devvp, de_bn2kb(pmp, bn), bsize, NOCRED, 0, bp); if (error) { +DPRINTF((%s(bread, %d)\n, __func__, error)); return (error); } bp_bn = bn; @@ -273,6 +288,8 @@ pcbmap(struct denode *dep, u_long findcn if (bo = bsize) { if (bp) brelse(bp, 0); + DPRINTF((%s(block, %lu = %lu)\n, __func__, bo, + bsize)); return (EIO); } KASSERT(bp != NULL); @@ -292,6 +309,8 @@ pcbmap(struct denode *dep, u_long findcn *bnp = cntobn(pmp, cn); if (cnp) *cnp = cn; + DPRINTF((%s(bn=%lu, cn=%lu)\n, __func__, cntobn(pmp, cn), + cn)); fc_setcache(dep, FC_LASTMAP, i, cn); return (0); } @@ -303,6 +322,7 @@ hiteof:; brelse(bp, 0); /* update last file cluster entry in the FAT cache */ fc_setcache(dep, FC_LASTFC, i - 1, prevcn); + DPRINTF((%s(eof, %lu)\n, __func__, i)); return (E2BIG); } @@ -362,10 +382,7 @@ updatefats(struct msdosfsmount *pmp, str int i; struct buf *bpn; -#ifdef MSDOSFS_DEBUG - printf(updatefats(pmp %p, bp %p, fatbn %lu)\n, - pmp, bp, fatbn); -#endif + DPRINTF((%s(pmp %p, bp %p, fatbn %lu)\n, __func__, pmp, bp, fatbn)); /* * If we have an FSInfo block, update it. @@ -530,17 +547,16 @@ fatentry(int function, struct msdosfsmou u_long bn, bo, bsize, byteoffset; struct buf *bp; -#ifdef MSDOSFS_DEBUG - printf(fatentry(func %d, pmp %p, clust %lu, oldcon %p, newcon %lx)\n, - function, pmp, cn, oldcontents, newcontents); -#endif + DPRINTF((%s(func %d, pmp %p, clust %lu, oldcon %p, newcon %lx)\n, + __func__, function, pmp, cn, oldcontents, newcontents)); #ifdef DIAGNOSTIC /* * Be sure they asked us to do something. */ if ((function (FAT_SET | FAT_GET)) == 0) { - printf(fatentry(): function code doesn't specify get or set\n); + DPRINTF((%s(): function code doesn't specify get or set\n, + __func__)); return (EINVAL); } @@ -549,7 +565,8 @@ fatentry(int function, struct msdosfsmou * where to put it, give them an error. */ if ((function FAT_GET) oldcontents == NULL) { - printf(fatentry(): get function with no place to put result\n); + DPRINTF((%s(): get function with no place to put result\n, + __func__)); return (EINVAL); }
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Sun Jan 27 22:04:19 UTC 2013 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: don't need sys/mount.h in userland. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_fat.c diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.26 src/sys/fs/msdosfs/msdosfs_fat.c:1.27 --- src/sys/fs/msdosfs/msdosfs_fat.c:1.26 Sun Jan 27 15:15:58 2013 +++ src/sys/fs/msdosfs/msdosfs_fat.c Sun Jan 27 17:04:19 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_fat.c,v 1.26 2013/01/27 20:15:58 christos Exp $ */ +/* $NetBSD: msdosfs_fat.c,v 1.27 2013/01/27 22:04:19 christos Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -52,15 +52,15 @@ #endif #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.26 2013/01/27 20:15:58 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.27 2013/01/27 22:04:19 christos Exp $); /* * kernel include files. */ #include sys/param.h #include sys/file.h -#include sys/mount.h /* to define statvfs structure */ #ifdef _KERNEL +#include sys/mount.h /* to define statvfs structure */ #include sys/errno.h #include sys/systm.h #include sys/kauth.h
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Mon Jan 28 00:17:18 UTC 2013 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: A little more debugging. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_fat.c diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.27 src/sys/fs/msdosfs/msdosfs_fat.c:1.28 --- src/sys/fs/msdosfs/msdosfs_fat.c:1.27 Sun Jan 27 17:04:19 2013 +++ src/sys/fs/msdosfs/msdosfs_fat.c Sun Jan 27 19:17:18 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_fat.c,v 1.27 2013/01/27 22:04:19 christos Exp $ */ +/* $NetBSD: msdosfs_fat.c,v 1.28 2013/01/28 00:17:18 christos Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -52,7 +52,7 @@ #endif #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.27 2013/01/27 22:04:19 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.28 2013/01/28 00:17:18 christos Exp $); /* * kernel include files. @@ -147,6 +147,8 @@ fatblock(struct msdosfsmount *pmp, u_lon * pmp-pm_BytesPerSec; bn += pmp-pm_fatblk + pmp-pm_curfat * pmp-pm_FATsecs; + DPRINTF((%s(ofs=%lu bn=%lu, size=%lu, bo=%lu)\n, __func__, ofs, bn, + size, ofs % pmp-pm_fatblocksize)); if (bnp) *bnp = bn; if (sizep) @@ -154,7 +156,7 @@ fatblock(struct msdosfsmount *pmp, u_lon if (bop) *bop = ofs % pmp-pm_fatblocksize; - pm_fatblocksize = pmp-pm_fatblocksize; + pm_fatblocksize = pmp-pm_fatblocksize; } /* @@ -299,6 +301,8 @@ pcbmap(struct denode *dep, u_long findcn cn = getushort((char *)bp-b_data + bo); if (FAT12(pmp) (prevcn 1)) cn = 4; + DPRINTF((%s(cn=%lu masked=%lu)\n, __func__, cn, + cn pmp-pm_fatmask)); cn = pmp-pm_fatmask; }
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Sun Jan 27 20:15:58 UTC 2013 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: tidy up debugging printfs; no functional change. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Sun Jan 27 22:04:19 UTC 2013 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: don't need sys/mount.h in userland. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Mon Jan 28 00:17:18 UTC 2013 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: A little more debugging. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Sat Jan 26 16:51:51 UTC 2013 Modified Files: src/sys/fs/msdosfs: denode.h msdosfs_conv.c msdosfs_fat.c msdosfs_lookup.c msdosfsmount.h Log Message: more cross-compile friendly. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/fs/msdosfs/denode.h cvs rdiff -u -r1.8 -r1.9 src/sys/fs/msdosfs/msdosfs_conv.c cvs rdiff -u -r1.24 -r1.25 src/sys/fs/msdosfs/msdosfs_fat.c cvs rdiff -u -r1.28 -r1.29 src/sys/fs/msdosfs/msdosfs_lookup.c cvs rdiff -u -r1.18 -r1.19 src/sys/fs/msdosfs/msdosfsmount.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/denode.h diff -u src/sys/fs/msdosfs/denode.h:1.21 src/sys/fs/msdosfs/denode.h:1.22 --- src/sys/fs/msdosfs/denode.h:1.21 Fri Jan 25 19:21:49 2013 +++ src/sys/fs/msdosfs/denode.h Sat Jan 26 11:51:51 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: denode.h,v 1.21 2013/01/26 00:21:49 christos Exp $ */ +/* $NetBSD: denode.h,v 1.22 2013/01/26 16:51:51 christos Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -49,7 +49,15 @@ #ifndef _MSDOSFS_DENODE_H_ #define _MSDOSFS_DENODE_H_ +#ifdef _KERNEL #include miscfs/genfs/genfs_node.h +#else +struct genfs_node { +}; +struct vnode; +struct msdosfsmount; +struct buf; +#endif /* * This is the pc filesystem specific portion of the vnode structure. @@ -289,13 +297,14 @@ int msdosfs_pathconf (void *); */ struct componentname; struct direntry; +struct kauth_cred; int msdosfs_update(struct vnode *, const struct timespec *, const struct timespec *, int); int createde(struct denode *, struct denode *, struct denode **, struct componentname *); -int deextend(struct denode *, u_long, kauth_cred_t); +int deextend(struct denode *, u_long, struct kauth_cred *); int deget(struct msdosfsmount *, u_long, u_long, struct denode **); -int detrunc(struct denode *, u_long, int, kauth_cred_t); +int detrunc(struct denode *, u_long, int, struct kauth_cred *); int deupdat(struct denode *, int); int doscheckpath(struct denode *, struct denode *); int dosdirempty(struct denode *); @@ -306,7 +315,7 @@ void reinsert(struct denode *); int removede(struct denode *, struct denode *); int uniqdosname(struct denode *, struct componentname *, u_char *); int findwin95(struct denode *); -int msdosfs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t); +int msdosfs_gop_alloc(struct vnode *, off_t, off_t, int, struct kauth_cred *); void msdosfs_gop_markupdate(struct vnode *, int); void msdosfs_detimes(struct denode *, const struct timespec *, const struct timespec *, const struct timespec *, int); Index: src/sys/fs/msdosfs/msdosfs_conv.c diff -u src/sys/fs/msdosfs/msdosfs_conv.c:1.8 src/sys/fs/msdosfs/msdosfs_conv.c:1.9 --- src/sys/fs/msdosfs/msdosfs_conv.c:1.8 Fri Jan 25 19:21:49 2013 +++ src/sys/fs/msdosfs/msdosfs_conv.c Sat Jan 26 11:51:51 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_conv.c,v 1.8 2013/01/26 00:21:49 christos Exp $ */ +/* $NetBSD: msdosfs_conv.c,v 1.9 2013/01/26 16:51:51 christos Exp $ */ /*- * Copyright (C) 1995, 1997 Wolfgang Solfrank. @@ -52,19 +52,22 @@ #endif #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_conv.c,v 1.8 2013/01/26 00:21:49 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_conv.c,v 1.9 2013/01/26 16:51:51 christos Exp $); /* * System include files. */ #include sys/param.h -#include sys/systm.h #include sys/time.h -#include sys/kernel.h +#ifdef _KERNEL #include sys/dirent.h +#include sys/systm.h +#include sys/kernel.h #include sys/vnode.h -#ifndef _KERNEL +#else #include stdio.h +#include dirent.h +#include sys/queue.h #endif /* @@ -722,7 +725,9 @@ win2unixfn(struct winentry *wep, struct /* * This works even though d_namlen is one byte! */ +#ifdef __NetBSD__ dp-d_namlen = (wep-weCntWIN_CNT) * WIN_CHARS; +#endif } else if (chksum != wep-weChksum) chksum = -1; if (chksum == -1) @@ -740,8 +745,10 @@ win2unixfn(struct winentry *wep, struct for (cp = wep-wePart1, i = sizeof(wep-wePart1)/2; --i = 0;) { switch (*np++ = *cp++) { case 0: +#ifdef __NetBSD__ dp-d_namlen -= sizeof(wep-wePart2)/2 + sizeof(wep-wePart3)/2 + i + 1; +#endif return chksum; case '/': np[-1] = 0; @@ -762,7 +769,9 @@ win2unixfn(struct winentry *wep, struct for (cp = wep-wePart2, i = sizeof(wep-wePart2)/2; --i = 0;) { switch (*np++ = *cp++) { case 0: +#ifdef __NetBSD__ dp-d_namlen -= sizeof(wep-wePart3)/2 + i + 1; +#endif return chksum; case '/': np[-1] = 0; @@ -783,7 +792,9 @@ win2unixfn(struct winentry *wep, struct for (cp = wep-wePart3, i = sizeof(wep-wePart3)/2; --i = 0;) { switch (*np++ = *cp++) { case 0: +#ifdef __NetBSD__ dp-d_namlen -= i + 1; +#endif return chksum; case '/': np[-1] = 0; Index: src/sys/fs/msdosfs/msdosfs_fat.c diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.24
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Sat Jan 26 16:51:51 UTC 2013 Modified Files: src/sys/fs/msdosfs: denode.h msdosfs_conv.c msdosfs_fat.c msdosfs_lookup.c msdosfsmount.h Log Message: more cross-compile friendly. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/fs/msdosfs/denode.h cvs rdiff -u -r1.8 -r1.9 src/sys/fs/msdosfs/msdosfs_conv.c cvs rdiff -u -r1.24 -r1.25 src/sys/fs/msdosfs/msdosfs_fat.c cvs rdiff -u -r1.28 -r1.29 src/sys/fs/msdosfs/msdosfs_lookup.c cvs rdiff -u -r1.18 -r1.19 src/sys/fs/msdosfs/msdosfsmount.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Sat Jan 26 19:45:02 UTC 2013 Modified Files: src/sys/fs/msdosfs: denode.h Log Message: fix fstat build. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/fs/msdosfs/denode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Sat Jan 26 00:21:49 UTC 2013 Modified Files: src/sys/fs/msdosfs: denode.h direntry.h fat.h msdosfs_conv.c msdosfs_fat.c msdosfs_lookup.c msdosfsmount.h Log Message: expose more stuff if MAKEFS is defined for the headers, and arrange for the source file to be compilable from userland. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/fs/msdosfs/denode.h cvs rdiff -u -r1.5 -r1.6 src/sys/fs/msdosfs/direntry.h cvs rdiff -u -r1.7 -r1.8 src/sys/fs/msdosfs/fat.h \ src/sys/fs/msdosfs/msdosfs_conv.c cvs rdiff -u -r1.23 -r1.24 src/sys/fs/msdosfs/msdosfs_fat.c cvs rdiff -u -r1.27 -r1.28 src/sys/fs/msdosfs/msdosfs_lookup.c cvs rdiff -u -r1.17 -r1.18 src/sys/fs/msdosfs/msdosfsmount.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/denode.h diff -u src/sys/fs/msdosfs/denode.h:1.20 src/sys/fs/msdosfs/denode.h:1.21 --- src/sys/fs/msdosfs/denode.h:1.20 Sun Nov 4 12:57:59 2012 +++ src/sys/fs/msdosfs/denode.h Fri Jan 25 19:21:49 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: denode.h,v 1.20 2012/11/04 17:57:59 jakllsch Exp $ */ +/* $NetBSD: denode.h,v 1.21 2013/01/26 00:21:49 christos Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -231,7 +231,7 @@ struct denode { #define de_forw de_chain[0] #define de_back de_chain[1] -#ifdef _KERNEL +#if defined(_KERNEL) || defined(MAKEFS) #define VTODE(vp) ((struct denode *)(vp)-v_data) #define DETOV(de) ((de)-de_vnode) @@ -287,6 +287,8 @@ int msdosfs_pathconf (void *); /* * Internal service routine prototypes. */ +struct componentname; +struct direntry; int msdosfs_update(struct vnode *, const struct timespec *, const struct timespec *, int); int createde(struct denode *, struct denode *, @@ -312,5 +314,5 @@ int msdosfs_fh_enter(struct msdosfsmount int msdosfs_fh_remove(struct msdosfsmount *, uint32_t, uint32_t); int msdosfs_fh_lookup(struct msdosfsmount *, uint32_t, uint32_t, uint32_t *); void msdosfs_fh_destroy(struct msdosfsmount *); -#endif /* _KERNEL */ +#endif /* _KERNEL || MAKEFS */ #endif /* _MSDOSFS_DENODE_H_ */ Index: src/sys/fs/msdosfs/direntry.h diff -u src/sys/fs/msdosfs/direntry.h:1.5 src/sys/fs/msdosfs/direntry.h:1.6 --- src/sys/fs/msdosfs/direntry.h:1.5 Sat Dec 3 12:34:43 2005 +++ src/sys/fs/msdosfs/direntry.h Fri Jan 25 19:21:49 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: direntry.h,v 1.5 2005/12/03 17:34:43 christos Exp $ */ +/* $NetBSD: direntry.h,v 1.6 2013/01/26 00:21:49 christos Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -120,7 +120,8 @@ struct winentry { #define DD_YEAR_MASK 0xFE00 /* year - 1980 */ #define DD_YEAR_SHIFT 9 -#ifdef _KERNEL +#if defined(_KERNEL) || defined(MAKEFS) +struct dirent; void unix2dostime(const struct timespec *tsp, int gmtoff, u_int16_t *ddp, u_int16_t *dtp, u_int8_t *dhp); void dos2unixtime(u_int dd, u_int dt, u_int dh, int gmtoff, @@ -135,5 +136,5 @@ int winChkName(const u_char *un, int unl int win2unixfn(struct winentry *wep, struct dirent *dp, int chksum); u_int8_t winChksum(u_int8_t *name); int winSlotCnt(const u_char *un, int unlen); -#endif /* _KERNEL */ +#endif /* _KERNEL || MAKEFS */ #endif /* _MSDOSFS_DIRENTRY_H_ */ Index: src/sys/fs/msdosfs/fat.h diff -u src/sys/fs/msdosfs/fat.h:1.7 src/sys/fs/msdosfs/fat.h:1.8 --- src/sys/fs/msdosfs/fat.h:1.7 Sun Nov 4 12:57:59 2012 +++ src/sys/fs/msdosfs/fat.h Fri Jan 25 19:21:49 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fat.h,v 1.7 2012/11/04 17:57:59 jakllsch Exp $ */ +/* $NetBSD: fat.h,v 1.8 2013/01/26 00:21:49 christos Exp $ */ /*- * Copyright (C) 1994, 1997 Wolfgang Solfrank. @@ -92,7 +92,7 @@ #define MSDOSFSEOF(cn, fatmask) \ (((cn) CLUST_EOFS) == (CLUST_EOFS (fatmask))) -#ifdef _KERNEL +#if defined(_KERNEL) || defined(MAKEFS) /* * These are the values for the function argument to the function * fatentry(). @@ -115,5 +115,5 @@ void fc_purge(struct denode *, u_int); void fc_lookup(struct denode *, u_long, u_long *, u_long *); int fillinusemap(struct msdosfsmount *); int freeclusterchain(struct msdosfsmount *, u_long); -#endif /* _KERNEL */ +#endif /* _KERNEL || MAKEFS */ #endif /* _MSDOSFS_FAT_H_ */ Index: src/sys/fs/msdosfs/msdosfs_conv.c diff -u src/sys/fs/msdosfs/msdosfs_conv.c:1.7 src/sys/fs/msdosfs/msdosfs_conv.c:1.8 --- src/sys/fs/msdosfs/msdosfs_conv.c:1.7 Sun Mar 15 13:15:57 2009 +++ src/sys/fs/msdosfs/msdosfs_conv.c Fri Jan 25 19:21:49 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_conv.c,v 1.7 2009/03/15 17:15:57 cegger Exp $ */ +/* $NetBSD: msdosfs_conv.c,v 1.8 2013/01/26 00:21:49 christos Exp $ */ /*- * Copyright (C) 1995, 1997 Wolfgang Solfrank. @@ -47,8 +47,12 @@ * October 1992 */ +#if HAVE_NBTOOL_CONFIG_H +#include nbtool_config.h +#endif + #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_conv.c,v 1.7 2009/03/15 17:15:57 cegger Exp $);
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: christos Date: Sat Jan 26 00:21:49 UTC 2013 Modified Files: src/sys/fs/msdosfs: denode.h direntry.h fat.h msdosfs_conv.c msdosfs_fat.c msdosfs_lookup.c msdosfsmount.h Log Message: expose more stuff if MAKEFS is defined for the headers, and arrange for the source file to be compilable from userland. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/fs/msdosfs/denode.h cvs rdiff -u -r1.5 -r1.6 src/sys/fs/msdosfs/direntry.h cvs rdiff -u -r1.7 -r1.8 src/sys/fs/msdosfs/fat.h \ src/sys/fs/msdosfs/msdosfs_conv.c cvs rdiff -u -r1.23 -r1.24 src/sys/fs/msdosfs/msdosfs_fat.c cvs rdiff -u -r1.27 -r1.28 src/sys/fs/msdosfs/msdosfs_lookup.c cvs rdiff -u -r1.17 -r1.18 src/sys/fs/msdosfs/msdosfsmount.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Fri Dec 28 08:04:00 UTC 2012 Modified Files: src/sys/fs/msdosfs: msdosfs_vnops.c Log Message: Move the initialization of n to after the error branch. From Taylor R Campbell riastr...@netbsd.org To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.85 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vnops.c diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.84 src/sys/fs/msdosfs/msdosfs_vnops.c:1.85 --- src/sys/fs/msdosfs/msdosfs_vnops.c:1.84 Thu Dec 20 08:03:42 2012 +++ src/sys/fs/msdosfs/msdosfs_vnops.c Fri Dec 28 08:03:59 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vnops.c,v 1.84 2012/12/20 08:03:42 hannken Exp $ */ +/* $NetBSD: msdosfs_vnops.c,v 1.85 2012/12/28 08:03:59 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.84 2012/12/20 08:03:42 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.85 2012/12/28 08:03:59 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -525,10 +525,10 @@ msdosfs_read(void *v) */ error = bread(pmp-pm_devvp, de_bn2kb(pmp, lbn), blsize, NOCRED, 0, bp); - n = MIN(n, pmp-pm_bpcluster - bp-b_resid); if (error) { goto bad; } + n = MIN(n, pmp-pm_bpcluster - bp-b_resid); error = uiomove((char *)bp-b_data + on, (int) n, uio); brelse(bp, 0); } while (error == 0 uio-uio_resid 0 n != 0);
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Fri Dec 28 08:04:00 UTC 2012 Modified Files: src/sys/fs/msdosfs: msdosfs_vnops.c Log Message: Move the initialization of n to after the error branch. From Taylor R Campbell riastr...@netbsd.org To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.85 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Thu Dec 20 11:44:39 UTC 2012 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: Revert rev. 1.20 now that bread() has been fixed. PR kern/46282 (6.0_BETA crash: msdosfs_bmap - pcbmap - bread - bio_doread) To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_fat.c diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.22 src/sys/fs/msdosfs/msdosfs_fat.c:1.23 --- src/sys/fs/msdosfs/msdosfs_fat.c:1.22 Thu Dec 20 08:03:42 2012 +++ src/sys/fs/msdosfs/msdosfs_fat.c Thu Dec 20 11:44:39 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_fat.c,v 1.22 2012/12/20 08:03:42 hannken Exp $ */ +/* $NetBSD: msdosfs_fat.c,v 1.23 2012/12/20 11:44:39 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.22 2012/12/20 08:03:42 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.23 2012/12/20 11:44:39 hannken Exp $); /* * kernel include files. @@ -254,26 +254,10 @@ pcbmap(struct denode *dep, u_long findcn if (bn != bp_bn) { if (bp) brelse(bp, 0); - bp = getblk(pmp-pm_devvp, de_bn2kb(pmp, bn), bsize, - 0, 0); - if (bp == NULL) { -/* - * getblk() above returns NULL only iff we are - * pagedaemon. See the implementation of getblk - * for detail. - */ -return ENOMEM; - } - if (!ISSET(bp-b_oflags, (BO_DONE | BO_DELWRI))) { -SET(bp-b_flags, B_READ); -BIO_SETPRIO(bp, BPRIO_TIMECRITICAL); -VOP_STRATEGY(pmp-pm_devvp, bp); -curlwp-l_ru.ru_inblock++; -error = biowait(bp); -if (error) { - brelse(bp, 0); - return error; -} + error = bread(pmp-pm_devvp, de_bn2kb(pmp, bn), bsize, + NOCRED, 0, bp); + if (error) { +return (error); } bp_bn = bn; }
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Thu Dec 20 11:44:39 UTC 2012 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: Revert rev. 1.20 now that bread() has been fixed. PR kern/46282 (6.0_BETA crash: msdosfs_bmap - pcbmap - bread - bio_doread) To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.