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, ) == 0) { @@ -570,22 +571,22 @@ getfslab(const char *str) } if (ioctl(fd, DIOCGDINFO, ) == -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, ) == -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 = >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: sevan Date: Sat Apr 18 22:02:11 UTC 2020 Modified Files: src/sbin/fsck: fsck.8 Log Message: grammar To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sbin/fsck/fsck.8 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.8 diff -u src/sbin/fsck/fsck.8:1.40 src/sbin/fsck/fsck.8:1.41 --- src/sbin/fsck/fsck.8:1.40 Sun Sep 11 09:09:54 2016 +++ src/sbin/fsck/fsck.8 Sat Apr 18 22:02:11 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: fsck.8,v 1.40 2016/09/11 09:09:54 wiz Exp $ +.\" $NetBSD: fsck.8,v 1.41 2020/04/18 22:02:11 sevan Exp $ .\" .\" Copyright (c) 1996 Christos Zoulas. All rights reserved. .\" @@ -22,7 +22,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd September 11, 2016 +.Dd April 18, 2020 .Dt FSCK 8 .Os .Sh NAME @@ -175,7 +175,7 @@ from the terminal). .Xr fsck_msdos 8 , .Xr mount 8 .Sh HISTORY -A +An .Nm utility appeared in .Bx 4.0 .
CVS commit: src/sbin/fsck
Module Name:src Committed By: sevan Date: Sat Apr 18 22:02:11 UTC 2020 Modified Files: src/sbin/fsck: fsck.8 Log Message: grammar To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 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: 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, _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.
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: wiz Date: Sun Sep 11 09:09:54 UTC 2016 Modified Files: src/sbin/fsck: fsck.8 Log Message: file system police. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sbin/fsck/fsck.8 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.8 diff -u src/sbin/fsck/fsck.8:1.39 src/sbin/fsck/fsck.8:1.40 --- src/sbin/fsck/fsck.8:1.39 Sun Sep 11 03:48:11 2016 +++ src/sbin/fsck/fsck.8 Sun Sep 11 09:09:54 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: fsck.8,v 1.39 2016/09/11 03:48:11 sevan Exp $ +.\" $NetBSD: fsck.8,v 1.40 2016/09/11 09:09:54 wiz Exp $ .\" .\" Copyright (c) 1996 Christos Zoulas. All rights reserved. .\" @@ -98,7 +98,7 @@ will check all file systems listed in according to their pass number, and will make minor repairs without human intervention. .It Fl q -Quiet mode, do not output any messages for clean filesystems. +Quiet mode, do not output any messages for clean file systems. .It Fl T Ar fstype:fsoptions List of comma separated file system specific options for the specified file system type, in the same format as @@ -115,7 +115,7 @@ for the file system types that are not s .It Fl v Print the commands before executing them. .It Fl x Ar mountpoint -Exclude the filesystem which has a +Exclude the file system which has a .Ar mountpoint the same as in .Pa /etc/fstab . @@ -148,16 +148,16 @@ intervention is required. .It Dv 1 Usage problem. .It Dv 2 -Unresolved errors while checking the filesystem. +Unresolved errors while checking the file system. Re-running .Nm -on the filesystem(s) is required. +on the file system(s) is required. .It Dv 4 -The root filesystem was changed in the process of checking, and updating the +The root file system was changed in the process of checking, and updating the mount was unsuccessful. A reboot (without sync) is required. .It Dv 8 -The filesystem check has failed, and a subsequent check is required +The file system check has failed, and a subsequent check is required that will require human intervention. .It Dv 12 .Nm @@ -179,8 +179,8 @@ A .Nm utility appeared in .Bx 4.0 . -It was reimplemented as a filesystem independent wrapper in +It was reimplemented as a file system independent wrapper in .Nx 1.3 . -The original filesystem specific utility became +The original file system specific utility became .Xr fsck_ffs 8 at this point.
CVS commit: src/sbin/fsck
Module Name:src Committed By: wiz Date: Sun Sep 11 09:09:54 UTC 2016 Modified Files: src/sbin/fsck: fsck.8 Log Message: file system police. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 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: sevan Date: Sun Sep 11 03:48:11 UTC 2016 Modified Files: src/sbin/fsck: fsck.8 Log Message: Document the version fsck first appeared. Bump date. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 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: sevan Date: Sun Sep 11 03:48:11 UTC 2016 Modified Files: src/sbin/fsck: fsck.8 Log Message: Document the version fsck first appeared. Bump date. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sbin/fsck/fsck.8 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.8 diff -u src/sbin/fsck/fsck.8:1.38 src/sbin/fsck/fsck.8:1.39 --- src/sbin/fsck/fsck.8:1.38 Thu Apr 28 12:16:10 2011 +++ src/sbin/fsck/fsck.8 Sun Sep 11 03:48:11 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: fsck.8,v 1.38 2011/04/28 12:16:10 wiz Exp $ +.\" $NetBSD: fsck.8,v 1.39 2016/09/11 03:48:11 sevan Exp $ .\" .\" Copyright (c) 1996 Christos Zoulas. All rights reserved. .\" @@ -22,7 +22,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd February 17, 2010 +.Dd September 11, 2016 .Dt FSCK 8 .Os .Sh NAME @@ -174,3 +174,13 @@ from the terminal). .Xr fsck_lfs 8 , .Xr fsck_msdos 8 , .Xr mount 8 +.Sh HISTORY +A +.Nm +utility appeared in +.Bx 4.0 . +It was reimplemented as a filesystem independent wrapper in +.Nx 1.3 . +The original filesystem specific utility became +.Xr fsck_ffs 8 +at this point.
CVS commit: src/sbin/fsck
Module Name:src Committed By: dholland Date: Sun Jun 21 03:33:22 UTC 2015 Modified Files: src/sbin/fsck: exitvalues.h Log Message: add missing rcsid To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sbin/fsck/exitvalues.h 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/exitvalues.h diff -u src/sbin/fsck/exitvalues.h:1.2 src/sbin/fsck/exitvalues.h:1.3 --- src/sbin/fsck/exitvalues.h:1.2 Mon Apr 28 20:23:08 2008 +++ src/sbin/fsck/exitvalues.h Sun Jun 21 03:33:22 2015 @@ -1,3 +1,4 @@ +/* $NetBSD: exitvalues.h,v 1.3 2015/06/21 03:33:22 dholland Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. @@ -26,6 +27,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ + #define FSCK_EXIT_OK 0 #define FSCK_EXIT_USAGE 1 #define FSCK_EXIT_UNRESOLVED 2
CVS commit: src/sbin/fsck
Module Name:src Committed By: dholland Date: Sun Jun 21 03:33:22 UTC 2015 Modified Files: src/sbin/fsck: exitvalues.h Log Message: add missing rcsid To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sbin/fsck/exitvalues.h 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: dholland Date: Sun Jun 21 04:01:40 UTC 2015 Modified Files: src/sbin/fsck: fsutil.c preen.c Log Message: Add used-by comments on source files that are .PATH'd in from elsewhere. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sbin/fsck/fsutil.c cvs rdiff -u -r1.31 -r1.32 src/sbin/fsck/preen.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: dholland Date: Sun Jun 21 04:01:40 UTC 2015 Modified Files: src/sbin/fsck: fsutil.c preen.c Log Message: Add used-by comments on source files that are .PATH'd in from elsewhere. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sbin/fsck/fsutil.c cvs rdiff -u -r1.31 -r1.32 src/sbin/fsck/preen.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/fsutil.c diff -u src/sbin/fsck/fsutil.c:1.25 src/sbin/fsck/fsutil.c:1.26 --- src/sbin/fsck/fsutil.c:1.25 Sun Jun 21 03:58:36 2015 +++ src/sbin/fsck/fsutil.c Sun Jun 21 04:01:40 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: fsutil.c,v 1.25 2015/06/21 03:58:36 dholland Exp $ */ +/* $NetBSD: fsutil.c,v 1.26 2015/06/21 04:01:40 dholland Exp $ */ /* * Copyright (c) 1990, 1993 @@ -31,9 +31,20 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: fsutil.c,v 1.25 2015/06/21 03:58:36 dholland Exp $); +__RCSID($NetBSD: fsutil.c,v 1.26 2015/06/21 04:01:40 dholland Exp $); #endif /* not lint */ +/* + * used by sbin/fsck + * used by sbin/fsck_ext2fs + * used by sbin/fsck_ffs + * used by sbin/fsck_lfs + * used by sbin/fsck_msdos + * used by sbin/fsck_v7fs + * used by sbin/fsdb + * used by usr.sbin/quotacheck + */ + #include sys/param.h #include stdio.h Index: src/sbin/fsck/preen.c diff -u src/sbin/fsck/preen.c:1.31 src/sbin/fsck/preen.c:1.32 --- src/sbin/fsck/preen.c:1.31 Sat Apr 7 04:52:20 2012 +++ src/sbin/fsck/preen.c Sun Jun 21 04:01:40 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: preen.c,v 1.31 2012/04/07 04:52:20 christos Exp $ */ +/* $NetBSD: preen.c,v 1.32 2015/06/21 04:01:40 dholland Exp $ */ /* * Copyright (c) 1990, 1993 @@ -34,10 +34,15 @@ #if 0 static char sccsid[] = @(#)preen.c 8.5 (Berkeley) 4/28/95; #else -__RCSID($NetBSD: preen.c,v 1.31 2012/04/07 04:52:20 christos Exp $); +__RCSID($NetBSD: preen.c,v 1.32 2015/06/21 04:01:40 dholland Exp $); #endif #endif /* not lint */ +/* + * used by sbin/fsck + * used by usr.sbin/quotacheck + */ + #include sys/param.h #include sys/stat.h #include sys/wait.h
CVS commit: src/sbin/fsck
Module Name:src Committed By: dholland Date: Sun Jun 21 03:58:36 UTC 2015 Modified Files: src/sbin/fsck: fsutil.c fsutil.h Log Message: global variables should be declared extern. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sbin/fsck/fsutil.c cvs rdiff -u -r1.19 -r1.20 src/sbin/fsck/fsutil.h 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/fsutil.c diff -u src/sbin/fsck/fsutil.c:1.24 src/sbin/fsck/fsutil.c:1.25 --- src/sbin/fsck/fsutil.c:1.24 Sun Jan 13 19:53:16 2013 +++ src/sbin/fsck/fsutil.c Sun Jun 21 03:58:36 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: fsutil.c,v 1.24 2013/01/13 19:53:16 mlelstv Exp $ */ +/* $NetBSD: fsutil.c,v 1.25 2015/06/21 03:58:36 dholland Exp $ */ /* * Copyright (c) 1990, 1993 @@ -31,7 +31,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: fsutil.c,v 1.24 2013/01/13 19:53:16 mlelstv Exp $); +__RCSID($NetBSD: fsutil.c,v 1.25 2015/06/21 03:58:36 dholland Exp $); #endif /* not lint */ #include sys/param.h @@ -53,6 +53,8 @@ __RCSID($NetBSD: fsutil.c,v 1.24 2013/0 #include fsutil.h #include exitvalues.h +volatile sig_atomic_t returntosingle; + static const char *dev = NULL; static int hot = 0; static int preen = 0; Index: src/sbin/fsck/fsutil.h diff -u src/sbin/fsck/fsutil.h:1.19 src/sbin/fsck/fsutil.h:1.20 --- src/sbin/fsck/fsutil.h:1.19 Sat Apr 7 16:44:10 2012 +++ src/sbin/fsck/fsutil.h Sun Jun 21 03:58:36 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: fsutil.h,v 1.19 2012/04/07 16:44:10 christos Exp $ */ +/* $NetBSD: fsutil.h,v 1.20 2015/06/21 03:58:36 dholland Exp $ */ /* * Copyright (c) 1996 Christos Zoulas. All rights reserved. @@ -51,7 +51,7 @@ int checkfstab(int, int, void *(*)(struc int (*) (const char *, const char *, const char *, void *, pid_t *)); void (*ckfinish)(int); -volatile sig_atomic_t returntosingle; +extern volatile sig_atomic_t returntosingle; void catch(int) __dead; void catchquit(int); void voidquit(int);
CVS commit: src/sbin/fsck
Module Name:src Committed By: dholland Date: Sun Jun 21 03:58:36 UTC 2015 Modified Files: src/sbin/fsck: fsutil.c fsutil.h Log Message: global variables should be declared extern. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sbin/fsck/fsutil.c cvs rdiff -u -r1.19 -r1.20 src/sbin/fsck/fsutil.h 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: martin Date: Wed Jun 3 17:53:23 UTC 2015 Modified Files: src/sbin/fsck: partutil.c Log Message: Make querying the disk geometry fail silently if called for a non-exitent disk. XXX: DIOCGDISKINFO returns strange error codes To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 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.14 src/sbin/fsck/partutil.c:1.15 --- src/sbin/fsck/partutil.c:1.14 Mon Dec 29 16:35:38 2014 +++ src/sbin/fsck/partutil.c Wed Jun 3 17:53:23 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: partutil.c,v 1.14 2014/12/29 16:35:38 christos Exp $ */ +/* $NetBSD: partutil.c,v 1.15 2015/06/03 17:53:23 martin Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: partutil.c,v 1.14 2014/12/29 16:35:38 christos Exp $); +__RCSID($NetBSD: partutil.c,v 1.15 2015/06/03 17:53:23 martin Exp $); #include sys/types.h #include sys/param.h @@ -99,7 +99,7 @@ getdiskinfo(const char *s, int fd, const prop_dictionary_t disk_dict, geom_dict; struct stat sb; const struct partition *pp; - int ptn; + int ptn, error; if (dt) { lp = getdiskbyname(dt); @@ -108,7 +108,13 @@ getdiskinfo(const char *s, int fd, const } /* Get disk description dictionary */ - if (prop_dictionary_recv_ioctl(fd, DIOCGDISKINFO, disk_dict)) { + error = prop_dictionary_recv_ioctl(fd, DIOCGDISKINFO, disk_dict); + + /* fail quickly if the device does not exist at all */ + if (error == ENXIO) + return -1; + + if (error) { /* * Ask for disklabel if DIOCGDISKINFO failed. This is * compatibility call and can be removed when all devices @@ -116,7 +122,8 @@ getdiskinfo(const char *s, int fd, const * cgd, ccd pseudo disk drives doesn't support DIOCGDDISKINFO */ if (ioctl(fd, DIOCGDINFO, lp) == -1) { - warn(DIOCGDINFO on %s failed, s); + if (errno != ENXIO) +warn(DIOCGDINFO on %s failed, s); return -1; } label2geom(geo, lp);
CVS commit: src/sbin/fsck
Module Name:src Committed By: martin Date: Wed Jun 3 17:53:23 UTC 2015 Modified Files: src/sbin/fsck: partutil.c Log Message: Make querying the disk geometry fail silently if called for a non-exitent disk. XXX: DIOCGDISKINFO returns strange error codes To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 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: Mon Dec 29 16:27:43 UTC 2014 Modified Files: src/sbin/fsck: partutil.c partutil.h Log Message: Provide a simple getdisksize() api for gpt(8). To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sbin/fsck/partutil.c cvs rdiff -u -r1.2 -r1.3 src/sbin/fsck/partutil.h 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.12 src/sbin/fsck/partutil.c:1.13 --- src/sbin/fsck/partutil.c:1.12 Sat Apr 13 18:08:57 2013 +++ src/sbin/fsck/partutil.c Mon Dec 29 11:27:43 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: partutil.c,v 1.12 2013/04/13 22:08:57 jakllsch Exp $ */ +/* $NetBSD: partutil.c,v 1.13 2014/12/29 16:27:43 christos Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -30,9 +30,10 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: partutil.c,v 1.12 2013/04/13 22:08:57 jakllsch Exp $); +__RCSID($NetBSD: partutil.c,v 1.13 2014/12/29 16:27:43 christos Exp $); #include sys/types.h +#include sys/param.h #include sys/disklabel.h #include sys/disk.h #include sys/ioctl.h @@ -135,8 +136,10 @@ getdiskinfo(const char *s, int fd, const DIOCGDINFO for disk device %s, s); } - /* DIOCGDINFO didn't fail */ + if (dkw == NULL) + return 0; + /* DIOCGDINFO didn't fail */ (void)memset(dkw, 0, sizeof(*dkw)); if (stat(s, sb) == -1) @@ -161,3 +164,23 @@ getdiskinfo(const char *s, int fd, const return 0; } + +int +getdisksize(const char *name, u_int *secsize, off_t *mediasize) +{ + char buf[MAXPATHLEN]; + struct disk_geom geo; + int fd, error; + + if ((fd = opendisk(name, O_RDONLY, buf, sizeof(buf), 0)) == -1) + return -1; + + error = getdiskinfo(name, fd, NULL, geo, NULL); + close(fd); + if (error) + return error; + + *secsize = geo.dg_secsize; + *mediasize = geo.dg_secsize * geo.dg_secperunit; + return 0; +} Index: src/sbin/fsck/partutil.h diff -u src/sbin/fsck/partutil.h:1.2 src/sbin/fsck/partutil.h:1.3 --- src/sbin/fsck/partutil.h:1.2 Mon Apr 28 16:23:08 2008 +++ src/sbin/fsck/partutil.h Mon Dec 29 11:27:43 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: partutil.h,v 1.2 2008/04/28 20:23:08 martin Exp $ */ +/* $NetBSD: partutil.h,v 1.3 2014/12/29 16:27:43 christos Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -32,8 +32,11 @@ #define _PARTUTIL_H_ __BEGIN_DECLS +struct dkwedge_info; +struct disk_geom; int getdiskinfo(const char *, int, const char *, struct disk_geom *, struct dkwedge_info *); +int getdisksize(const char *, u_int *, off_t *); __END_DECLS #endif /* _PARTUTIL_H_ */
CVS commit: src/sbin/fsck
Module Name:src Committed By: christos Date: Mon Dec 29 16:35:38 UTC 2014 Modified Files: src/sbin/fsck: partutil.c Log Message: abort earlier. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 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.13 src/sbin/fsck/partutil.c:1.14 --- src/sbin/fsck/partutil.c:1.13 Mon Dec 29 11:27:43 2014 +++ src/sbin/fsck/partutil.c Mon Dec 29 11:35:38 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: partutil.c,v 1.13 2014/12/29 16:27:43 christos Exp $ */ +/* $NetBSD: partutil.c,v 1.14 2014/12/29 16:35:38 christos Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: partutil.c,v 1.13 2014/12/29 16:27:43 christos Exp $); +__RCSID($NetBSD: partutil.c,v 1.14 2014/12/29 16:35:38 christos Exp $); #include sys/types.h #include sys/param.h @@ -125,6 +125,9 @@ getdiskinfo(const char *s, int fd, const dict2geom(geo, geom_dict); } + if (dkw == NULL) + return 0; + /* Get info about partition/wedge */ if (ioctl(fd, DIOCGWEDGEINFO, dkw) != -1) { /* DIOCGWEDGEINFO didn't fail, we're done */ @@ -136,9 +139,6 @@ getdiskinfo(const char *s, int fd, const DIOCGDINFO for disk device %s, s); } - if (dkw == NULL) - return 0; - /* DIOCGDINFO didn't fail */ (void)memset(dkw, 0, sizeof(*dkw));
CVS commit: src/sbin/fsck
Module Name:src Committed By: christos Date: Mon Dec 29 16:27:43 UTC 2014 Modified Files: src/sbin/fsck: partutil.c partutil.h Log Message: Provide a simple getdisksize() api for gpt(8). To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sbin/fsck/partutil.c cvs rdiff -u -r1.2 -r1.3 src/sbin/fsck/partutil.h 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: Mon Dec 29 16:35:38 UTC 2014 Modified Files: src/sbin/fsck: partutil.c Log Message: abort earlier. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 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: mlelstv Date: Sat Oct 25 22:00:19 UTC 2014 Modified Files: src/sbin/fsck: fsck.c Log Message: fix logic that handles command line arguments. Now you can: fsck /mnt/point fsck dkX fsck rdkX fsck /dev/dkX fsck /dev/rdkX fsck NAME=wedge To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 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.51 src/sbin/fsck/fsck.c:1.52 --- src/sbin/fsck/fsck.c:1.51 Sat Apr 7 04:52:20 2012 +++ src/sbin/fsck/fsck.c Sat Oct 25 22:00:19 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: fsck.c,v 1.51 2012/04/07 04:52:20 christos Exp $ */ +/* $NetBSD: fsck.c,v 1.52 2014/10/25 22:00:19 mlelstv Exp $ */ /* * Copyright (c) 1996 Christos Zoulas. All rights reserved. @@ -36,7 +36,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: fsck.c,v 1.51 2012/04/07 04:52:20 christos Exp $); +__RCSID($NetBSD: fsck.c,v 1.52 2014/10/25 22:00:19 mlelstv Exp $); #endif /* not lint */ #include sys/param.h @@ -196,23 +196,30 @@ main(int argc, char *argv[]) for (; argc--; argv++) { - const char *spec, *type, *cp; + const char *spec, *spec2, *mntpt, *type, *cp; char device[MAXPATHLEN]; - spec = *argv; - cp = strrchr(spec, '/'); + spec = mntpt = *argv; + spec2 = getfsspecname(buf, sizeof(buf), spec); + if (spec2 == NULL) + spec2 = spec; + + cp = strrchr(spec2, '/'); if (cp == 0) { (void)snprintf(device, sizeof(device), %s%s, -_PATH_DEV, spec); - spec = device; +_PATH_DEV, spec2); + spec2 = device; } - if ((fs = getfsfile(spec)) == NULL - (fs = getfsspec(spec)) == NULL) { - if (vfstype == NULL) -vfstype = getfslab(spec); - type = vfstype; + + fs = getfsfile(spec); + if (fs == NULL) + fs = getfsspec(spec); + if (fs == NULL spec != spec2) { + fs = getfsspec(spec2); + spec = spec2; } - else { + + if (fs) { spec = getfsspecname(buf, sizeof(buf), fs-fs_spec); if (spec == NULL) err(FSCK_EXIT_CHECK_FAILED, %s, buf); @@ -221,6 +228,10 @@ main(int argc, char *argv[]) errx(FSCK_EXIT_CHECK_FAILED, %s has unknown file system type., spec); + } else { + if (vfstype == NULL) +vfstype = getfslab(spec); + type = vfstype; } rval = checkfs(type, blockcheck(spec), *argv, NULL, NULL);
CVS commit: src/sbin/fsck
Module Name:src Committed By: mlelstv Date: Sat Oct 25 22:00:19 UTC 2014 Modified Files: src/sbin/fsck: fsck.c Log Message: fix logic that handles command line arguments. Now you can: fsck /mnt/point fsck dkX fsck rdkX fsck /dev/dkX fsck /dev/rdkX fsck NAME=wedge To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 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: jakllsch Date: Sat Apr 13 22:08:58 UTC 2013 Modified Files: src/sbin/fsck: partutil.c Log Message: Make getdiskinfo() always return correct dkwedge_info for the raw partition. A real disk's raw partition does not implement DIOCGWEDGEINFO, but does implement DIOCGDINFO. This was resulting in the returned wedge information containing 32-bit-clamped values for size of the raw partition, with no indication thereof. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 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.11 src/sbin/fsck/partutil.c:1.12 --- src/sbin/fsck/partutil.c:1.11 Sun Nov 13 22:04:51 2011 +++ src/sbin/fsck/partutil.c Sat Apr 13 22:08:57 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: partutil.c,v 1.11 2011/11/13 22:04:51 christos Exp $ */ +/* $NetBSD: partutil.c,v 1.12 2013/04/13 22:08:57 jakllsch Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: partutil.c,v 1.11 2011/11/13 22:04:51 christos Exp $); +__RCSID($NetBSD: partutil.c,v 1.12 2013/04/13 22:08:57 jakllsch Exp $); #include sys/types.h #include sys/disklabel.h @@ -89,30 +89,6 @@ dict2geom(struct disk_geom *geo, prop_di } -static void -part2wedge(struct dkwedge_info *dkw, const struct disklabel *lp, const char *s) -{ - struct stat sb; - const struct partition *pp; - int ptn; - - (void)memset(dkw, 0, sizeof(*dkw)); - if (stat(s, sb) == -1) - return; - - ptn = strchr(s, '\0')[-1] - 'a'; - if ((unsigned)ptn = lp-d_npartitions || - (devminor_t)ptn != DISKPART(sb.st_rdev)) - return; - - pp = lp-d_partitions[ptn]; - dkw-dkw_offset = pp-p_offset; - dkw-dkw_size = pp-p_size; - dkw-dkw_parent[0] = '*'; - strlcpy(dkw-dkw_ptype, getfstypename(pp-p_fstype), - sizeof(dkw-dkw_ptype)); -} - int getdiskinfo(const char *s, int fd, const char *dt, struct disk_geom *geo, struct dkwedge_info *dkw) @@ -120,6 +96,9 @@ getdiskinfo(const char *s, int fd, const struct disklabel lab; struct disklabel *lp = lab; prop_dictionary_t disk_dict, geom_dict; + struct stat sb; + const struct partition *pp; + int ptn; if (dt) { lp = getdiskbyname(dt); @@ -144,15 +123,41 @@ getdiskinfo(const char *s, int fd, const geom_dict = prop_dictionary_get(disk_dict, geometry); dict2geom(geo, geom_dict); } - + /* Get info about partition/wedge */ - if (ioctl(fd, DIOCGWEDGEINFO, dkw) == -1) { - if (ioctl(fd, DIOCGDINFO, lp) == -1) - err(1, Please implement DIOCGWEDGEINFO or - DIOCGDINFO for disk device %s, s); + if (ioctl(fd, DIOCGWEDGEINFO, dkw) != -1) { + /* DIOCGWEDGEINFO didn't fail, we're done */ + return 0; + } + + if (ioctl(fd, DIOCGDINFO, lp) == -1) { + err(1, Please implement DIOCGWEDGEINFO or + DIOCGDINFO for disk device %s, s); + } + + /* DIOCGDINFO didn't fail */ + + (void)memset(dkw, 0, sizeof(*dkw)); + + 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)) + return 0; - part2wedge(dkw, lp, s); + pp = lp-d_partitions[ptn]; + if (ptn != getrawpartition()) { + dkw-dkw_offset = pp-p_offset; + dkw-dkw_size = pp-p_size; + } else { + dkw-dkw_offset = 0; + dkw-dkw_size = geo-dg_secperunit; } + dkw-dkw_parent[0] = '*'; + strlcpy(dkw-dkw_ptype, getfstypename(pp-p_fstype), + sizeof(dkw-dkw_ptype)); return 0; }
CVS commit: src/sbin/fsck
Module Name:src Committed By: jakllsch Date: Sat Apr 13 22:08:58 UTC 2013 Modified Files: src/sbin/fsck: partutil.c Log Message: Make getdiskinfo() always return correct dkwedge_info for the raw partition. A real disk's raw partition does not implement DIOCGWEDGEINFO, but does implement DIOCGDINFO. This was resulting in the returned wedge information containing 32-bit-clamped values for size of the raw partition, with no indication thereof. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 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: mlelstv Date: Sun Jan 13 19:53:17 UTC 2013 Modified Files: src/sbin/fsck: fsutil.c Log Message: Support symlinks to a block device to resolve the name of the corresponding raw device. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sbin/fsck/fsutil.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/fsutil.c diff -u src/sbin/fsck/fsutil.c:1.23 src/sbin/fsck/fsutil.c:1.24 --- src/sbin/fsck/fsutil.c:1.23 Sun Apr 8 04:19:14 2012 +++ src/sbin/fsck/fsutil.c Sun Jan 13 19:53:16 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fsutil.c,v 1.23 2012/04/08 04:19:14 christos Exp $ */ +/* $NetBSD: fsutil.c,v 1.24 2013/01/13 19:53:16 mlelstv Exp $ */ /* * Copyright (c) 1990, 1993 @@ -31,7 +31,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: fsutil.c,v 1.23 2012/04/08 04:19:14 christos Exp $); +__RCSID($NetBSD: fsutil.c,v 1.24 2013/01/13 19:53:16 mlelstv Exp $); #endif /* not lint */ #include sys/param.h @@ -173,6 +173,7 @@ blockcheck(const char *origname) const char *newname, *raw, *cooked; struct fstab *fsp; int retried = 0; + ssize_t len; char cbuf[MAXPATHLEN]; static char buf[MAXPATHLEN]; @@ -181,7 +182,13 @@ blockcheck(const char *origname) perr(Can't stat `/'); return (origname); } - newname = origname; + len = readlink(origname, cbuf, sizeof(cbuf)-1); + if (len == -1) { + newname = origname; + } else { + cbuf[len] = '\0'; + newname = cbuf; + } retry: if (stat(newname, stblock) 0) { perr(Can't stat `%s', newname);
CVS commit: src/sbin/fsck
Module Name:src Committed By: mlelstv Date: Sun Jan 13 19:53:17 UTC 2013 Modified Files: src/sbin/fsck: fsutil.c Log Message: Support symlinks to a block device to resolve the name of the corresponding raw device. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sbin/fsck/fsutil.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: Sun Apr 8 04:19:14 UTC 2012 Modified Files: src/sbin/fsck: fsutil.c Log Message: Don't re-use the same buffer that we pass in for newname in the cooked-raw conversion. Better variable names. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sbin/fsck/fsutil.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/fsutil.c diff -u src/sbin/fsck/fsutil.c:1.22 src/sbin/fsck/fsutil.c:1.23 --- src/sbin/fsck/fsutil.c:1.22 Sat Apr 7 12:44:10 2012 +++ src/sbin/fsck/fsutil.c Sun Apr 8 00:19:14 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: fsutil.c,v 1.22 2012/04/07 16:44:10 christos Exp $ */ +/* $NetBSD: fsutil.c,v 1.23 2012/04/08 04:19:14 christos Exp $ */ /* * Copyright (c) 1990, 1993 @@ -31,7 +31,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: fsutil.c,v 1.22 2012/04/07 16:44:10 christos Exp $); +__RCSID($NetBSD: fsutil.c,v 1.23 2012/04/08 04:19:14 christos Exp $); #endif /* not lint */ #include sys/param.h @@ -170,9 +170,10 @@ const char * blockcheck(const char *origname) { struct stat stslash, stblock, stchar; - const char *newname, *raw; + const char *newname, *raw, *cooked; struct fstab *fsp; int retried = 0; + char cbuf[MAXPATHLEN]; static char buf[MAXPATHLEN]; hot = 0; @@ -184,7 +185,7 @@ blockcheck(const char *origname) retry: if (stat(newname, stblock) 0) { perr(Can't stat `%s', newname); - return (origname); + return origname; } if (S_ISBLK(stblock.st_mode)) { if (stslash.st_dev == stblock.st_rdev) @@ -196,26 +197,25 @@ retry: } if (stat(raw, stchar) 0) { perr(Can't stat `%s', raw); - return (origname); + return origname; } if (S_ISCHR(stchar.st_mode)) { - return (raw); + return raw; } else { - printf(%s is not a character device\n, raw); - return (origname); + perr(%s is not a character device\n, raw); + return origname; } } else if (S_ISCHR(stblock.st_mode) !retried) { - raw = getdiskcookedname(buf, sizeof(buf), newname); - if (raw == NULL) { + cooked = getdiskcookedname(cbuf, sizeof(cbuf), newname); + if (cooked == NULL) { perr(Can't convert to cooked `%s', newname); return origname; } else - newname = raw; + newname = cooked; retried++; goto retry; } else if ((fsp = getfsfile(newname)) != 0 !retried) { - char rbuf[MAXPATHLEN]; - newname = getfsspecname(rbuf, sizeof(rbuf), fsp-fs_spec); + newname = getfsspecname(cbuf, sizeof(cbuf), fsp-fs_spec); if (newname == NULL) perr(%s, buf); retried++; @@ -225,7 +225,7 @@ retry: * Not a block or character device, just return name and * let the user decide whether to use it. */ - return (origname); + return origname; } const char *
CVS commit: src/sbin/fsck
Module Name:src Committed By: christos Date: Sun Apr 8 04:19:14 UTC 2012 Modified Files: src/sbin/fsck: fsutil.c Log Message: Don't re-use the same buffer that we pass in for newname in the cooked-raw conversion. Better variable names. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sbin/fsck/fsutil.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: Sun Nov 13 22:04:51 UTC 2011 Modified Files: src/sbin/fsck: partutil.c Log Message: use getfstypename To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 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.10 src/sbin/fsck/partutil.c:1.11 --- src/sbin/fsck/partutil.c:1.10 Fri Mar 5 19:30:54 2010 +++ src/sbin/fsck/partutil.c Sun Nov 13 17:04:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: partutil.c,v 1.10 2010/03/06 00:30:54 christos Exp $ */ +/* $NetBSD: partutil.c,v 1.11 2011/11/13 22:04:51 christos Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: partutil.c,v 1.10 2010/03/06 00:30:54 christos Exp $); +__RCSID($NetBSD: partutil.c,v 1.11 2011/11/13 22:04:51 christos Exp $); #include sys/types.h #include sys/disklabel.h @@ -109,47 +109,8 @@ part2wedge(struct dkwedge_info *dkw, con dkw-dkw_offset = pp-p_offset; dkw-dkw_size = pp-p_size; dkw-dkw_parent[0] = '*'; - switch (pp-p_fstype) { - default: - (void)strcpy(dkw-dkw_ptype, DKW_PTYPE_UNKNOWN); - break; - case FS_UNUSED: - (void)strcpy(dkw-dkw_ptype, DKW_PTYPE_UNUSED); - break; - case FS_SWAP: - (void)strcpy(dkw-dkw_ptype, DKW_PTYPE_SWAP); - break; - case FS_BSDFFS: - (void)strcpy(dkw-dkw_ptype, DKW_PTYPE_FFS); - break; - case FS_BSDLFS: - (void)strcpy(dkw-dkw_ptype, DKW_PTYPE_LFS); - break; - case FS_EX2FS: - (void)strcpy(dkw-dkw_ptype, DKW_PTYPE_EXT2FS); - break; - case FS_ISO9660: - (void)strcpy(dkw-dkw_ptype, DKW_PTYPE_ISO9660); - break; - case FS_ADOS: - (void)strcpy(dkw-dkw_ptype, DKW_PTYPE_AMIGADOS); - break; - case FS_HFS: - (void)strcpy(dkw-dkw_ptype, DKW_PTYPE_APPLEHFS); - break; - case FS_MSDOS: - (void)strcpy(dkw-dkw_ptype, DKW_PTYPE_FAT); - break; - case FS_FILECORE: - (void)strcpy(dkw-dkw_ptype, DKW_PTYPE_FILECORE); - break; - case FS_APPLEUFS: - (void)strcpy(dkw-dkw_ptype, DKW_PTYPE_APPLEUFS); - break; - case FS_NTFS: - (void)strcpy(dkw-dkw_ptype, DKW_PTYPE_NTFS); - break; - } + strlcpy(dkw-dkw_ptype, getfstypename(pp-p_fstype), + sizeof(dkw-dkw_ptype)); } int
CVS commit: src/sbin/fsck
Module Name:src Committed By: christos Date: Sun Nov 13 22:04:51 UTC 2011 Modified Files: src/sbin/fsck: partutil.c Log Message: use getfstypename To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 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: joerg Date: Sat Aug 27 17:34:44 UTC 2011 Modified Files: src/sbin/fsck: fsck.c fsutil.h Log Message: Use __dead and __printflike. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sbin/fsck/fsck.c cvs rdiff -u -r1.17 -r1.18 src/sbin/fsck/fsutil.h 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.49 src/sbin/fsck/fsck.c:1.50 --- src/sbin/fsck/fsck.c:1.49 Wed Feb 24 13:56:07 2010 +++ src/sbin/fsck/fsck.c Sat Aug 27 17:34:44 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fsck.c,v 1.49 2010/02/24 13:56:07 hannken Exp $ */ +/* $NetBSD: fsck.c,v 1.50 2011/08/27 17:34:44 joerg Exp $ */ /* * Copyright (c) 1996 Christos Zoulas. All rights reserved. @@ -36,7 +36,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: fsck.c,v 1.49 2010/02/24 13:56:07 hannken Exp $); +__RCSID($NetBSD: fsck.c,v 1.50 2011/08/27 17:34:44 joerg Exp $); #endif /* not lint */ #include sys/param.h @@ -89,7 +89,7 @@ static void catopt(char **, const char *); static void mangle(char *, int *, const char ** volatile *, int *); static const char *getfslab(const char *); -static void usage(void); +__dead static void usage(void); static void *isok(struct fstab *); int Index: src/sbin/fsck/fsutil.h diff -u src/sbin/fsck/fsutil.h:1.17 src/sbin/fsck/fsutil.h:1.18 --- src/sbin/fsck/fsutil.h:1.17 Thu Jun 9 21:23:29 2011 +++ src/sbin/fsck/fsutil.h Sat Aug 27 17:34:44 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fsutil.h,v 1.17 2011/06/09 21:23:29 christos Exp $ */ +/* $NetBSD: fsutil.h,v 1.18 2011/08/27 17:34:44 joerg Exp $ */ /* * Copyright (c) 1996 Christos Zoulas. All rights reserved. @@ -27,18 +27,12 @@ #include stdarg.h #include signal.h -void errexit(const char *, ...) -__attribute__((__noreturn__,__format__(__printf__,1,2))); -void pfatal(const char *, ...) -__attribute__((__format__(__printf__,1,2))); -void pwarn(const char *, ...) -__attribute__((__format__(__printf__,1,2))); -void perr(const char *, ...) -__attribute__((__format__(__printf__,1,2))); -void panic(const char *, ...) -__attribute__((__noreturn__,__format__(__printf__,1,2))); -void vmsg(int, const char *, va_list) - __attribute__((__format__(__printf__,2,0))); +void errexit(const char *, ...) __printflike(1, 2) __dead; +void pfatal(const char *, ...) __printflike(1, 2); +void pwarn(const char *, ...) __printflike(1, 2); +void perr(const char *, ...) __printflike(1, 2); +void panic(const char *, ...) __printflike(1, 2) __dead; +void vmsg(int, const char *, va_list) __printflike(2, 0); const char *rawname(const char *); const char *unrawname(const char *); const char *blockcheck(const char *); @@ -60,6 +54,6 @@ void (*ckfinish)(int); volatile sig_atomic_t returntosingle; -void catch(int); +void catch(int) __dead; void catchquit(int); void voidquit(int);
CVS commit: src/sbin/fsck
Module Name:src Committed By: joerg Date: Sat Aug 27 17:34:44 UTC 2011 Modified Files: src/sbin/fsck: fsck.c fsutil.h Log Message: Use __dead and __printflike. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sbin/fsck/fsck.c cvs rdiff -u -r1.17 -r1.18 src/sbin/fsck/fsutil.h 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 Apr 28 12:16:10 UTC 2011 Modified Files: src/sbin/fsck: fsck.8 Log Message: New sentence, new line. Sort sections. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sbin/fsck/fsck.8 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.8 diff -u src/sbin/fsck/fsck.8:1.37 src/sbin/fsck/fsck.8:1.38 --- src/sbin/fsck/fsck.8:1.37 Thu Feb 18 06:57:17 2010 +++ src/sbin/fsck/fsck.8 Thu Apr 28 12:16:10 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: fsck.8,v 1.37 2010/02/18 06:57:17 wiz Exp $ +.\ $NetBSD: fsck.8,v 1.38 2011/04/28 12:16:10 wiz Exp $ .\ .\ Copyright (c) 1996 Christos Zoulas. All rights reserved. .\ @@ -128,6 +128,11 @@ to assume yes as the answer to all operator questions. .El +.Sh FILES +.Bl -tag -width /etc/fstab -compact +.It Pa /etc/fstab +file system table +.El .Sh EXIT STATUS .Nm exits with @@ -149,7 +154,8 @@ on the filesystem(s) is required. .It Dv 4 The root filesystem was changed in the process of checking, and updating the -mount was unsuccessful. A reboot (without sync) is required. +mount was unsuccessful. +A reboot (without sync) is required. .It Dv 8 The filesystem check has failed, and a subsequent check is required that will require human intervention. @@ -161,11 +167,6 @@ .Dv SIGQUIT from the terminal). .El -.Sh FILES -.Bl -tag -width /etc/fstab -compact -.It Pa /etc/fstab -file system table -.El .Sh SEE ALSO .Xr fstab 5 , .Xr fsck_ext2fs 8 ,
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 sys/cdefs.h -__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 sys/types.h #include sys/disklabel.h @@ -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: 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: 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. Modified files: Index: src/sbin/fsck/fsck.c diff -u src/sbin/fsck/fsck.c:1.48 src/sbin/fsck/fsck.c:1.49 --- src/sbin/fsck/fsck.c:1.48 Wed Feb 17 23:30:21 2010 +++ src/sbin/fsck/fsck.c Wed Feb 24 13:56:07 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: fsck.c,v 1.48 2010/02/17 23:30:21 christos Exp $ */ +/* $NetBSD: fsck.c,v 1.49 2010/02/24 13:56:07 hannken Exp $ */ /* * Copyright (c) 1996 Christos Zoulas. All rights reserved. @@ -36,7 +36,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: fsck.c,v 1.48 2010/02/17 23:30:21 christos Exp $); +__RCSID($NetBSD: fsck.c,v 1.49 2010/02/24 13:56:07 hannken Exp $); #endif /* not lint */ #include sys/param.h @@ -156,7 +156,7 @@ case 'x': addentry(omhead, optarg, ); - break; + continue; case 'y': break;
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 mountpoint ``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.
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 mountpoint ``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. Modified files: Index: src/sbin/fsck/fsck.8 diff -u src/sbin/fsck/fsck.8:1.35 src/sbin/fsck/fsck.8:1.36 --- src/sbin/fsck/fsck.8:1.35 Tue Oct 20 21:07:46 2009 +++ src/sbin/fsck/fsck.8 Wed Feb 17 18:30:21 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: fsck.8,v 1.35 2009/10/21 01:07:46 snj Exp $ +.\ $NetBSD: fsck.8,v 1.36 2010/02/17 23:30:21 christos Exp $ .\ .\ Copyright (c) 1996 Christos Zoulas. All rights reserved. .\ @@ -22,7 +22,7 @@ .\ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\ -.Dd February 23, 2008 +.Dd February 17, 2010 .Dt FSCK 8 .Os .Sh NAME @@ -34,6 +34,7 @@ .Op Fl l Ar maxparallel .Op Fl T Ar fstype:fsoptions .Op Fl t Ar fstype +.Op Fl x Ar mountpoint .Op special | node ... .Sh DESCRIPTION The @@ -111,6 +112,12 @@ for the file system types that are not specified in the list. .It Fl v Print the commands before executing them. +.It Fl x Ar mountpoint +Exclude the filesystem which has a +.Ar mountpoint +the same as in +.Pa /etc/fstab . +Used only in ``preen'' mode. .It Fl y Causes .Nm Index: src/sbin/fsck/fsck.c diff -u src/sbin/fsck/fsck.c:1.47 src/sbin/fsck/fsck.c:1.48 --- src/sbin/fsck/fsck.c:1.47 Sat Feb 23 16:41:47 2008 +++ src/sbin/fsck/fsck.c Wed Feb 17 18:30:21 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: fsck.c,v 1.47 2008/02/23 21:41:47 christos Exp $ */ +/* $NetBSD: fsck.c,v 1.48 2010/02/17 23:30:21 christos Exp $ */ /* * Copyright (c) 1996 Christos Zoulas. All rights reserved. @@ -36,7 +36,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: fsck.c,v 1.47 2008/02/23 21:41:47 christos Exp $); +__RCSID($NetBSD: fsck.c,v 1.48 2010/02/17 23:30:21 christos Exp $); #endif /* not lint */ #include sys/param.h @@ -67,7 +67,7 @@ static enum { IN_LIST, NOT_IN_LIST } which = NOT_IN_LIST; -TAILQ_HEAD(fstypelist, entry) opthead, selhead; +TAILQ_HEAD(fstypelist, entry) opthead, selhead, omhead; struct entry { char *type; @@ -81,6 +81,7 @@ static int checkfs(const char *, const char *, const char *, void *, pid_t *); static int selected(const char *); +static int omitted(const char *); static void addoption(char *); static const char *getoptions(const char *); static void addentry(struct fstypelist *, const char *, const char *); @@ -105,8 +106,9 @@ TAILQ_INIT(selhead); TAILQ_INIT(opthead); + TAILQ_INIT(omhead); - while ((i = getopt(argc, argv, dfl:nPpqT:t:vy)) != -1) { + while ((i = getopt(argc, argv, dfl:nPpqT:t:vx:y)) != -1) { switch (i) { case 'd': flags |= CHECK_DEBUG; @@ -152,6 +154,10 @@ flags |= CHECK_VERBOSE; continue; + case 'x': + addentry(omhead, optarg, ); + break; + case 'y': break; @@ -236,6 +242,9 @@ if (!selected(fs-fs_vfstype)) return NULL; + if (omitted(fs-fs_file)) + return NULL; + return fs; } @@ -391,6 +400,20 @@ } +static int +omitted(const char *mountedon) +{ + struct entry *e; + + /* If no type specified, it's always selected. */ + TAILQ_FOREACH(e, omhead, entries) + if (!strcmp(e-type, mountedon)) + return 1; + + return 0; +} + + static const char * getoptions(const char *type) { @@ -558,7 +581,7 @@ usage(void) { static const char common[] = - [-dfnPpqvy] [-l maxparallel] [-T fstype:fsoptions]\n\t\t[-t fstype]; + [-dfnPpqvy] [-x excludemount] [-l maxparallel] [-T fstype:fsoptions]\n\t\t[-t fstype]; (void)fprintf(stderr, usage: %s %s [special|node]...\n, getprogname(), common);
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. Modified files: Index: src/sbin/fsck/fsck.8 diff -u src/sbin/fsck/fsck.8:1.36 src/sbin/fsck/fsck.8:1.37 --- src/sbin/fsck/fsck.8:1.36 Wed Feb 17 23:30:21 2010 +++ src/sbin/fsck/fsck.8 Thu Feb 18 06:57:17 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: fsck.8,v 1.36 2010/02/17 23:30:21 christos Exp $ +.\ $NetBSD: fsck.8,v 1.37 2010/02/18 06:57:17 wiz Exp $ .\ .\ Copyright (c) 1996 Christos Zoulas. All rights reserved. .\ @@ -47,7 +47,9 @@ It is normally used in the script .Pa /etc/rc during automatic reboot. -If no file systems are specified, and ``preen'' mode is enabled ( +If no file systems are specified, and +.Dq preen +mode is enabled ( .Fl p option) .Nm @@ -117,7 +119,9 @@ .Ar mountpoint the same as in .Pa /etc/fstab . -Used only in ``preen'' mode. +Used only in +.Dq preen +mode. .It Fl y Causes .Nm @@ -126,7 +130,7 @@ .El .Sh EXIT STATUS .Nm -exits with +exits with .Dv 0 on success. Any major problems will cause @@ -149,7 +153,7 @@ .It Dv 8 The filesystem check has failed, and a subsequent check is required that will require human intervention. -.It Dv 12 +.It Dv 12 .Nm exited because of the result of a signal (usually .Dv SIGINT
CVS commit: src/sbin/fsck
Module Name:src Committed By: dyoung Date: Thu Jul 16 23:50:32 UTC 2009 Modified Files: src/sbin/fsck: partutil.c Log Message: Callers expect getdiskinfo() to return -1 on error, so do that. Simplify getdiskinfo() a bit while I am here: don't save error codes that we will never refer to again. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 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.8 src/sbin/fsck/partutil.c:1.9 --- src/sbin/fsck/partutil.c:1.8 Sun Jun 14 21:06:18 2009 +++ src/sbin/fsck/partutil.c Thu Jul 16 23:50:32 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: partutil.c,v 1.8 2009/06/14 21:06:18 haad Exp $ */ +/* $NetBSD: partutil.c,v 1.9 2009/07/16 23:50:32 dyoung Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: partutil.c,v 1.8 2009/06/14 21:06:18 haad Exp $); +__RCSID($NetBSD: partutil.c,v 1.9 2009/07/16 23:50:32 dyoung Exp $); #include sys/types.h #include sys/disklabel.h @@ -155,10 +155,7 @@ struct disklabel lab; struct disklabel *lp = lab; prop_dictionary_t disk_dict, geom_dict; - int error; - error = 0; - if (dt) { lp = getdiskbyname(dt); if (lp == NULL) @@ -166,17 +163,16 @@ } /* Get disk description dictionary */ - if ((error = prop_dictionary_recv_ioctl(fd, DIOCGDISKINFO, - disk_dict)) != 0) { + if (prop_dictionary_recv_ioctl(fd, DIOCGDISKINFO, disk_dict)) { /* * Ask for disklabel if DIOCGDISKINFO failed. This is * compatibility call and can be removed when all devices * will support DIOCGDISKINFO. * cgd, ccd pseudo disk drives doesn't support DIOCGDDISKINFO */ - if ((error = ioctl(fd, DIOCGDINFO, lp)) == -1) { + if (ioctl(fd, DIOCGDINFO, lp) == -1) { printf(DIOCGDINFO on %s failed\n, s); - return (errno); + return -1; } label2geom(geo, lp); } else {
CVS commit: src/sbin/fsck
Module Name:src Committed By: haad Date: Sun Jun 14 21:06:19 UTC 2009 Modified Files: src/sbin/fsck: partutil.c Log Message: Remove bogus warn, which was printed when DIOCGDISKINFO failed. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 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.7 src/sbin/fsck/partutil.c:1.8 --- src/sbin/fsck/partutil.c:1.7 Sat Jun 6 18:31:29 2009 +++ src/sbin/fsck/partutil.c Sun Jun 14 21:06:18 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: partutil.c,v 1.7 2009/06/06 18:31:29 haad Exp $ */ +/* $NetBSD: partutil.c,v 1.8 2009/06/14 21:06:18 haad Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: partutil.c,v 1.7 2009/06/06 18:31:29 haad Exp $); +__RCSID($NetBSD: partutil.c,v 1.8 2009/06/14 21:06:18 haad Exp $); #include sys/types.h #include sys/disklabel.h @@ -168,12 +168,11 @@ /* Get disk description dictionary */ if ((error = prop_dictionary_recv_ioctl(fd, DIOCGDISKINFO, disk_dict)) != 0) { - warn(Please implement DIOCGDISKINFO for %s disk driver\n, s); - /* * Ask for disklabel if DIOCGDISKINFO failed. This is * compatibility call and can be removed when all devices * will support DIOCGDISKINFO. + * cgd, ccd pseudo disk drives doesn't support DIOCGDDISKINFO */ if ((error = ioctl(fd, DIOCGDINFO, lp)) == -1) { printf(DIOCGDINFO on %s failed\n, s);
CVS commit: src/sbin/fsck
Module Name:src Committed By: haad Date: Sat Jun 6 18:31:29 UTC 2009 Modified Files: src/sbin/fsck: partutil.c Log Message: Add support for devices which do not support DIOCGDISKINFO ioctl yet. This change will restore fsck/newfs on vnd device. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 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.6 src/sbin/fsck/partutil.c:1.7 --- src/sbin/fsck/partutil.c:1.6 Sat Jun 6 17:47:50 2009 +++ src/sbin/fsck/partutil.c Sat Jun 6 18:31:29 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: partutil.c,v 1.6 2009/06/06 17:47:50 haad Exp $ */ +/* $NetBSD: partutil.c,v 1.7 2009/06/06 18:31:29 haad Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: partutil.c,v 1.6 2009/06/06 17:47:50 haad Exp $); +__RCSID($NetBSD: partutil.c,v 1.7 2009/06/06 18:31:29 haad Exp $); #include sys/types.h #include sys/disklabel.h @@ -52,6 +52,23 @@ #include partutil.h +/* + * Convert disklabel geometry info to disk_geom. + */ +static void +label2geom(struct disk_geom *geo, const struct disklabel *lp) +{ + geo-dg_secperunit = lp-d_secperunit; + geo-dg_secsize = lp-d_secsize; + geo-dg_nsectors = lp-d_nsectors; + geo-dg_ntracks = lp-d_ntracks; + geo-dg_ncylinders = lp-d_ncylinders; + geo-dg_secpercyl = lp-d_secpercyl; + geo-dg_pcylinders = lp-d_ncylinders; + geo-dg_sparespertrack = lp-d_sparespertrack; + geo-dg_sparespercyl = lp-d_sparespercyl; + geo-dg_acylinders = lp-d_acylinders; +} /* * Set what we need to know about disk geometry. @@ -138,7 +155,10 @@ struct disklabel lab; struct disklabel *lp = lab; prop_dictionary_t disk_dict, geom_dict; + int error; + error = 0; + if (dt) { lp = getdiskbyname(dt); if (lp == NULL) @@ -146,18 +166,30 @@ } /* Get disk description dictionary */ - if (prop_dictionary_recv_ioctl(fd, DIOCGDISKINFO, disk_dict) != 0) { - warn(Please implement DIOCGDISKINFO for %s\n disk driver\n, s); - return (errno); + if ((error = prop_dictionary_recv_ioctl(fd, DIOCGDISKINFO, + disk_dict)) != 0) { + warn(Please implement DIOCGDISKINFO for %s disk driver\n, s); + + /* + * Ask for disklabel if DIOCGDISKINFO failed. This is + * compatibility call and can be removed when all devices + * will support DIOCGDISKINFO. + */ + if ((error = ioctl(fd, DIOCGDINFO, lp)) == -1) { + printf(DIOCGDINFO on %s failed\n, s); + return (errno); + } + label2geom(geo, lp); + } else { + geom_dict = prop_dictionary_get(disk_dict, geometry); + dict2geom(geo, geom_dict); } - geom_dict = prop_dictionary_get(disk_dict, geometry); - dict2geom(geo, geom_dict); - /* 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); + errx(errno, Please implement DIOCGWEDGEINFO or + DIOCGDINFO for disk device %s\n, s); part2wedge(dkw, lp, s); }
CVS commit: src/sbin/fsck
Module Name:src Committed By: lukem Date: Sat Apr 11 06:48:36 UTC 2009 Modified Files: src/sbin/fsck: partutil.c progress.c Log Message: fix sign-compare issues To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sbin/fsck/partutil.c cvs rdiff -u -r1.4 -r1.5 src/sbin/fsck/progress.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.3 src/sbin/fsck/partutil.c:1.4 --- src/sbin/fsck/partutil.c:1.3 Mon Apr 28 20:23:08 2008 +++ src/sbin/fsck/partutil.c Sat Apr 11 06:48:36 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: partutil.c,v 1.3 2008/04/28 20:23:08 martin Exp $ */ +/* $NetBSD: partutil.c,v 1.4 2009/04/11 06:48:36 lukem Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: partutil.c,v 1.3 2008/04/28 20:23:08 martin Exp $); +__RCSID($NetBSD: partutil.c,v 1.4 2009/04/11 06:48:36 lukem Exp $); #include sys/types.h #include sys/disklabel.h @@ -75,7 +75,8 @@ return; ptn = strchr(s, '\0')[-1] - 'a'; - if (ptn = lp-d_npartitions || ptn != DISKPART(sb.st_rdev)) + if ((unsigned)ptn = lp-d_npartitions || + (devminor_t)ptn != DISKPART(sb.st_rdev)) return; pp = lp-d_partitions[ptn]; Index: src/sbin/fsck/progress.c diff -u src/sbin/fsck/progress.c:1.4 src/sbin/fsck/progress.c:1.5 --- src/sbin/fsck/progress.c:1.4 Mon Apr 28 20:23:08 2008 +++ src/sbin/fsck/progress.c Sat Apr 11 06:48:36 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: progress.c,v 1.4 2008/04/28 20:23:08 martin Exp $ */ +/* $NetBSD: progress.c,v 1.5 2009/04/11 06:48:36 lukem Exp $ */ /*- * Copyright (c) 1997-2004 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #ifndef SMALL #include sys/cdefs.h -__RCSID($NetBSD: progress.c,v 1.4 2008/04/28 20:23:08 martin Exp $); +__RCSID($NetBSD: progress.c,v 1.5 2009/04/11 06:48:36 lukem Exp $); /* * File system independent fsck progress bar routines. @@ -47,7 +47,7 @@ #include progress.h -static int ttywidth = 80; +static size_t ttywidth = 80; static int progress_onoff; static int progress_lowlim;