aboutsummaryrefslogtreecommitdiff
path: root/lib/libufs/block.c
Commit message (Collapse)AuthorAgeFilesLines
* lib: Automated cleanup of cdefs and other formattingWarner Losh2023-11-271-1/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* Ensure I/O buffers in libufs(3) are 128-byte aligned.Kirk McKusick2023-11-171-32/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | Various disk controllers require their buffers to be aligned to a cache-line size (128 bytes). For buffers allocated in structures, ensure that they are 128-byte aligned. Use aligned_malloc to allocate memory to ensure that the returned memory is 128-byte aligned. While we are here, we replace the dynamically allocated inode buffer with a buffer allocated in the uufsd structure just as the superblock and cylinder group buffers do. This can be removed if/when the kernel is fixed. Because this problem has existed on one I/O subsystem or another since the 1990's, we are probably stuck with dealing with it forever. The problem most recent showed up in Azure, see: https://reviews.freebsd.org/D41728 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267654 Before these fixes were applied, it was confirmed that the changes in this commit also fixed the issue in Azure. Reviewed-by: Warner Losh, kib Tested-by: Souradeep Chakrabarti of Microsoft (earlier version) PR: 267654 Differential Revision: https://reviews.freebsd.org/D41724
* 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
* 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
* 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
* Make berase() work on platforms whose kernel lacks DIOCGDELETE ioctl.Robert Millan2011-12-081-5/+48
| | | | | | | Approved by: kib (mentor) Notes: svn path=/head/; revision=228349
* Bail out when memory allocation is failed, rather than referencingXin LI2009-04-021-2/+6
| | | | | | | | | | a NULL pointer. PR: kern/94480 Submitted by: Michiel Pelt <m.pelt xs4all nl> Notes: svn path=/head/; revision=190646
* Add a berase() function which uses ioctl(DIOCGDELETE) to erase a slabPoul-Henning Kamp2007-12-161-0/+19
| | | | | | | of the disk. Notes: svn path=/head/; revision=174668
* Add XXX'ed temporary bounce-buffering.Poul-Henning Kamp2003-10-071-6/+37
| | | | Notes: svn path=/head/; revision=120874
* Reduce diffs with code in Perforce:Juli Mallett2003-06-091-6/+6
| | | | | | | Parenthesise return values. Notes: svn path=/head/; revision=116084
* MFp4: Fix copy&paste English error.Juli Mallett2003-03-301-1/+1
| | | | Notes: svn path=/head/; revision=112850
* Clean up error reporting in block.c, so that it gives honest error stringsJuli Mallett2003-02-191-9/+18
| | | | | | | | | | | | | | | | | | | | | | | for the sorts of errors we run into[1]. This also gives us room to put in a vaguely appropriate casts to silence warnings since our compiler doesn't like when we compare ssize_t to size_t[2]. Add a cast in sblock.c[3] to silence a warning because of signed vs. size_t hell (again). Clean up nearby excessive parenthemutilation[4]. Reviewed by: bde [2] [3] Suggested by: bde, many [1] Submitted by: bde [4] An aside about [4], bde notes that we do not check for a negative value for the fs bsize. I'm nto going to do that in every situation we use it, one must expect a reasonable program to pass down reasonable values. Some foot shooting protection I will tolerate, some I will not. Also he suggests some possible conditional improvements there, which I may take to heart. PS: For me at least, this is now WARNS=5 clean... Notes: svn path=/head/; revision=111111
* API for opening (and tracking) writable file descriptors per disk.Juli Mallett2003-01-291-8/+3
| | | | Notes: svn path=/head/; revision=110066
* bwrite, not sbwrite, needs to open for writing and write.Juli Mallett2003-01-231-0/+13
| | | | Notes: svn path=/head/; revision=109766
* Don't crash when utilities are dumb and try to read less than the disk blockJuli Mallett2003-01-191-1/+1
| | | | | | | | size (dumpfs may try to read the cylinder size (or is is sector size?) by way of bread). Prevents a bounds error. Notes: svn path=/head/; revision=109511
* Nuke dumb error reporting code, people can just use disk::d_error. Unify theJuli Mallett2003-01-181-6/+4
| | | | | | | | 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
* Add libufs, a library for dealing with UFS filesystems from userland toJuli Mallett2002-07-011-0/+87
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