Commit Graph

205 Commits

Author SHA1 Message Date
lukem 063df7cfb7 various calcipg() fixes:
- fix round-off errors when determining the number of inodes per group,
  which often resulted in the total number of inodes in the file system
  being less than what the density asked for.
  now you might get more inodes than requested for a given density,
  rather than less.
- if the new inodes/group is <= 0, ensure that it's at least 1, preventing
  a possible division by zero or other wacky problems
- use long long instead of quad_t
2001-08-25 01:42:46 +00:00
lukem 1b81d6353d remove third argument (`int ns') from ffs_sb_swap(), and let ffs_sb_swap()
determine the endianness of the `struct fs *o' superblock from o->fs_magic
and set needswap as necessary, rather than trusting the caller to get
it right.  invariably, almost every caller of ffs_sb_swap() was calling it
with ns set to the wrong value for ns anyway!
ansi KNF ffs_bswap.c declarations whilst here.

this fixes all sorts of problems when trying to use other-endian file systems,
notably the kernel trying to access memory *way* off, possibly corrupting or
panicing, and userland programs SEGVing and/or corrupting things (e.g,
"fsck_ffs -B"  to swap a file system endianness).

whilst the previous rev of ffs_bswap.c (1.10, 2000/12/23) made this problem
worse, i suspect that the problem was always there and previous versions
just happened not to trash things at the wrong time.

FFS_EI should now be a lot more stable.
2001-08-17 02:18:46 +00:00
lukem 15af0b9ec7 when zeroing the image, use fstatfs() to find the optimal block size
(falling back to 8KB) instead of 512. should speed things up.
2001-08-08 07:34:53 +00:00
lukem 8a6a290e5a revert rev 1.48 for now, until i'm sure the malloc (et al) rename is
safe (since there's two separate mallocs using sbrk(2) in that case)

XXX: local malloc provided for mfs memory store allocation; need to
investigate if system (phk) malloc can be used instead.
2001-07-31 01:31:26 +00:00
lukem 2b2279d9a5 - constify mkfs()'s first arg
- slightly reorder steps in -F image creation
2001-07-30 07:45:08 +00:00
lukem 852833fff1 rename and hide: malloc->Malloc, calloc->Calloc, free->Free. (remove realloc) 2001-07-30 07:13:58 +00:00
lukem 1c37a982fa enable WARNS=2 2001-07-29 09:59:12 +00:00
lukem 14929f77ab * add -F option: enable creation of file system in a regular file. a "fake"
disklabel is created as per mfs on "swap".
* add -Z option: pre-zero the -F image file before use. this is necessary if
  the image is to be used with vnd(4) because by default the files created
  with -F have "holes" and vnd doesn't cope with that.
* support 'k', 'm', 'g' suffixes for all options which take numeric arguments.
  provide strsuftoi() which performs the parsing mechanism.
* improve man page description of various options
* replace "filesystem" with "file system"
* when displaying usage for mfs, only list mfs options
* minor KNF and WARNS=2 cleanups
2001-07-29 09:55:22 +00:00
lukem c67d40dc35 improve message describing MAXCSBUFS overflow 2001-07-27 15:19:33 +00:00
lukem bc1974136c s/filesystem/file system/ 2001-07-27 06:41:02 +00:00
lukem 8a54ab244e clean up for WARNS=2 by renaming some local variables that shadow globals 2001-07-26 22:59:57 +00:00
lukem b6172cb606 - check return value of calloc() in mkfs()
- in replacement malloc(), if sbrk(2) returns (void *)-1, convert to NULL
  before returning
- in replacement calloc(), check return value of malloc() before zeroing result
2001-07-26 16:53:39 +00:00
lukem 91d95899b4 remove unnecessary duplicate initialisation of sblock.fs_clean 2001-07-26 03:46:57 +00:00
mrg 55e0fea74f s/primary swap area/first swap area/ 2001-06-07 14:52:50 +00:00
wiz 73f545bb5b Drop arguments of .Os. 2001-06-05 11:22:41 +00:00
wiz 6fccda72ed Don't xref format(8) -- the man pages we have for it (hp300/vax) don't
seem very interesting at all, if not even obsolete.
Whitespace fixes while I'm here.
2001-04-03 11:21:57 +00:00
ad edb647f542 Fix typo. 2001-03-02 17:57:34 +00:00
cgd 8a986b2e96 convert to use getprogname() 2001-02-19 22:48:57 +00:00
enami 2f0c4425ee Don't swap clustersum[0]. It's not a cluster summery but block free bitmap. 2000-12-23 12:32:12 +00:00
scw 222e7ea5ea Fix a bug introduced by 4.4-Lite:
Don't try to subtract the address of "acg.cg_firstfield" from
"acg.cg_nextfreeoff", as it's already relative to the start of "&acg".
This always worked because the result of the subtraction was
always negative, thus could never be > "sblock.fs_cgsize" ...
2000-12-04 09:59:48 +00:00
simonb c878d09614 For mount_mfs, allow an 'm' suffix to the file system size option to
specify the size of the mfs in megabytes.

Inspired by the Solaris tmpfs "-o size=sz" option.
2000-12-01 12:48:09 +00:00
simonb b234617a20 Put extern variable declarations in "extern.h". 2000-12-01 12:03:27 +00:00
simonb 06cbcf7494 ANSIfy. 2000-12-01 11:52:54 +00:00
is 9979da6cbb Format string cleanups by Bill Sommerfeld. 2000-10-10 20:24:49 +00:00
bouyer bacd71f681 Check the number of cylinder group summary area against MAXCSBUFS. fsck and
the kernel will happilly trash data after fs_csp[] in the superblock with
a large number of cylinder group.
2000-05-22 10:33:45 +00:00
wrstuden 398c91fa04 Adjust column-sizing code to keep output in 76 character lines, so output
doesn't wrap in sysinst.
1999-07-30 17:44:01 +00:00
wrstuden 6f14acdddf If -c not set on command line and the partition has a non-zero cpg
value, use it for the number of cylinders per group. So now the value
in the disklabel does something. :-)
1999-05-19 00:25:59 +00:00
ad 64a1f3885d Add NOTES section. Indicate that fstype in disklabel should be set to 4.2BSD. 1999-05-16 20:58:49 +00:00
wrstuden 6735cc1a4c Make newfs's spare superblock output nicer. Figure out how wide the
largest block number will be, and make the columns wide enough for it. Then
make enough columns to fit in an 80 character window.

Samples: small end & faked up values:

super-block backups (for fsck -b #) at:
   32,  176,  272,  416,  512,  656,  752,  896,  992, 1136, 1232, 1376, 1472,
 1616, 1712, 1856, 1952, 2096, 2192, 2336, 2432, 2576, 2672, 2816, 2912, 3056,
 3152, 3296, 3392, 3536, 3632, 3776, 3872, 4016, 4112, 4256, 4352, 4496, 4592,

For a 155 GB fs we have:

super-block backups (for fsck -b #) at:
       128,     65792,    131456,    197120,    262784,    328448,    394112,
    459776,    525440,    591104,    656768,    722432,    788096,    853760,
    919424,    985088,   1050752,   1116416,   1182080,   1247744,   1313408,
   1379072,   1444736,   1510400,   1576064,   1641728,   1707392,   1773056,
...
 317462144, 317527808, 317593472, 317659136, 317724800, 317790464, 317856128,
 317921792, 317987456, 318053120, 318118784, 318184448, 318250112, 318315776,
 318381440, 318447104, 318512768, 318578432,

Now it actually looks like someone's thought about making large fs's. :-)
1999-05-14 22:36:50 +00:00
wrstuden f2c170eda0 Modify newfs so that the root node (and lost+found dir, if created)
of the new fs has uid.gid equal to the euid.egid of the process
which made it. This change permits users who have write access to
a device (say a floppy) to create a filesystem that, when mounted,
they have write access to.

This change closes PR bin/5990 from jbernard@ox.mines.edu, and is also the
change requested in PR bin/6276 from "Charles M. Hannum" <mycroft@netbsd.org>
1999-03-16 21:52:34 +00:00
wrstuden 988bdf8e19 Modify how the byteswapping of the cylinder summaries is handled. If we
need to swap, allocate a buffer for the swapped summaries rather than using
writebuf. The latter is fixed at 64k, which is only enough room to hold
4096 summaries. Creating an fs with more results in a buffer overrun.

First noted by Matt Jacob mjacob@netbsd.org, and fixed by Albeaus
Bayucan, bayucan@nas.nasa.gov. Minor mods by me.
1999-03-11 20:23:58 +00:00
mycroft f6590b22cd Clean up SYNOPSIS formatting. 1999-03-07 11:02:05 +00:00
tron 3ef6c36461 Include "disktab.h" to get prototype for getdiskbyname(). 1999-01-19 19:34:50 +00:00
bouyer 3e3f9c7795 #include machine/bswap.h and remove -lutil. 1999-01-15 13:32:05 +00:00
simonb 00c4adc933 Explicitly zero "node" before we start using it. 1998-11-03 18:14:55 +00:00
thorpej a2d370bc46 Use DINODE_SIZE instead of sizeof(struct dinode). Also, eliminate some
unnecessary pointer casts.
1998-10-23 00:39:15 +00:00
mycroft 243b42b3bc Use the default calculation of maxcontig, based on fs_bsize and MAXPHYS, so
that the cluster summary information is correct for bsize=4k and MAXPHYS=64k.
1998-10-22 08:55:42 +00:00
matt f8bd2123f3 vax -> __vax__ 1998-10-20 01:48:14 +00:00
mycroft 519d858510 __AUDIT__ cleanup. 1998-07-28 19:22:54 +00:00
mycroft 89e1507edb Add a reference to fsirand(8). 1998-05-07 03:40:48 +00:00
fair 3d7afc6d03 fix bad .Xr references 1998-04-29 09:49:10 +00:00
kleink 31e5ddfa12 Need <time.h> for time() prototype. 1998-04-01 15:28:12 +00:00
bouyer 15c41b2f72 Allow creation of non-native byteorder FFS (via the '-B' option). 1998-03-18 17:10:15 +00:00
fvdl e5bc90f40c Merge with Lite2 + local changes 1998-03-01 02:20:01 +00:00
perry 34a98169f0 macroize BSD, NetBSD, FreeBSD and misc cleanup 1998-02-06 05:54:12 +00:00
drochner 604ab80fa9 mount_mfs: avoid spurious error message if the mount system call returns
for "valid reasons" (ie, "mount -u")
1997-11-19 09:48:52 +00:00
drochner 55f4357866 Make "mount_mfs" behave synchronously - don't exit before the mount is
done. This has 2 advantages:
-The calling process can rely on the mounted filesystem.
-We get error messages if the mount system call fails.
1997-11-01 18:25:46 +00:00
christos e230a48b57 CFLAGS->CPPFLAGS 1997-10-10 19:47:50 +00:00
enami 0d8fa88b1f Don't declare optind and optarg. 1997-10-01 02:21:34 +00:00
enami 7b4b674241 When calling err(3),
- Don't output unnecessary colon and space, and
- Include the name of system call just called.
1997-09-29 05:18:00 +00:00
jeremy f83ae6979b Quell gcc 2.7.2 initialization warning. 1997-09-21 08:32:04 +00:00
lukem ec31f79470 * resolve conflicts from lite-2 import
* use int32_t instead of long
1997-09-16 14:05:39 +00:00
lukem 2ddc10a0ab define WARNS?=1 for all of sbin/* 1997-09-15 12:45:47 +00:00
lukem 1a96f83dbe * getopt returns -1 not EOF
* fix .Nm usage
1997-09-15 06:23:03 +00:00
christos bec3b005c5 Fix compiler warnings. 1997-06-30 22:20:30 +00:00
tls 4a70009927 I don't understand just what exactly changed in the past week that the GDINFO ioctl call here would smash the value of 'fd' and fail, but making fd volatile seems to fix it, for this program at least. 1997-06-30 08:09:22 +00:00
gwr 10e180cc49 Back out the .PATH.c changes. The .depend problem (and others)
will be fixed using the new .NOPATH make feature instead.
1997-05-08 21:11:01 +00:00
gwr 012e528f2e Use .PATH.c: ... 1997-05-06 20:44:56 +00:00
mouse 80c0d60f84 alternate -> alternative, per PR 2643 1997-03-08 13:47:08 +00:00
tls aeb2ee9ac9 add support for noatime mount flag 1997-01-30 09:56:10 +00:00
mikel 8a207c6ea3 eliminate obsolete reference to mkfs(8);
from Klaus Klein <kleink@layla.inka.de>.
also fixed buggy -a flag lines, reference fsck_ffs(8) instead of fsck(8).
1996-12-26 04:37:18 +00:00
cgd c1eeddcff9 this file system (according to its source) supports MNT_UPDATE. Therefore
the mount program must recognize the 'update' option.
1996-10-23 22:46:16 +00:00
perry 7bc26fc852 Remove #ifdef tahoe conditionals. We have no tahoe port. There is
still a big #if vax in this file which should be removed if possible --
#ifdef MACHINE stuff in mi code is bad.
1996-10-18 07:16:02 +00:00
mrg 9be9a14c1a update to reality. from mike long (pr#2517) 1996-06-06 15:23:47 +00:00
thorpej 37b8aea219 Use getmaxpartitions() from libutil, not a homegrown version. 1996-05-16 07:13:01 +00:00
thorpej d535998d4b Use sysctl() to determine maxpartitions. Fixes pr #970. 1995-06-28 02:21:02 +00:00
cgd 93a2f4ea60 update for posixified stat structure 1995-06-18 21:35:33 +00:00
mycroft ae16273156 Back out previous change. 1995-06-11 05:16:04 +00:00
cgd 788733b7a9 typeof(timeval.tv_sec) != time_t 1995-06-07 17:14:21 +00:00
jtc 2d709c7062 flush stdout instead of stderr, so that each block number is displayed
as it is printed.  From PR 989.
1995-05-06 06:55:34 +00:00
mycroft 5a76ea02ce Set the `clean' flag. 1995-04-12 21:24:31 +00:00
cgd 0cc5c1886a short -> int16_t in a couple of places 1995-03-21 01:28:05 +00:00
cgd 0114e805ce convert to new RCS Id conventions; reduce my headache 1995-03-18 14:54:19 +00:00
cgd 909eb54fbb calculate the 'offset' argument to lseek() in a prettier way, more
consistent with the way fsck(8) does it.  no functional change.
1995-03-18 07:02:29 +00:00
cgd f9b9202a22 flush stdout after printing each alternate superblock location. 1995-03-04 06:28:20 +00:00
cgd 4c02b41140 fix up inconsisten uses of lseek(). (three uses. one hard-coded 'whence'
as a number, one used an L_ constant and the other used a SEEK_ constant!)
1995-03-04 06:10:39 +00:00
mycroft 705a6ebacb Use S_IS*(). 1995-01-30 19:39:36 +00:00
cgd 06e2955ff1 specify man pages the new way. 1994-12-22 10:44:04 +00:00
cgd 74104b5039 compile against new headers. 1994-12-18 16:00:21 +00:00
cgd 65a65336a8 adjust the documentation to note that 'swap' can be used instead of a dev. 1994-12-18 06:10:22 +00:00
cgd 4c998ed311 type size paranoia, and allow one to mount an mfs on the device 'swap',
so that diskless machines can use MFS /tmp directories.
1994-12-18 05:09:39 +00:00
mycroft 4c78b5e610 Use defaults that are more reasonable for modern disks, and document the `-n'
option.
1994-12-01 18:46:37 +00:00
cgd 86400f0f91 types/field names. 1994-10-31 04:22:12 +00:00
mycroft 4922d725cf Remove some more uses of obsolete functions. 1994-09-23 23:48:10 +00:00
mycroft ea7b5d4ec6 Eliminate uses of some obsolete functions. 1994-09-23 14:26:58 +00:00
cgd 040aaa7707 fix from Peter Galbavy <peter@alice.wonderland.org>: don't overflow 80cols. 1994-07-20 20:31:58 +00:00
cgd cbc266d592 fix that annoying 'cgd0: bad magic number' bug 1994-07-20 20:06:52 +00:00
jtc 8477715ae7 Change mfs in Synopsis to mount_mfs. 1994-07-16 05:18:11 +00:00
mycroft 625a6892f7 Update from 4.4-Lite, with local changes. 1994-06-08 19:27:32 +00:00
cgd ceeb9f072d various grunge 1994-04-25 18:28:36 +00:00
cgd f01b9646e3 back to 10%, per mkm 1994-04-20 03:56:03 +00:00
cgd 3eff8b176a 10 -> 5 1994-04-12 04:39:57 +00:00
cgd 59e72907cf off_t death... 1994-04-01 08:42:43 +00:00
chopps c46eb1bc76 added -D${MACHINE} for amiga's becuase of differing sizeof (struct disklabel) 1994-02-12 17:49:32 +00:00
cgd 0acef81434 numeric -> symbolic constant 1994-02-06 08:19:56 +00:00
cgd 884899f81f MINFREE defaults to 5% per mckusick 1994-01-28 06:02:57 +00:00
mycroft d9e1211542 Set clean flags. 1993-10-01 01:56:42 +00:00
mycroft e9d867ef50 Add RCS identifiers. 1993-08-01 17:54:45 +00:00
mycroft dfb9caab49 Add RCS indentifiers. 1993-08-01 07:32:48 +00:00
mycroft 1fb80e5b34 Add RCS identifiers. 1993-08-01 05:26:30 +00:00
cgd cbdb50c1c1 incorporate changes from 0-9-base to 0-9-ALPHA 1993-07-28 00:56:43 +00:00
mycroft ac2b12c76f Don't mix ANSI and pre-ANSI varargs. 1993-04-18 18:46:43 +00:00
cgd 06be60083d changed "Id" to "Header" for rcsids 1993-03-23 00:22:59 +00:00
cgd 346aa5dd48 added rcs ids to all files 1993-03-22 08:04:00 +00:00
cgd 61f282557f initial import of 386bsd-0.1 sources 1993-03-21 09:45:37 +00:00