A simple support for detecting BeFS (BeOS) filesystem with fstyp cli command
Details
- Reviewers
cse_cem_gmail_com trasz mmacy lwhsu pfg 0mp pstef - Group Reviewers
manpages - Commits
- rG6558f29ac87a: fstyp: add BeFS support
rG0e92585cde51: fstyp: add BeFS support
make tests
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
I am debating of using the name "bfs" or "befs", the Linux kernel has two filesystems with those names, and the second one is used for the BeOS filesystem, which is this case.
usr.sbin/fstyp/Makefile | ||
---|---|---|
7 | bfs.c is out of order | |
usr.sbin/fstyp/bfs.c | ||
2 ↗ | (On Diff #87936) | It's not needed anymore. Also, you may consider adding SPDX-License-Identifier: BSD-2-Clause-FreeBSD. |
43 ↗ | (On Diff #87936) | style(9) |
52 ↗ | (On Diff #87936) | style(9) |
usr.sbin/fstyp/tests/Makefile | ||
15 | Could you move it to the top to preserve the alphabetical order? | |
usr.sbin/fstyp/tests/fstyp_test.sh | ||
291 | This seems to be slightly out of order. |
usr.sbin/fstyp/bfs.c | ||
---|---|---|
45 ↗ | (On Diff #87941) | why not return bool here? |
usr.sbin/fstyp/bfs.c | ||
---|---|---|
45 ↗ | (On Diff #87941) | is it the standard? I am complete new collaborating with C code in an open source project, so I want to learn what is the best for FreeBSD src. |
usr.sbin/fstyp/bfs.c | ||
---|---|---|
45 ↗ | (On Diff #87941) | it is, and we use it. inconsistently https://reviews.freebsd.org/D29659 😅 |
usr.sbin/fstyp/bfs.c | ||
---|---|---|
45 ↗ | (On Diff #87941) | I guess it will require more changes in all the files and the fstyp.c, I found this gem: error = fstyp_f(fp, label, sizeof(label)); if (error == 0) |
usr.sbin/fstyp/bfs.c | ||
---|---|---|
45 ↗ | (On Diff #87941) | if you have time and motivating you could just ignore my comment for now and instead do a cleanup revision |
usr.sbin/fstyp/bfs.c | ||
---|---|---|
45 ↗ | (On Diff #87941) | thank you, I do have time and motivation! I will keep in mind this in future contributions, I would like to add the BFS support for the VFS/FS as well later on. |
FWIW, I'd like to see OpenBFS (haiku OS) supported some day on FreeBSD, so this support is welcome.
usr.sbin/fstyp/Makefile | ||
---|---|---|
7 | Where is bfs.c? I don't see it in the revision anymore. |
usr.sbin/fstyp/Makefile | ||
---|---|---|
7 | https://reviews.freebsd.org/D29917#change-fk9UBYmA71xW I applied some style(9) recommended by @0mp |
LGTM, but ultimately cem@ is the local expert.
usr.sbin/fstyp/bfs.c | ||
---|---|---|
37 ↗ | (On Diff #87941) | FWIW, there should be a <TAB> after #define. I can't check if that is a space or a tab, but it¿s a common mistake. |
We don't have the naming conflict here, but befs is OK.
FWIW, there is a fuse version which would be useful before considering a kernel version.
usr.sbin/fstyp/befs.c | ||
---|---|---|
63 | oh, we can't expect volume->name to be nul-terminated, then it should be MIN(size, BFS_OS_NAME_LENGTH + 1) so that we copy all of it and null-terminate? |
Thank you. I will go for the name BeFS because I noticed other things using this name, like sysutils/bfs or other operating systems using bfs for something else, so to make it clear, BeFS sounds good to me.
usr.sbin/fstyp/befs.c | ||
---|---|---|
63 | I want it to be safe, but then using this way I don't really need to rtrim(), right? |
Yes please. BFS is way too generic and we had experienced name clashes in the past because they were too short. Even better if it could be done consistently, i.e. applied to macros like BFS_OS_NAME_LENGTH and BFS_SUPER_BLOCK_MAGIC1.
No. those are documented in Practical File System Design with the Be File System, and we should match their definition. Section 4.8 recommends B_OS_NAME_LENGTH, Alternatively we could use the Haiku definitions.
BTW, it would be nice if we could use other fields from the superblock, but I have no time to investigate whatever other fstype filesystems use.
Agree, the validation or identification of the file system needs to be with one or two magic fields, since it is just fstyp I though one is enough, it is not altering the fs so. And for the naming Haiku uses BFS and not exactly following the naming of the PDF, not strictly as you mentioned.
usr.sbin/fstyp/befs.c | ||
---|---|---|
43 | Should we cast this constant expression to magic1's type int32_t? (Should the type be int32_t in any case?) |
usr.sbin/fstyp/befs.c | ||
---|---|---|
43 | The API documentation is defined this way, and every other system that implemented it are using this way as constant and only defining the int32_t at the structs. |
Ah it does not show up on the diff when downloading it but, I can see it is listed here below, specifically here: https://reviews.freebsd.org/F20835718