Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stat -f -c %T /sys/fs/cgroup/memory display "unknown" instead of "cgroupfs" #423

Closed
chairwa opened this issue Apr 11, 2023 · 11 comments
Closed

Comments

@chairwa
Copy link

chairwa commented Apr 11, 2023

mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
cd /sys/fs/cgroup
mkdir -p memory
mount -t cgroup -o memory cgroup memory

stat -f -c %T /sys/fs/cgroup/memory
unknown

Whereas on Linux,
stat -f -c %T /sys/fs/cgroup/memory
cgroupfs

@enh-google
Copy link
Collaborator

apologies for not adding this when i last went through the list. i don't know if i mentioned this at the time, but basically i only added "real" the file systems from <linux/magic.h> and skipped cgroupfs/cgroup2fs/debugfs/tracefs etc.

rob: i'm guessing if we add one, we should add them all? let me know if you'd like a patch. that's nice easy friday afternoon "don't break anything before the weekend" work :-)

@landley
Copy link
Owner

landley commented Apr 11, 2023

Sigh, where does Linux store these numbers... in magic.h. Ok, I've forgotten the magic "dear github, don't hork this line" escaping but for bash it's: sed -n 's/#define ([^_])_SUPER_MAGIC[ \t][ \t]([^ \t])./{\2, "\1"},/p' include/uapi/linux/magic.h | sort -k2,2 | xargs

And now grep for where each one's actually USED in the kernel source, one at a time, reading the adjacent Kconfig for a description to see which ones are real, and also what it's actually called when you mount the filesystem (the macro is binderfs but the mount -t is "binder", and no of course that isn't under fs/ like the rest of them...) and update the list by hand because of COURSE it isn't complete (BFS_MAGIC for fs/bfs is in include/uapi/linux/bfs_fs.h)... Why doesn't ext4 have its own number? There are minix2 and minix3 filesystems? There's an NCP_SUPER_MAGIC that's never used anywhere, why... because fs/ncpfs was deleted sometime since v4.0...

Working on it...

@landley
Copy link
Owner

landley commented Apr 11, 2023

I've been working on it all morning, I posted the above because I'm breaking for lunch. :)

@landley
Copy link
Owner

landley commented Apr 11, 2023

And all filesystems are "real" filesystems. There are four categories: block backed (ext2/vfat etc), server backed (nfs/cifs/v9fs/fuse etc), ram backed (ramfs/tmpfs), and synthetic (ala proc/sys). I even checked in some documentation on this: https://landley.net/toybox/doc/mount.html (Based on some random thing I posted to the busybox mailing list aeons ago, and then did a cleaned up version for livejournal, then...)

Cgroupfs is just a synthetic filesystem, like procfs and sysfs.

(There are also hybrid filesystems, the way devtmpfs is a synthetic filesystem that passes through to ram backed for newly created entries, and you could say "other filesystem backed" is a category ala unionfs and ecryptfs. Server backed is really "pipe backed" with data going across a serialized protocol, modulo NFSv2 sucking so much it uses udp instead of tcp and tries to parallelize it in a horrific way. But the four main filesystem categories are still useful to understand.)

@enh-google
Copy link
Collaborator

(yeah, s/"real"/block-backed/ in my earlier comment. sorry, i should have brought this up at the time and just added the lot...)

@landley
Copy link
Owner

landley commented Apr 11, 2023

P.S. Commit 1bb8155080c6 moved ncpfs (Novell netware) into drivers/staging and commit bd32895c750b deleted it. But they left it in the header...

@landley
Copy link
Owner

landley commented Apr 11, 2023

Don't ask me why CONFIG_SUN_OPENPROMFS is in arch/sparc/Kconfig not fs/openpromfs. And the "fs" vs not having "fs" in the names is just random (the filenames are all overlayfs.h as is the macro, but the module name and thus mount -t is "overlay"... I'm going with "what you'd mount".) And some have gratuitous version numbers while others don't (no of COURSE the mount macros aren't consistent with the filenames which aren't consistent with config symbols which aren't consistent with the module names.)

If you're wondering why toybox autodetects and auto-generates so much of this stuff and MAKES it line up... It's way easier to be consistent than right.

@landley
Copy link
Owner

landley commented Apr 28, 2023

Try commit 88ea9c9

@landley
Copy link
Owner

landley commented May 2, 2023

Ping.

@enh-google
Copy link
Collaborator

("works for me" with the original submitter's example.)

@landley
Copy link
Owner

landley commented May 3, 2023

Calling it good. Open a new one if you've got another bug.

@landley landley closed this as completed May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants