Commit Graph

22 Commits

Author SHA1 Message Date
Kirk McKusick
92c839a156 The libufs library needs to track and free the new fs_si structure
in addition to the fs_csp structure that it references.

PR:           247425
Sponsored by: Netflix
2020-06-23 21:28:26 +00:00
Kirk McKusick
5613df4f66 The ufs_disk_write() function is used to upgrade a read-only descriptor
to a read-write descriptor. Do not close the read-only descriptor until
the read-write is successfully obtained. Before this fix, a failed upgrade
left no usable descriptor with which to work.
2018-04-08 06:59:42 +00:00
Kirk McKusick
6a3fe71314 Missing disk close in libufs. 2017-12-26 23:16:11 +00:00
Pedro F. Giffuni
5e53a4f90f lib: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using mis-identified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-26 02:00:33 +00:00
Jeff Roberson
113db2dddb - Merge soft-updates journaling from projects/suj/head into head. This
brings in support for an optional intent log which eliminates the need
   for background fsck on unclean shutdown.

Sponsored by:   iXsystems, Yahoo!, and Juniper.
With help from: McKusick and Peter Holm
2010-04-24 07:05:35 +00:00
Juli Mallett
990b6d05ab Allow libufs(3) functions to operate on a regular file. This makes it possible to
use almost anything that uses libufs(3) against a file as an unprivileged user, e.g.
tunefs(8) and dumpfs(8) against a makefs(8)-created image.

Prodded by:	kensmith
2009-06-11 18:04:57 +00:00
Pawel Jakub Dawidek
fa1abc314f The ufs_disk_fillout(3) can take special device name (with or without /dev/
prefix) as an argument and mount point path. At the end it has to find
device name file system is stored on, which means when mount point path is
given, it tries to look into /etc/fstab and find special device
corresponding to the given mount point. This is not perfect, because it
doesn't handle the case when file system is mounted by hand and mount point
is given as an argument.

I found this problem while trying to use snapinfo(8), which passes mount
points to the ufs_disk_fillout(3) function, but I had file system mounted
manually, so snapinfo(8) was exiting with the error below:

	ufs_disk_fillout: No such file or directory

I modified libufs(3) to handle those arguments (the order is important):

1. special device with /dev/ prefix
2. special device without /dev/ prefix
3. mount point listed in /etc/fstab, directory exists
4. mount point listed in /etc/fstab, directory doesn't exist
5. mount point of a file system mounted by hand
2007-03-16 03:13:28 +00:00
Juli Mallett
b52f85e743 Remove ufs_disk_ctor and ufs_disk_dtor, they never came to fruition. I do
not know of any software using them, and there is no "published API" for
libufs, as it were.
2003-06-09 09:47:38 +00:00
Juli Mallett
1081253fa0 Reduce diffs with code in Perforce:
Parenthesise return values.
2003-06-09 09:32:29 +00:00
Juli Mallett
7a51271b68 Close the disk file descriptor that is RO before trying to open the
new one, and do not fall back to the RO fd.  There was a bug here
in that the RO fd was never closed, if the RDRW open succeeded, but
this code is bogus anyway, and it breaks newfs of floppies, at least
for me, due to "Device busy."  Anything that wants to fall back is
doing something significantly odd that it should have some more complex
code on its end.
2003-03-28 01:50:11 +00:00
Juli Mallett
9e4789cc2f Missing "return 0"
Big pointy hat to:	jmallett
Spotted by:		peter
2003-01-30 00:10:24 +00:00
Juli Mallett
7dc95357f8 API for opening (and tracking) writable file descriptors per disk. 2003-01-29 23:19:46 +00:00
Juli Mallett
d934deeff9 API to fillout a blank disk. For e.g. newfs. 2003-01-23 21:32:56 +00:00
Juli Mallett
cc3dd52898 Store not only the current cylinder group in the series (i.e. next that needs
to be read in) but also the last cylinder group in the series (i.e. what is
stored in the structure).
2003-01-19 05:46:23 +00:00
Juli Mallett
22ec2ef3bb Add facility to read one, or a string of, cylinger groups. 2003-01-19 01:31:26 +00:00
Juli Mallett
656128586d Hunt for a disk to operate on, if we're passed a partition mountpoint, etc.
Concept reviewed by:	phk
2003-01-19 00:43:17 +00:00
Juli Mallett
49b2a6863b Nuke dumb error reporting code, people can just use disk::d_error. Unify the
DEBUG and d_error initialisation into an ERROR macro, which can both trace and
set the d_error field.  Much a more meaningful thing, I should say.
2003-01-18 04:22:14 +00:00
Juli Mallett
8b8cd35523 Add the concept of a per-disk error string, and a function which prints it
along with the errno, if one is set.
2002-10-22 19:25:58 +00:00
Juli Mallett
e079a00a77 Initialise disk->d_ufs so that in sblock.c it's always initialised
(unless someone tries to use libufs support functions without using
	_fillout or _ctor to construct a uufsd.)

Obtained from:	jmallett_libufs Perforce branch.
2002-08-11 15:37:10 +00:00
Juli Mallett
cf6c0643ee Fill out (zero) and fill in (when doing getino()) the minimum and maximum
inodes in our inoblock (disk->d_ino{min,max}) appropriately.
2002-07-11 21:27:26 +00:00
Juli Mallett
585e540203 In getino, have our DEBUG message in the unhandled case mention that it
does not know what sort of UFS filesystem this is.

Add some DEBUG(NULL)'s to function entry points.
2002-07-01 18:19:20 +00:00
Juli Mallett
20938dbf84 Add libufs, a library for dealing with UFS filesystems from userland to
the build.  It is here to compartmentalise functionality currently duplicated
in many notable programs in the base system.  It currently handles block
reads and writes, as well as reading and writing of the filesystem superblock,
and the reading/lookup of inode data.  It supports both UFS and UFS2.  I
will be maintaining it, and porting programs to use it, however for now, it
is simply being built as part of world.
2002-07-01 01:45:03 +00:00