CVS commit: src/sbin/fsck
Module Name:src Committed By: mlelstv Date: Tue Jan 24 08:09:38 UTC 2023 Modified Files: src/sbin/fsck: fsck.c Log Message: Use opendisk when looking for filesystem type, otherwise the detection only works if the correct device path is given as an argument. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sbin/fsck/fsck.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/fsck/fsck.c diff -u src/sbin/fsck/fsck.c:1.52 src/sbin/fsck/fsck.c:1.53 --- src/sbin/fsck/fsck.c:1.52 Sat Oct 25 22:00:19 2014 +++ src/sbin/fsck/fsck.c Tue Jan 24 08:09:37 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fsck.c,v 1.52 2014/10/25 22:00:19 mlelstv Exp $ */ +/* $NetBSD: fsck.c,v 1.53 2023/01/24 08:09:37 mlelstv Exp $ */ /* * Copyright (c) 1996 Christos Zoulas. All rights reserved. @@ -36,7 +36,7 @@ #include #ifndef lint -__RCSID("$NetBSD: fsck.c,v 1.52 2014/10/25 22:00:19 mlelstv Exp $"); +__RCSID("$NetBSD: fsck.c,v 1.53 2023/01/24 08:09:37 mlelstv Exp $"); #endif /* not lint */ #include @@ -557,10 +557,11 @@ getfslab(const char *str) char p; const char *vfstype; u_char t; + char buf[MAXPATHLEN]; /* deduce the file system type from the disk label */ - if ((fd = open(str, O_RDONLY)) == -1) - err(1, "cannot open `%s'", str); +if ((fd = opendisk(str, O_RDONLY, buf, sizeof(buf), 0)) == -1) + err(1, "cannot open `%s'", buf); /* First check to see if it's a wedge. */ if (ioctl(fd, DIOCGWEDGEINFO, &dkw) == 0) { @@ -570,22 +571,22 @@ getfslab(const char *str) } if (ioctl(fd, DIOCGDINFO, &dl) == -1) - err(1, "cannot get disklabel for `%s'", str); + err(1, "cannot get disklabel for `%s'", buf); (void) close(fd); - p = str[strlen(str) - 1]; + p = buf[strlen(buf) - 1]; if ((p - 'a') >= dl.d_npartitions) - errx(1, "partition `%s' is not defined on disk", str); + errx(1, "partition `%s' is not defined on disk", buf); if ((t = dl.d_partitions[p - 'a'].p_fstype) >= FSMAXTYPES) errx(1, "partition `%s' is not of a legal vfstype", - str); + buf); if ((vfstype = fscknames[t]) == NULL) errx(1, "vfstype `%s' on partition `%s' is not supported", - fstypenames[t], str); + fstypenames[t], buf); return vfstype; }
CVS commit: src/sbin/fsck
Module Name:src Committed By: mlelstv Date: Tue Jan 24 08:09:38 UTC 2023 Modified Files: src/sbin/fsck: fsck.c Log Message: Use opendisk when looking for filesystem type, otherwise the detection only works if the correct device path is given as an argument. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sbin/fsck/fsck.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/fsck
Module Name:src Committed By: hannken Date: Mon Jan 2 16:08:13 UTC 2023 Modified Files: src/sbin/fsck: partutil.c Log Message: Change getdiskinfo() to no longer infer the partition from the device name. Since 2016-06-16 we create disk devices "<" as an alias for "<" where "" is the raw partition. These devices are treated as invalid partitions and a zero geometry is returned. Take the partition from "st_rdev" instead. Fix for PR kern/57134: st_size of stat on vnd raw partition sometimes is 0, causing newfs to fail To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sbin/fsck/partutil.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/fsck/partutil.c diff -u src/sbin/fsck/partutil.c:1.17 src/sbin/fsck/partutil.c:1.18 --- src/sbin/fsck/partutil.c:1.17 Sat Sep 28 18:03:18 2019 +++ src/sbin/fsck/partutil.c Mon Jan 2 16:08:13 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: partutil.c,v 1.17 2019/09/28 18:03:18 bad Exp $ */ +/* $NetBSD: partutil.c,v 1.18 2023/01/02 16:08:13 hannken Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: partutil.c,v 1.17 2019/09/28 18:03:18 bad Exp $"); +__RCSID("$NetBSD: partutil.c,v 1.18 2023/01/02 16:08:13 hannken Exp $"); #include #include @@ -155,9 +155,8 @@ getdiskinfo(const char *s, int fd, const if (stat(s, &sb) == -1) return 0; - ptn = strchr(s, '\0')[-1] - 'a'; - if ((unsigned)ptn >= lp->d_npartitions || - (devminor_t)ptn != DISKPART(sb.st_rdev)) + ptn = DISKPART(sb.st_rdev); + if (ptn < 0 || ptn >= lp->d_npartitions) return 0; pp = &lp->d_partitions[ptn];
CVS commit: src/sbin/fsck
Module Name:src Committed By: hannken Date: Mon Jan 2 16:08:13 UTC 2023 Modified Files: src/sbin/fsck: partutil.c Log Message: Change getdiskinfo() to no longer infer the partition from the device name. Since 2016-06-16 we create disk devices "<" as an alias for "<" where "" is the raw partition. These devices are treated as invalid partitions and a zero geometry is returned. Take the partition from "st_rdev" instead. Fix for PR kern/57134: st_size of stat on vnd raw partition sometimes is 0, causing newfs to fail To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sbin/fsck/partutil.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/fsck
Module Name:src Committed By: bad Date: Sat Sep 28 18:03:19 UTC 2019 Modified Files: src/sbin/fsck: partutil.c Log Message: initialize disc_dict to NULL. otherwise, if DIOCGDISKINFO returns an error != ENXIO getdiskinfo() later tries to prop_object_release() stack garbage. found by rumpctrl tests using clang-7. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sbin/fsck/partutil.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/fsck
Module Name:src Committed By: bad Date: Sat Sep 28 18:03:19 UTC 2019 Modified Files: src/sbin/fsck: partutil.c Log Message: initialize disc_dict to NULL. otherwise, if DIOCGDISKINFO returns an error != ENXIO getdiskinfo() later tries to prop_object_release() stack garbage. found by rumpctrl tests using clang-7. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sbin/fsck/partutil.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/fsck/partutil.c diff -u src/sbin/fsck/partutil.c:1.16 src/sbin/fsck/partutil.c:1.17 --- src/sbin/fsck/partutil.c:1.16 Sun Aug 18 11:08:56 2019 +++ src/sbin/fsck/partutil.c Sat Sep 28 18:03:18 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: partutil.c,v 1.16 2019/08/18 11:08:56 martin Exp $ */ +/* $NetBSD: partutil.c,v 1.17 2019/09/28 18:03:18 bad Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: partutil.c,v 1.16 2019/08/18 11:08:56 martin Exp $"); +__RCSID("$NetBSD: partutil.c,v 1.17 2019/09/28 18:03:18 bad Exp $"); #include #include @@ -108,6 +108,7 @@ getdiskinfo(const char *s, int fd, const } /* Get disk description dictionary */ + disk_dict = NULL; error = prop_dictionary_recv_ioctl(fd, DIOCGDISKINFO, &disk_dict); /* fail quickly if the device does not exist at all */
CVS commit: src/sbin/fsck
Module Name:src Committed By: martin Date: Sun Aug 18 11:08:57 UTC 2019 Modified Files: src/sbin/fsck: partutil.c Log Message: Properly release the disk properties dictionary we received via ioctl. Detected by leak sanitizer when building with MKSANITIZER=yes. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sbin/fsck/partutil.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/fsck/partutil.c diff -u src/sbin/fsck/partutil.c:1.15 src/sbin/fsck/partutil.c:1.16 --- src/sbin/fsck/partutil.c:1.15 Wed Jun 3 17:53:23 2015 +++ src/sbin/fsck/partutil.c Sun Aug 18 11:08:56 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: partutil.c,v 1.15 2015/06/03 17:53:23 martin Exp $ */ +/* $NetBSD: partutil.c,v 1.16 2019/08/18 11:08:56 martin Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: partutil.c,v 1.15 2015/06/03 17:53:23 martin Exp $"); +__RCSID("$NetBSD: partutil.c,v 1.16 2019/08/18 11:08:56 martin Exp $"); #include #include @@ -131,6 +131,8 @@ getdiskinfo(const char *s, int fd, const geom_dict = prop_dictionary_get(disk_dict, "geometry"); dict2geom(geo, geom_dict); } + if (disk_dict != NULL) + prop_object_release(disk_dict); if (dkw == NULL) return 0;
CVS commit: src/sbin/fsck
Module Name:src Committed By: martin Date: Sun Aug 18 11:08:57 UTC 2019 Modified Files: src/sbin/fsck: partutil.c Log Message: Properly release the disk properties dictionary we received via ioctl. Detected by leak sanitizer when building with MKSANITIZER=yes. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sbin/fsck/partutil.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/fsck
Module Name:src Committed By: christos Date: Sat Mar 6 00:30:54 UTC 2010 Modified Files: src/sbin/fsck: partutil.c Log Message: - use warn/err properly - wrap long lines To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sbin/fsck/partutil.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/fsck/partutil.c diff -u src/sbin/fsck/partutil.c:1.9 src/sbin/fsck/partutil.c:1.10 --- src/sbin/fsck/partutil.c:1.9 Thu Jul 16 19:50:32 2009 +++ src/sbin/fsck/partutil.c Fri Mar 5 19:30:54 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: partutil.c,v 1.9 2009/07/16 23:50:32 dyoung Exp $ */ +/* $NetBSD: partutil.c,v 1.10 2010/03/06 00:30:54 christos Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: partutil.c,v 1.9 2009/07/16 23:50:32 dyoung Exp $"); +__RCSID("$NetBSD: partutil.c,v 1.10 2010/03/06 00:30:54 christos Exp $"); #include #include @@ -76,12 +76,16 @@ static void dict2geom(struct disk_geom *geo, prop_dictionary_t dict) { - memset(geo, 0, sizeof(struct disk_geom)); - prop_dictionary_get_int64(dict, "sectors-per-unit", &geo->dg_secperunit); + (void)memset(geo, 0, sizeof(struct disk_geom)); + prop_dictionary_get_int64(dict, "sectors-per-unit", + &geo->dg_secperunit); prop_dictionary_get_uint32(dict, "sector-size", &geo->dg_secsize); - prop_dictionary_get_uint32(dict, "sectors-per-track", &geo->dg_nsectors); - prop_dictionary_get_uint32(dict, "tracks-per-cylinder", &geo->dg_ntracks); - prop_dictionary_get_uint32(dict, "cylinders-per-unit", &geo->dg_ncylinders); + prop_dictionary_get_uint32(dict, "sectors-per-track", + &geo->dg_nsectors); + prop_dictionary_get_uint32(dict, "tracks-per-cylinder", + &geo->dg_ntracks); + prop_dictionary_get_uint32(dict, "cylinders-per-unit", + &geo->dg_ncylinders); } @@ -159,7 +163,7 @@ if (dt) { lp = getdiskbyname(dt); if (lp == NULL) - errx(1, "%s: unknown disk type", dt); + errx(1, "unknown disk type `%s'", dt); } /* Get disk description dictionary */ @@ -171,7 +175,7 @@ * cgd, ccd pseudo disk drives doesn't support DIOCGDDISKINFO */ if (ioctl(fd, DIOCGDINFO, lp) == -1) { - printf("DIOCGDINFO on %s failed\n", s); + warn("DIOCGDINFO on %s failed", s); return -1; } label2geom(geo, lp); @@ -183,8 +187,8 @@ /* Get info about partition/wedge */ if (ioctl(fd, DIOCGWEDGEINFO, dkw) == -1) { if (ioctl(fd, DIOCGDINFO, lp) == -1) - errx(errno, "Please implement DIOCGWEDGEINFO or " - "DIOCGDINFO for disk device %s\n", s); + err(1, "Please implement DIOCGWEDGEINFO or " + "DIOCGDINFO for disk device %s", s); part2wedge(dkw, lp, s); }
CVS commit: src/sbin/fsck
Module Name:src Committed By: christos Date: Sat Mar 6 00:30:54 UTC 2010 Modified Files: src/sbin/fsck: partutil.c Log Message: - use warn/err properly - wrap long lines To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sbin/fsck/partutil.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/fsck
Module Name:src Committed By: hannken Date: Wed Feb 24 13:56:07 UTC 2010 Modified Files: src/sbin/fsck: fsck.c Log Message: Dont pass option -x down to fsck_xxxfs. Hi christos ... To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sbin/fsck/fsck.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/fsck
Module Name:src Committed By: wiz Date: Thu Feb 18 06:57:18 UTC 2010 Modified Files: src/sbin/fsck: fsck.8 Log Message: Use Dq for double quotes; remove trailing whitespace. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sbin/fsck/fsck.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/fsck
Module Name:src Committed By: christos Date: Wed Feb 17 23:30:21 UTC 2010 Modified Files: src/sbin/fsck: fsck.8 fsck.c Log Message: Add -x ``exclude'' option. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sbin/fsck/fsck.8 cvs rdiff -u -r1.47 -r1.48 src/sbin/fsck/fsck.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.