Commit Graph

413 Commits

Author SHA1 Message Date
christos 0fe82aa40b Add an option to warn and error out for mtree missing entries. 2024-05-08 15:57:56 +00:00
rillig 9e59e5f95f makefs: fix out-of-bounds fsnode count in fsnode_sort
Found by running './makefs img.dat cd9660'.

While here, apply more KNF.
2024-04-24 21:59:39 +00:00
christos 514871bdef use __func__ 2024-04-24 14:23:37 +00:00
christos c7e1aa689d make a separate sorting function and KNF (thanks rillig) 2024-04-24 14:02:39 +00:00
christos a5d2beee4d pass lint, simplify 2024-04-23 22:18:56 +00:00
christos c7526c4ece makefs: Fix symlink permission bits
Permission bits for symlinks are taken straight from `lstat()`. However, the
actual bits presented to the user are filesystem/kernel specific. For example,
Linux with ext2/3/4 will use 0777 for symlinks, whereas NetBSD/FFS will
show 0755. As far as `makefs` is in the loop, the target filesystem will likely
be FFS, so use 0755.
2024-04-23 22:12:48 +00:00
christos c50dd23e93 makefs: Sort directory contents by name (Jan-Benedict Glaw)
`makefs` inserts nodes into its internal data structures in the order as
returned by `readdir()` calls. As this is unpredictable, sort entries by
name before creating the target filesystem.

  This is done by first converting the (per-directory) linked list into
a plain array, sort it, finally re-link the list. Special case for the
sorting function: The "." directory entry seems to be ment to be always
at the front, so always check that first.
2024-04-23 22:12:16 +00:00
tkusumi 0b920f749a makefs/msdos: Fix broken [extra-directory ...] case
"path + cur->name" is not same as "cur->root + cur->path + cur->name"
for extra-directory files, as extra-directory files are
in different location. Do what makefs ffs code does.
2024-02-29 08:13:52 +00:00
christos 855b7dce54 Add an options pretty-printer, pass some lint. 2024-02-18 16:59:16 +00:00
christos ca46f897d1 PR/57945: Jan-Benedict Glaw: makefs: msdos filesystems with label not
reproducible.
When we specify a label, the volume label is used to create the root dir
and it gets stamped by the timestamp. We were trying to set the timestamp
in the fs-specific part of the options parsing which did not work since
the method was called only for fs_specific options. Move setting of the
timestamp just before we create the fs, where we reconcile the rest of
the options.
2024-02-18 16:58:51 +00:00
msaitoh 6da2a6ed01 s/strucutre/structure/ in comment. 2024-02-07 04:00:10 +00:00
tsutsui ec5d1d8226 Use EXIT_SUCCESS and EXIT_FAILURE where appropriate per style guide. 2023-12-28 12:13:55 +00:00
tsutsui f083387bcd Return a proper exit status on failure on creating msdosfs.
No particular comment in PR bin/57752.
Should be pulled up to netbsd-10 and netbsd-9.
2023-12-20 15:07:16 +00:00
lukem a9a927dd92 adapt to ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}
Simplify CWARNFLAGS to use ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}
which works for both clang and gcc, and remove compiler-specific
equivalents.
2023-06-03 21:26:27 +00:00
lukem c4b7a9e794 bsd.own.mk: rename GCC_NO_* to CC_WNO_*
Rename compiler-warning-disable variables from
	GCC_NO_warning
to
	CC_WNO_warning
where warning is the full warning name as used by the compiler.

GCC_NO_IMPLICIT_FALLTHRU is CC_WNO_IMPLICIT_FALLTHROUGH

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
2023-06-03 09:09:01 +00:00
lukem f937c412f3 bsd.own.mk: rename to CC_WNO_ADDRESS_OF_PACKED_MEMBER
Provide a single variable
	CC_WNO_ADDRESS_OF_PACKED_MEMBER
with options for both clang and gcc, to replace
	CLANG_NO_ADDR_OF_PACKED_MEMBER
	CC_NO_ADDR_OF_PACKED_MEMBER
	GCC_NO_ADDR_OF_PACKED_MEMBER

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
2023-06-03 08:52:53 +00:00
christos 7e2bdad6d9 Move date setting into cd9660_populate_iso_dir_record so there is no
path that leaves it unset.

