OpenBSD CVS

CVS log for src/sbin/ncheck_ffs/ncheck_ffs.c


[BACK] Up to [local] / src / sbin / ncheck_ffs

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.56 / (download) - annotate - [select for diffs], Tue Apr 23 13:34:50 2024 UTC (5 weeks, 4 days ago) by jsg
Branch: MAIN
CVS Tags: HEAD
Changes since 1.55: +2 -2 lines
Diff to previous 1.55 (colored)

correct indentation; no functional change
ok tb@

Revision 1.55 / (download) - annotate - [select for diffs], Wed Jul 3 03:24:02 2019 UTC (4 years, 11 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1, OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.54: +3 -3 lines
Diff to previous 1.54 (colored)

snprintf/vsnprintf return < 0 on error, rather than -1.

Revision 1.54 / (download) - annotate - [select for diffs], Fri Jun 28 13:32:45 2019 UTC (4 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.53: +5 -5 lines
Diff to previous 1.53 (colored)

When system calls indicate an error they return -1, not some arbitrary
value < 0.  errno is only updated in this case.  Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.

Revision 1.53 / (download) - annotate - [select for diffs], Sat May 28 23:46:06 2016 UTC (8 years ago) by tb
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4, OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1, OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.52: +1 -4 lines
Diff to previous 1.52 (colored)

Don't pledge before opendev() and ioctl DIOCGDINFO were called.
Avoids a pledge crash with 'ncheck_ffs /dev/tty'.

deraadt agrees

Revision 1.52 / (download) - annotate - [select for diffs], Mon Nov 23 19:19:30 2015 UTC (8 years, 6 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.51: +4 -1 lines
Diff to previous 1.51 (colored)

Use pledge "disklabel" as needed.  The theory here is these tools become more
resistant against memory correctup, if a corrupt filesystem is given to them.
ok krw

Revision 1.51 / (download) - annotate - [select for diffs], Sun Oct 11 19:00:40 2015 UTC (8 years, 7 months ago) by doug
Branch: MAIN
Changes since 1.50: +5 -1 lines
Diff to previous 1.50 (colored)

Pledge that ncheck_ffs only uses "stdio" after opening the device.

ok deraadt@

Revision 1.50 / (download) - annotate - [select for diffs], Sat Feb 7 02:09:13 2015 UTC (9 years, 3 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8, OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.49: +5 -5 lines
Diff to previous 1.49 (colored)

When getopt processing flags, many should be flag=1 instead of flag++
ok tedu miod

Revision 1.49 / (download) - annotate - [select for diffs], Tue Jan 20 18:22:21 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.48: +2 -2 lines
Diff to previous 1.48 (colored)

Adjust <sys/param.h> comments regarding use of use of MAXFRAG, or
delete <sys/param.h> if now possible
ok guenther

Revision 1.48 / (download) - annotate - [select for diffs], Fri Jan 16 06:39:59 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.47: +4 -3 lines
Diff to previous 1.47 (colored)

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible.  Annotate <sys/param.h> lines with their current reasons.  Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc.  Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution.  These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)

Revision 1.47 / (download) - annotate - [select for diffs], Thu Oct 9 02:41:22 2014 UTC (9 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.46: +3 -6 lines
Diff to previous 1.46 (colored)

fairly obvious reallocarray() conversion, where the size is recalculated
only on success.

Revision 1.46 / (download) - annotate - [select for diffs], Wed Jul 9 11:21:48 2014 UTC (9 years, 10 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.45: +19 -6 lines
Diff to previous 1.45 (colored)

Enable specifying the filesystem of interest by the duid.

Original diff from halex@ a while ago.

ok halex@ jsing@ (with comments for future tweaking)

Revision 1.45 / (download) - annotate - [select for diffs], Tue May 27 12:35:40 2014 UTC (10 years ago) by krw
Branch: MAIN
Changes since 1.44: +17 -9 lines
Diff to previous 1.44 (colored)

Where trying to pread() a single disk sector, the i/o must be for the
actual disk sector size and not DEV_BSIZE. The sector size must be
obtained via the disklabel. Larger i/o's must be multiple sectors,
so when retrying with a smaller size shrink the attempt by one sector
and not DEV_BSIZE.

Of course if your d_secsize is DEV_BSIZE, this will all be a no-op.

This does not make non-512-byte sectors work, but puts in place the
logic to get and use the disklabel info. Which makes the next diffs
bite sized and focused.

ok guenther@

Revision 1.44 / (download) - annotate - [select for diffs], Sat May 24 21:49:09 2014 UTC (10 years ago) by krw
Branch: MAIN
Changes since 1.43: +18 -20 lines
Diff to previous 1.43 (colored)

Nuke last of the illusionary 'dev_bsize' and 'dev_bshift' variables in
favour of DEV_BSIZE. No-op on 512-byte sector devices.

Revision 1.43 / (download) - annotate - [select for diffs], Thu May 22 02:15:54 2014 UTC (10 years ago) by krw
Branch: MAIN
Changes since 1.42: +2 -2 lines
Diff to previous 1.42 (colored)

Nuke some trailing whitespace to shrink subsequent diffs.

Revision 1.42 / (download) - annotate - [select for diffs], Tue May 20 21:11:16 2014 UTC (10 years ago) by krw
Branch: MAIN
Changes since 1.41: +5 -7 lines
Diff to previous 1.41 (colored)

As suggested by guenther@ and millert@, replace seek+[read|write] with
p[read|write].  Makes the code much clearer by eliminating extra error
checking and verbiage.

No intentional functional change.

Tweaks by and ok guenther@

Revision 1.41 / (download) - annotate - [select for diffs], Tue May 13 05:50:24 2014 UTC (10 years ago) by guenther
Branch: MAIN
Changes since 1.40: +68 -58 lines
Diff to previous 1.40 (colored)

Since this is limited to ffs, use ufsinfo_t instead of ino_t.
Grow the array of cached inodes exponentially instead of arithmetically.
Prefer sizeof(*pointer) over sizeof(type) in mallocs.
Don't leak memory in searchdir().
Fix multiple bugs in the handling of indirect blocks, including reuse of
a static buffer in a recursive function and failure to track the remaining
size of the directory blocks to process

Tested with a directory *doubly* indirect block!
ok krw@

Revision 1.40 / (download) - annotate - [select for diffs], Sun May 11 21:25:07 2014 UTC (10 years ago) by halex
Branch: MAIN
Changes since 1.39: +5 -13 lines
Diff to previous 1.39 (colored)

replace realloc(p, N * M) with reallocarray(p, N, M) and remove some
pointless cleanup if we're obviously going to die anyway

ok guenther@

Revision 1.39 / (download) - annotate - [select for diffs], Sun May 11 21:14:03 2014 UTC (10 years ago) by guenther
Branch: MAIN
Changes since 1.38: +4 -2 lines
Diff to previous 1.38 (colored)

struct direct's d_ino is no longer the same size as an ino_t, so copy it
for the call to bsearch()

problem report and ok krw@

Revision 1.38 / (download) - annotate - [select for diffs], Fri Nov 1 17:36:18 2013 UTC (10 years, 7 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.37: +10 -8 lines
Diff to previous 1.37 (colored)

Sprinkle (long long) casts where %lld is being used to print daddr_t
variables. Some random whitespace/knf repairs encountered on the way.

ok miod@ on inspection, feedback & more suggestions from millert@

Revision 1.37 / (download) - annotate - [select for diffs], Tue Jun 11 16:42:05 2013 UTC (10 years, 11 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.36: +8 -8 lines
Diff to previous 1.36 (colored)

final removal of daddr64_t.  daddr_t has been 64 bit for a long enough
test period; i think 3 years ago the last bugs fell out.
ok otto beck others

Revision 1.36 / (download) - annotate - [select for diffs], Wed Apr 24 13:46:29 2013 UTC (11 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.35: +14 -12 lines
Diff to previous 1.35 (colored)

pretty print bigger off_t
ok tedu otto

Revision 1.35 / (download) - annotate - [select for diffs], Tue Oct 27 23:59:33 2009 UTC (14 years, 7 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2, OPENBSD_5_1_BASE, OPENBSD_5_1, OPENBSD_5_0_BASE, OPENBSD_5_0, OPENBSD_4_9_BASE, OPENBSD_4_9, OPENBSD_4_8_BASE, OPENBSD_4_8, OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.34: +1 -5 lines
Diff to previous 1.34 (colored)

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable).  these days, people use source.  these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms

Revision 1.34 / (download) - annotate - [select for diffs], Tue Jun 2 22:37:05 2009 UTC (15 years ago) by ray
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6
Changes since 1.33: +4 -3 lines
Diff to previous 1.33 (colored)

snprintf returns int, not size_t.

OK millert otto deraadt

Revision 1.33 / (download) - annotate - [select for diffs], Mon Aug 6 19:16:05 2007 UTC (16 years, 9 months ago) by sobrado
Branch: MAIN
CVS Tags: OPENBSD_4_5_BASE, OPENBSD_4_5, OPENBSD_4_4_BASE, OPENBSD_4_4, OPENBSD_4_3_BASE, OPENBSD_4_3, OPENBSD_4_2_BASE, OPENBSD_4_2
Changes since 1.32: +4 -3 lines
Diff to previous 1.32 (colored)

the ellipsis is not an optional argument; while here, sync the usage
and synopsis of commands

lots of good ideas by jmc@

ok jmc@

Revision 1.32 / (download) - annotate - [select for diffs], Mon Jul 9 17:12:17 2007 UTC (16 years, 10 months ago) by thib
Branch: MAIN
Changes since 1.31: +9 -5 lines
Diff to previous 1.31 (colored)

correct a typo in an error message.
use realpath(3) to sanitize the path we're going to
work with, prevents silly errors when passing ncheck_ffs
paths from the shell with a trailing '/' since that
doesnt match the entry in fstab.

ok deraadt@,krw@

Revision 1.31 / (download) - annotate - [select for diffs], Fri Jun 29 03:37:09 2007 UTC (16 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.30: +3 -3 lines
Diff to previous 1.30 (colored)

more daddr64_t changes; checked by otto

Revision 1.30 / (download) - annotate - [select for diffs], Fri Jun 1 23:42:35 2007 UTC (17 years ago) by pedro
Branch: MAIN
Changes since 1.29: +6 -6 lines
Diff to previous 1.29 (colored)

ufs1_daddr_t cleanup, okay otto@

Revision 1.29 / (download) - annotate - [select for diffs], Fri Jun 1 06:41:35 2007 UTC (17 years ago) by deraadt
Branch: MAIN
Changes since 1.28: +10 -10 lines
Diff to previous 1.28 (colored)

convert ufs2_daddr_t -> daddr64_t for greater clarity; ok pedro otto thib

Revision 1.28 / (download) - annotate - [select for diffs], Mon May 21 18:12:00 2007 UTC (17 years ago) by millert
Branch: MAIN
Changes since 1.27: +143 -69 lines
Diff to previous 1.27 (colored)

Add ffs2 support; some parts adapted from ffs2 dump changes in FreeBSD.

Revision 1.27 / (download) - annotate - [select for diffs], Mon Mar 19 13:27:47 2007 UTC (17 years, 2 months ago) by pedro
Branch: MAIN
Changes since 1.26: +3 -3 lines
Diff to previous 1.26 (colored)

Add FFS2 fields to the superblock, change file system tools to keep
accessing FFS1 fields, okay art@, quite some testing by ckuethe@, simon@
and thib@, thanks.

Revision 1.26 / (download) - annotate - [select for diffs], Sun Apr 2 00:48:35 2006 UTC (18 years, 2 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_4_1_BASE, OPENBSD_4_1, OPENBSD_4_0_BASE, OPENBSD_4_0
Changes since 1.25: +4 -4 lines
Diff to previous 1.25 (colored)

use SEEK_* for lseek()

Revision 1.25 / (download) - annotate - [select for diffs], Sat Nov 12 15:26:23 2005 UTC (18 years, 6 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_9_BASE, OPENBSD_3_9
Changes since 1.24: +3 -8 lines
Diff to previous 1.24 (colored)

more asprintf; ok dhill@mindcry.org

Revision 1.24 / (download) - annotate - [select for diffs], Tue Apr 12 06:39:29 2005 UTC (19 years, 1 month ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_8_BASE, OPENBSD_3_8
Changes since 1.23: +4 -4 lines
Diff to previous 1.23 (colored)

handle snprintf potential -1 case

Revision 1.23 / (download) - annotate - [select for diffs], Sun Aug 8 19:04:25 2004 UTC (19 years, 9 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_7_BASE, OPENBSD_3_7, OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.22: +3 -3 lines
Diff to previous 1.22 (colored)

spacing

Revision 1.22 / (download) - annotate - [select for diffs], Fri Nov 21 22:57:32 2003 UTC (20 years, 6 months ago) by jmc
Branch: MAIN
CVS Tags: OPENBSD_3_5_BASE, OPENBSD_3_5
Changes since 1.21: +3 -3 lines
Diff to previous 1.21 (colored)

- standard SYNOPSIS
- sort OPTIONS
- s/Dq/Sq when quoting single characters
- sync usage()
- simplify macros

Revision 1.21 / (download) - annotate - [select for diffs], Thu Sep 25 07:50:22 2003 UTC (20 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.20: +27 -16 lines
Diff to previous 1.20 (colored)

realloc fixes; 3rd rev to make markus happier

Revision 1.20 / (download) - annotate - [select for diffs], Mon Aug 25 23:28:15 2003 UTC (20 years, 9 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_3_4_BASE, OPENBSD_3_4
Changes since 1.19: +17 -17 lines
Diff to previous 1.19 (colored)

rename struct dinode to ufs1_dinode.  clears the namespace and makes
way for some future work.  no function changes yet.
help testing otto@ and markus@

Revision 1.19 / (download) - annotate - [select for diffs], Tue Jul 29 18:38:36 2003 UTC (20 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.18: +4 -4 lines
Diff to previous 1.18 (colored)

spaces

Revision 1.18 / (download) - annotate - [select for diffs], Wed Jun 11 06:22:14 2003 UTC (20 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.17: +4 -3 lines
Diff to previous 1.17 (colored)

ansification

Revision 1.17 / (download) - annotate - [select for diffs], Wed Jun 4 16:24:44 2003 UTC (21 years ago) by deraadt
Branch: MAIN
Changes since 1.16: +2 -7 lines
Diff to previous 1.16 (colored)

term 3 & 4 from tholo after permission

Revision 1.16 / (download) - annotate - [select for diffs], Fri Jan 17 18:27:58 2003 UTC (21 years, 4 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_3_BASE, OPENBSD_3_3
Changes since 1.15: +110 -19 lines
Diff to previous 1.15 (colored)

Add a new option, -f, that allows the user to specify a custom output
format.  Currently only supports printing the inode number and path
(along with any arbitrary text) but other escapes may be added later.
A useful invocation is:
    ncheck -s -f '\P\0' | xargs -0 ls -ldgT

deraadt@ OK

Revision 1.15 / (download) - annotate - [select for diffs], Fri Jan 17 17:56:53 2003 UTC (21 years, 4 months ago) by millert
Branch: MAIN
Changes since 1.14: +5 -5 lines
Diff to previous 1.14 (colored)

Don't report setugid directories in "ncheck -s" output since those
bits have no meaning on OpenBSD.  deraadt@ OK

Revision 1.14 / (download) - annotate - [select for diffs], Mon Aug 12 00:42:56 2002 UTC (21 years, 9 months ago) by aaron
Branch: MAIN
CVS Tags: OPENBSD_3_2_BASE, OPENBSD_3_2
Changes since 1.13: +3 -3 lines
Diff to previous 1.13 (colored)

Swap args to calloc(3) so they are in the correct order; art@ ok.

Revision 1.13 / (download) - annotate - [select for diffs], Thu Jul 11 21:23:29 2002 UTC (21 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.12: +6 -2 lines
Diff to previous 1.12 (colored)

malloc() failure tests; rimshot@pandora.be

Revision 1.12 / (download) - annotate - [select for diffs], Wed Jul 3 22:32:33 2002 UTC (21 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.11: +20 -43 lines
Diff to previous 1.11 (colored)

ansi

Revision 1.11 / (download) - annotate - [select for diffs], Wed May 22 08:21:02 2002 UTC (22 years ago) by deraadt
Branch: MAIN
Changes since 1.10: +7 -6 lines
Diff to previous 1.10 (colored)

strcpy, sprintf death; mpech ok

Revision 1.10 / (download) - annotate - [select for diffs], Thu Mar 14 06:51:41 2002 UTC (22 years, 2 months ago) by mpech
Branch: MAIN
CVS Tags: OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.9: +9 -9 lines
Diff to previous 1.9 (colored)

Remove \n from err/errx/warn/warnx().

millert@ ok

Revision 1.9 / (download) - annotate - [select for diffs], Sat Feb 16 21:27:36 2002 UTC (22 years, 3 months ago) by millert
Branch: MAIN
Changes since 1.8: +16 -16 lines
Diff to previous 1.8 (colored)

Part one of userland __P removal.  Done with a simple regexp with some minor hand editing to make comments line up correctly.  Another pass is forthcoming that handles the cases that could not be done automatically.

Revision 1.8 / (download) - annotate - [select for diffs], Sat Dec 1 19:05:39 2001 UTC (22 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.7: +48 -27 lines
Diff to previous 1.7 (colored)

use strtoul() instead of atoi()

Revision 1.7 / (download) - annotate - [select for diffs], Mon Nov 5 07:39:16 2001 UTC (22 years, 7 months ago) by mpech
Branch: MAIN
Changes since 1.6: +4 -4 lines
Diff to previous 1.6 (colored)

kill more registers;

millert@ ok

Revision 1.6 / (download) - annotate - [select for diffs], Sat Jul 7 18:26:16 2001 UTC (22 years, 11 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0
Changes since 1.5: +13 -10 lines
Diff to previous 1.5 (colored)

major -Wall cleanup, almost complete

Revision 1.5 / (download) - annotate - [select for diffs], Wed Jan 15 23:41:30 1997 UTC (27 years, 4 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_2_9_BASE, OPENBSD_2_9, OPENBSD_2_8_BASE, OPENBSD_2_8, OPENBSD_2_7_BASE, OPENBSD_2_7, OPENBSD_2_6_BASE, OPENBSD_2_6, OPENBSD_2_5_BASE, OPENBSD_2_5, OPENBSD_2_4_BASE, OPENBSD_2_4, OPENBSD_2_3_BASE, OPENBSD_2_3, OPENBSD_2_2_BASE, OPENBSD_2_2, OPENBSD_2_1_BASE, OPENBSD_2_1
Changes since 1.4: +3 -3 lines
Diff to previous 1.4 (colored)

getopt(3) returns -1 when out of args, not EOF, whee!

Revision 1.4 / (download) - annotate - [select for diffs], Wed Aug 14 06:41:37 1996 UTC (27 years, 9 months ago) by tholo
Branch: MAIN
CVS Tags: OPENBSD_2_0_BASE, OPENBSD_2_0
Changes since 1.3: +11 -10 lines
Diff to previous 1.3 (colored)

ncheck -i would never show any information as it did not cache the directory
inodes; from OpenBSD PR #3
Also avoid recursing into . or .. directories due to misplaced test

Revision 1.3 / (download) - annotate - [select for diffs], Sun Jun 30 05:45:55 1996 UTC (27 years, 11 months ago) by tholo
Branch: MAIN
Changes since 1.2: +37 -3 lines
Diff to previous 1.2 (colored)

Accept mount points and block devices
Correct search for matched inodes

Revision 1.2 / (download) - annotate - [select for diffs], Sun Jun 30 04:43:34 1996 UTC (27 years, 11 months ago) by tholo
Branch: MAIN
Changes since 1.1: +3 -3 lines
Diff to previous 1.1 (colored)

Fix usage and manpage

Revision 1.1 / (download) - annotate - [select for diffs], Tue Jun 25 04:43:45 1996 UTC (27 years, 11 months ago) by tholo
Branch: MAIN

ncheck(8) implementation

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.