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
- rS FreeBSD src repository - subversion
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 38843 Build 35732: arc lint + arc unit
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 ↗ | (On Diff #87936) | bfs.c is out of order |
usr.sbin/fstyp/bfs.c | ||
2 | It's not needed anymore. Also, you may consider adding SPDX-License-Identifier: BSD-2-Clause-FreeBSD. | |
43 | style(9) | |
52 | style(9) | |
usr.sbin/fstyp/tests/Makefile | ||
14 ↗ | (On Diff #87936) | Could you move it to the top to preserve the alphabetical order? |
usr.sbin/fstyp/tests/fstyp_test.sh | ||
289 ↗ | (On Diff #87936) | This seems to be slightly out of order. |
usr.sbin/fstyp/bfs.c | ||
---|---|---|
49–50 | why not return bool here? |
usr.sbin/fstyp/bfs.c | ||
---|---|---|
49–50 | 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 | ||
---|---|---|
49–50 | it is, and we use it. inconsistently https://reviews.freebsd.org/D29659 😅 |
usr.sbin/fstyp/bfs.c | ||
---|---|---|
49–50 | 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 | ||
---|---|---|
49–50 | 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 | ||
---|---|---|
49–50 | 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 | ||
---|---|---|
6 ↗ | (On Diff #87941) | Where is bfs.c? I don't see it in the revision anymore. |
usr.sbin/fstyp/Makefile | ||
---|---|---|
6 ↗ | (On Diff #87941) | 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 | ||
---|---|---|
41 | 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 | ||
---|---|---|
54 ↗ | (On Diff #88071) | wonder if we should provide a define (e.g. BFS_SUPER_BLOCK_OFFSET) for 512. |
61 ↗ | (On Diff #88071) | why bzero() the buffer if we are going to overwrite with nul-terminated string anyway? |
62 ↗ | (On Diff #88071) | no magic is needed for the 3rd argument, it should be exactly the size of provided buffer |
usr.sbin/fstyp/befs.c | ||
---|---|---|
62 ↗ | (On Diff #88071) | 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 | ||
---|---|---|
62 ↗ | (On Diff #88071) | 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 | ||
---|---|---|
42 ↗ | (On Diff #88324) | 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 | ||
---|---|---|
42 ↗ | (On Diff #88324) | 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