From FreeBSD https://reviews.freebsd.org/D39258
2023-04-18 23:05:51 +00:00
christos 8399b2db93 We previously attempted to emit Rock Ridge NM records only when the name
represented by the Rock Ridge extensions would actually differ. We would
omit the record for an all-upper-case directory name, however Linux (and
perhaps other operating systems) map names with no NM record to
lowercase.

This affected only directories, as file names have an implicit ";1"
version number appended and thus always differ.  To solve, just emit NM
records for all entries other than DOT and DOTDOT .

We could continue to omit the NM record for directories that would avoid
mapping (for example, one named 1234.567) but this does not seem worth
the complexity.

From FreeBSD https://reviews.freebsd.org/D39258
2023-04-18 23:02:51 +00:00
christos 88133efe71 The boot catalog pointer is a DWord, but we previously populated it via
cd9660_bothendian_dword which overwrote four unused bytes following it.
See El Torito 1.0 (1995) Figure 7 for details.

Found by Coverity on FreeBSD
2023-04-18 23:00:02 +00:00
christos 4c1d366af2 See RRIP 4.1.4 Description of the "NM" System Use Entry for details.
From FreeBSD
2023-04-18 22:58:14 +00:00
christos 0941656289 The bit definitions for the TF_* timestamp bits (TF_MODIFY, etc.) were
incorrect, and timestamps were written in the wrong order.

See RRIP 4.1.6 Description of the "TF" System Use Entry for details.

From: https://reviews.freebsd.org/D39221
2023-04-18 22:56:41 +00:00
kre fd13ea68e6 In bwrite() if the write() returned -1, the associated errno was
being used after a (possible) call to printf (only happens when
debugging) and a certain call to free() (via brelse()).
Make a copy, and use that instead.
2023-03-14 10:36:06 +00:00
kre ca975e38ba Use %zd to print ssize_t (%z[uxo] for size_t), rather than %jd
(just like the other adjacent printfs do)

