On Tue, Aug 18, 2020 at 1:18 PM Miklos Szeredi <miklos@xxxxxxxxxx> wrote: > > So why mix a binary structure into it? Would it not make more sense > to make it text only? .. because for basic and standard stuff, the binary structure just makes sense and is easier for everybody. When I want to get the size of a file, I do "stat()" on it, and get the size from st.st_size. That's convenient, and there's no reason _not_ to do it. Returning the size as an ASCII string would be completely pointless and annoying as hell. So binary formats have their places. But those places are for standard and well-understood fields that are commonly accessed and do not have any free-form or wild components to them that needs to be marshalled into some binary format. Whenever you have free-form data, just use ASCII. It's what "mount" already uses, for chrissake. We pass in mount options as ASCII for a good reason. Basically, I think a rough rule of thumb can and should be: - stuff that the VFS knows about natively and fully is clearly pretty mount-agnostic and generic, and can be represented in whatever extended "struct statfs_x" directly. - anything that is variable-format and per-fs should be expressed in the ASCII buffer Look at our fancy new fs_context - that's pretty much what it does even inside the kernel. Sure, we have "binary" fields there for core basic information ("struct dentry *root", but also things like flags with MNT_NOSUID), but the configuration stuff is ASCII that the filesystem can parse itself. Exactly because some things are very much specific to some filesystems, not generic things. So we fundamentally already have a mix of "standard FS data" and "filesystem-specific options", and it's already basically split that way: binary flag fields for the generic stuff, and ASCII text for the odd options. Again: binary data isn't wrong when it's a fixed structure that didn't need some odd massaging or marshalling or parsing. Just a simple fixed structure. That is _the_ most common kernel interface, used for almost everything. Sometimes we have arrays of them, but most of the time it's a single struct pointer. But binary data very much is wrong the moment you think you need to have a parser to read it, or a marshaller to write it. Just use ASCII. I really would prefer for the free-form data to have a lot of commonalities with the /proc/mounts line. Not because that's a wonderful format, but because there are very very few truly wonderful formats out there, and in the absense of "wonderful", I'd much prefer "familiar" and "able to use common helpers" (hopefully both on the kernel side and the user side).. Linus