aboutsummaryrefslogtreecommitdiff
path: root/lib/libufs/type.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* Add a flags parameter to the ffs_sbget() function that reads UFS superblocks.Kirk McKusick2022-07-311-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than trying to shoehorn flags into the requested superblock address, create a separate flags parameter to the ffs_sbget() function in sys/ufs/ffs/ffs_subr.c. The ffs_sbget() function is used both in the kernel and in user-level utilities through export to the sbget() function in the libufs(3) library (see sbget(3) for details). The kernel uses ffs_sbget() when mounting UFS filesystems, in the glabel(8) and gjournal(8) GEOM utilities, and in the standalone library used when booting the system from a UFS root filesystem. The ffs_sbget() function reads the superblock located at the byte offset specified by its sblockloc parameter. The value UFS_STDSB may be specified for sblockloc to request that the standard location for the superblock be read. The two existing options are now flags: UFS_NOHASHFAIL will note if the check hash is wrong but will still return the superblock. This is used by the bootstrap code to give the system a chance to come up so that fsck can be run to correct the problem. UFS_NOMSG indicates that superblock inconsistency error messages should not be printed. It is used by programs like fsck that want to print their own error message and programs like glabel(8) that just want to know if a UFS filesystem exists on a partition. One additional flag is added: UFS_NOCSUM causes only the superblock itself to be returned, but does not read in any auxiliary data structures like the cylinder group summary information. It is used by clients like glabel(8) that just want to check for possible filesystem types. Using UFS_NOCSUM skips the superblock checks for csum data which allows superblocks that have corrupted csum data to be read and used. The validate_sblock() function checks that the superblock has not been corrupted in a way that can crash or hang the system. Unless the UFS_NOMSG flag is specified, it will print out any errors that it finds. Prior to this commit, validate_sblock() returned as soon as it found an inconsistency so would print at most one message. It now does all its checks so when UFS_NOMSG has not been specified will print out everything that it finds inconsistent. Sponsored by: The FreeBSD Foundation
* Add d_sblockloc to libufs(3) disk structure to allow options to be added.Kirk McKusick2022-07-251-0/+1
| | | | | | | | | | | By making the disk block parameter used by the libufs(3) sbread(3) function visible, applications using sbread(3) can set their own addition options such as using the STDSB_NOHASHFAIL request to say that they want the superblock read to succeed even when the superblock checkhash is incorrect. While here also add an error message when a check-hash failure is detected.
* Remove #define _KERNEL hacks from libprocstatKonstantin Belousov2021-02-211-0/+2
| | | | | | | | | | | | | | | | | | Make sys/buf.h, sys/pipe.h, sys/fs/devfs/devfs*.h headers usable in userspace, assuming that the consumer has an idea what it is for. Unhide more material from sys/mount.h and sys/ufs/ufs/inode.h, sys/ufs/ufs/ufsmount.h for consumption of userspace tools, with the same caveat. Remove unacceptable hack from usr.sbin/makefs which relied on sys/buf.h being unusable in userspace, where it override struct buf with its own definition. Instead, provide struct m_buf and struct m_vnode and adapt code to use local variants. Reviewed by: mckusick Tested by: pho Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D28679
* The libufs library needs to track and free the new fs_si structureKirk McKusick2020-06-231-4/+5
| | | | | | | | | | in addition to the fs_csp structure that it references. PR: 247425 Sponsored by: Netflix Notes: svn path=/head/; revision=362559
* The ufs_disk_write() function is used to upgrade a read-only descriptorKirk McKusick2018-04-081-4/+7
| | | | | | | | | 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. Notes: svn path=/head/; revision=332266
* Missing disk close in libufs.Kirk McKusick2017-12-261-0/+1
| | | | Notes: svn path=/head/; revision=327227
* lib: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-261-1/+3
| | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=326219
* - Merge soft-updates journaling from projects/suj/head into head. ThisJeff Roberson2010-04-241-0/+5
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=207141
* Allow libufs(3) functions to operate on a regular file. This makes it ↵Juli Mallett2009-06-111-1/+4
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=194030
* The ufs_disk_fillout(3) can take special device name (with or without /dev/Pawel Jakub Dawidek2007-03-161-7/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=167625
* Remove ufs_disk_ctor and ufs_disk_dtor, they never came to fruition. I doJuli Mallett2003-06-091-41/+0
| | | | | | | | not know of any software using them, and there is no "published API" for libufs, as it were. Notes: svn path=/head/; revision=116086
* Reduce diffs with code in Perforce:Juli Mallett2003-06-091-14/+14
| | | | | | | Parenthesise return values. Notes: svn path=/head/; revision=116084
* Close the disk file descriptor that is RO before trying to open theJuli Mallett2003-03-281-4/+1
| | | | | | | | | | | | 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. Notes: svn path=/head/; revision=112730
* Missing "return 0"Juli Mallett2003-01-301-0/+1
| | | | | | | | Big pointy hat to: jmallett Spotted by: peter Notes: svn path=/head/; revision=110067
* API for opening (and tracking) writable file descriptors per disk.Juli Mallett2003-01-291-0/+26
| | | | Notes: svn path=/head/; revision=110066
* API to fillout a blank disk. For e.g. newfs.Juli Mallett2003-01-231-5/+12
| | | | Notes: svn path=/head/; revision=109755
* Store not only the current cylinder group in the series (i.e. next that needsJuli Mallett2003-01-191-0/+1
| | | | | | | | to be read in) but also the last cylinder group in the series (i.e. what is stored in the structure). Notes: svn path=/head/; revision=109518
* Add facility to read one, or a string of, cylinger groups.Juli Mallett2003-01-191-0/+1
| | | | Notes: svn path=/head/; revision=109509
* Hunt for a disk to operate on, if we're passed a partition mountpoint, etc.Juli Mallett2003-01-191-2/+40
| | | | | | | Concept reviewed by: phk Notes: svn path=/head/; revision=109506
* Nuke dumb error reporting code, people can just use disk::d_error. Unify theJuli Mallett2003-01-181-13/+22
| | | | | | | | 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. Notes: svn path=/head/; revision=109462
* Add the concept of a per-disk error string, and a function which prints itJuli Mallett2002-10-221-0/+2
| | | | | | | along with the errno, if one is set. Notes: svn path=/head/; revision=105737
* Initialise disk->d_ufs so that in sblock.c it's always initialisedJuli Mallett2002-08-111-0/+1
| | | | | | | | | | (unless someone tries to use libufs support functions without using _fillout or _ctor to construct a uufsd.) Obtained from: jmallett_libufs Perforce branch. Notes: svn path=/head/; revision=101687
* Fill out (zero) and fill in (when doing getino()) the minimum and maximumJuli Mallett2002-07-111-0/+2
| | | | | | | inodes in our inoblock (disk->d_ino{min,max}) appropriately. Notes: svn path=/head/; revision=99823
* In getino, have our DEBUG message in the unhandled case mention that itJuli Mallett2002-07-011-0/+2
| | | | | | | | | does not know what sort of UFS filesystem this is. Add some DEBUG(NULL)'s to function entry points. Notes: svn path=/head/; revision=99222
* Add libufs, a library for dealing with UFS filesystems from userland toJuli Mallett2002-07-011-0/+114
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. Notes: svn path=/head/; revision=99193