Should fix i386 build.
2023-03-14 09:25:13 +00:00
christos 6839df46b4 Don't brelse() if bread() fails. The kernel does this for us. Our bread()
implementation just exits on failure, but if it didn't we would double-free.
From Ed Maste (https://reviews.freebsd.org/D39069)
2023-03-13 22:17:24 +00:00
christos d2604cfd26 modernize; release bpp and set it to NULL as the kernel does even if we
never return here.
2023-03-13 22:10:30 +00:00
chs f298a94b73 ufs: fixed signed/unsigned bugs affecting large file systems
Apply these commits from FreeBSD:

  commit e870d1e6f97cc73308c11c40684b775bcfa906a2
  Author: Kirk McKusick <mckusick@FreeBSD.org>
  Date:   Wed Feb 10 20:10:35 2010 +0000

    This fix corrects a problem in the file system that treats large
    inode numbers as negative rather than unsigned. For a default
    (16K block) file system, this bug began to show up at a file system
    size above about 16Tb.

    To fully handle this problem, newfs must be updated to ensure that
    it will never create a filesystem with more than 2^32 inodes. That
    patch will be forthcoming soon.

    Reported by: Scott Burns, John Kilburg, Bruce Evans
    Followup by: Jeff Roberson
    PR:          133980
    MFC after:   2 weeks

  commit 81479e688b0f643ffacd3f335b4b4bba460b769d
  Author: Kirk McKusick <mckusick@FreeBSD.org>
  Date:   Thu Feb 11 18:14:53 2010 +0000

    One last pass to get all the unsigned comparisons correct.


In additional to the changes from FreeBSD, this commit includes quite a few
related changes to appease -Wsign-compare.
2023-01-07 19:41:29 +00:00
chs 87ba0e2a31 Restore backward compatibility of UFS2 with previous NetBSD releases by
disabling support in UFS2 for extended attributes (including ACLs).
Add a new variant of UFS2 called "UFS2ea" that does support extended attributes.
Add new	fsck_ffs operations "-c	ea" and	"-c no-ea" to convert file systems
from UFS2 to UFS2ea and	vice-versa (both of which delete all existing extended
attributes in the process).
2022-11-17 06:40:38 +00:00
andvar 49811c99f0 fix various typos in comments and makefs README file. 2022-10-26 21:56:19 +00:00
reinoud bb9c76765e Revert, sorry this was not intended to be committed. 2022-05-08 21:29:20 +00:00
reinoud 945e1caad5 When creating disc images, keep the proposed size a multiple of the blockingnr
for good measure; this prevents possible burning/copying issues on packet
media.
2022-05-07 08:54:02 +00:00
reinoud 5823a2adcd Avoid warning by clang of unused variable
While here, use the computated obj_size even though it's always the same as
its information length since we don't use extended attribute files or
stream directories.
2022-04-26 15:18:08 +00:00
reinoud ecbc9e51ab Fix endian bug that resulted in UniqueIDs of 0 in file identifiers; note that
the the unique ID in a longad stored in a FID is 32 bit where in the file
descriptor (fe/efe) its 64 bits long.
2022-04-26 14:59:37 +00:00
reinoud 7906b5d46d No need to use ceilf() when ceil() is already used 2022-04-26 13:27:24 +00:00
reinoud 1cb1a07c94 Fix endian bug in makefs for udf 2022-04-26 13:26:30 +00:00
riastradh 2773c1b540 makefs(8): Fix tool build -- no libutil DPADD if HOSTPROG. 2022-04-10 09:22:35 +00:00
riastradh b9ccfe96a1 makefs(8): Needs -lm for ceil in udf as a host tool too. 2022-04-09 14:38:47 +00:00
riastradh bf2ad72489 makefs(8): Nix trailing whitespace.
Computed by machine, eyeballed by hand, so to speak.
2022-04-09 10:05:35 +00:00
hauke 56fc4047d2 udf.c uses math library functions. 2022-04-06 22:25:00 +00:00
wiz 374cb9be67 makefs: fix some typos 2022-04-06 13:44:25 +00:00
wiz 1baa92514a new sentence, new line 2022-04-06 13:39:06 +00:00
reinoud 8f4e1cd991 Refactor and rewrite of newfs_udf(8) and makefs(8) (-t udf) with a shared
section for fsck_udf(8).

Newfs_udf and makefs support predefined disc image profiles, harddisc
partitions (disklabel and wedges on all generic block devices) and all optical
media types on CD/DVD/BD writers.

Newfs_udf and makefs now also support formatting of UDF 2.50 with a metadata
partition.
2022-04-06 13:29:15 +00:00
mlelstv 2c701485e4 Avoid integer overflow on systems with 32bit disk addresses. 2022-04-02 19:16:49 +00:00
hgutch 0d7f3d7673 Make sure daddr_t is a 64 bit type when building tools.
(see also PR sw-bug/56742 ).
2022-03-06 08:31:54 +00:00
hannken 514b0270dd A component name is a counted string (cn_nameptr, cn_namelen),
not a zero terminated string cn_nameptr.

Change the following operations to work with counted strings:

v7fs_file_lookup_by_name()
v7fs_file_allocate()
v7fs_file_deallocate()
v7fs_directory_add_entry()
v7fs_directory_remove_entry()
v7fs_file_rename()
v7fs_file_link()
v7fs_dirent_filename()

Adapt all vnode operations with component names as argument.
2022-02-11 10:55:15 +00:00
andvar 427b92d9af s/filname/filename/ 2021-12-21 21:28:31 +00:00
reinoud 2e7f29dcb8 Explain cd9660 and udf exceptions on the rule that the default sectorsize is
512.
2021-11-12 07:41:55 +00:00
thorpej 8086f46e37 Sanitize the symbol namespace. NFC. 2021-10-23 16:58:17 +00:00
hannken 25fae635e5 Factor out the lookup results from struct denode.
No functional change.
2021-10-23 07:38:33 +00:00
andvar 16e91b5f21 s/helt/held+s/eroneously/erroneously/+s/splitted/split/+s/recommented/recommended/ 2021-08-21 09:59:45 +00:00
simonb ba42c78d37 Add a -L option to follow all symbolic links. Useful if you have symlinks
in a makefs directory tree but want to refer to the actual file.
2021-04-03 14:10:56 +00:00