Page MenuHomeFreeBSD

Add fstyp(8).
AbandonedPublic

Authored by trasz on Dec 2 2014, 7:50 PM.
Tags
None
Referenced Files
F87097044: D1255.id2651.diff
Sat, Jun 29, 7:34 AM
Unknown Object (File)
Sat, Jun 29, 12:59 AM
Unknown Object (File)
Sat, Jun 29, 12:55 AM
Unknown Object (File)
Fri, Jun 28, 11:59 PM
Unknown Object (File)
Fri, Jun 28, 10:23 PM
Unknown Object (File)
Fri, Jun 28, 10:16 PM
Unknown Object (File)
Fri, Jun 28, 10:10 PM
Unknown Object (File)
Thu, Jun 27, 4:02 PM

Details

Reviewers
emaste
Group Reviewers
manpages
Summary

Add fstyp(8) utility. It's named after SVR4 utility which did something
similar. Plan is to use it for "-media" autofs map.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

trasz retitled this revision from to Add fstyp(8)..
trasz updated this object.
trasz edited the test plan for this revision. (Show Details)

I will look at this in a bit, but the first question is how does this differ from using file -s? There should also be a SEE ALSO entry for file(1).

It differs in four ways: its output is machine-parseable, it supports labels, it doesn't know about non-filesystems, so won't get confused, and is secure, due to capsicum. Take a look at the -special autofs map in https://reviews.freebsd.org/D1210 - with this tool, all of the file/glabel ugliness goes away.

A lot of small changes, mostly better error handling.

Btw, file(1) is contrib. Can I just go and modify its man page to add .Xr?

In D1255#8, @trasz wrote:

Btw, file(1) is contrib. Can I just go and modify its man page to add .Xr?

I think this is fine, but do check with contrib's in-tree maintainer. The desire to avoid modifying contrib at all costs comes from CVS limitations which no longer apply.

usr.sbin/fstyp/fstyp.c
170–171

I wonder if we should allow ENOSYS (and print a warning).

usr.sbin/fstyp/msdosfs.h
3–4

Where does this file come from? Can we reuse msdosfs kernel headers instead?

The reason I ask is that we're going to want msdosfs support in makefs(1), so the kernel headers in sys/fs/msdosfs/*.h will need to be available in userspace anyway.

usr.sbin/fstyp/fstyp.c
170–171

Hm, you're right, but I'd prefer to not do a warning. I'll only annoy people; if someone builds kernel without capsicum, it's their fault, and their choice. In other words, I don't see a point in alarming people who disabled a feature that the feature is indeed disabled.

usr.sbin/fstyp/msdosfs.h
3–4

It's from sys/geom/label/g_label_msdosfs.h.

In D1255#12, @trasz wrote:

Hm, you're right, but I'd prefer to not do a warning. I'll only annoy people; if someone builds kernel without capsicum, it's their fault, and their choice. In other words, I don't see a point in alarming people who disabled a feature that the feature is indeed disabled.

That's true.

I guess instead of a warning for this case (which has come up before) I'd like some way to choose in userland between "use capsicum if available" and "err if capsicum is not available." But I don't see a convenient way to do that.

trasz edited edge metadata.

Don't fail on kernel built without capsicum, and add cross-references
from file(1) and mount(8). I've pinged brien@ whether he's ok with file(1)
change.

usr.sbin/fstyp/msdosfs.h
3–4

Note that this file is quite different from what's found in sys/fs/msdosfs/. It is possible to merge the two, but I'd prefer to keep it in sync with geom_label, since that's where the code comes from. I could make it use kernel include instead of local copy, though. This would reduce code duplication, but would make it depend on kernel source tree. Hm.

usr.sbin/fstyp/fstyp.8
53

These are the names and capitalization of the filesystems as used on FreeBSD. Should the official names also be included when they differ?

.Cm cd9660
.Pq (ISO 9660) ,
.Cm ext2fs
.Pq (Ext2) ,
.Cm msdosfs
.Pq (MS-DOS or FAT) ,

55

s/The following/These/

58

The second comma is not needed.

63

Passive -> active:

s/will only work on/only works on/

Split sentence at "nodes"

...device nodes.
Trying to...

65

s/undefinitely/indefinitely/

70

Second comma is not needed.

usr.sbin/fstyp/fstyp.8
47

s/Recognized/The recognized/

Remove comma.

55

Based on the earlier explanation, add some explanation on how this utility is better for this purpose than file.

Because
.Nm
is built specifically to detect filesystem types, it differs from
.Xr file 1
in several ways.
The output is machine-parsable, disk and filesystem labels are supported, and only filesystems are identified.
Security is improved with
.Xr capsicum 4 .

74

Add:

.Xr capsicum 4 ,
.Xr glabel 8 ,

We should mention this project on an appropriate mailing list, perhaps freebsd-hackers?

brueffer added inline comments.
contrib/file/doc/file.man
388

Should be section 8 I suppose?

usr.sbin/fstyp/fstyp.8
45

...the filesystem...

49

.Cm -> .Li (also for the ones below)

Documentation improvements.

usr.sbin/fstyp/fstyp.8
47

Looking at this again, "recognized" is redundant with the previous sentence, and can be removed. The comma after "output" is still not needed.

Can this be libxo'd please?

In D1255#33, @alfredperlstein wrote:

Can this be libxo'd please?

Yeah, it should, although I'd probably like to see it go in as two commits if that's convenient. That will help others see how to libxo-ize something, and also make it easier to MFC.

In D1255#35, @emaste wrote:
In D1255#33, @alfredperlstein wrote:

Can this be libxo'd please?

Yeah, it should, although I'd probably like to see it go in as two commits if that's convenient. That will help others see how to libxo-ize something, and also make it easier to MFC.

That would be fine, this isn't a hard requirement obviously just a request.

In D1255#36, @alfredperlstein wrote:

That would be fine, this isn't a hard requirement obviously just a request.

Not a hard requirement, but I think it's very valuable when we develop new tools to make use of recent tech additions to FreeBSD (e.g. capsicum, libxo).

It'd be great to get kyua tests here too.

I'll add libxo support, but I'd prefer to do this in a separate commit.

Not sure if it is too late or not, but this stuff would be perfect for fsck, mount and maybe others. Right now, we rely on the partition type to determine this (well, the GEOM attributes about the GEOM). this suggests that this should be a routine that is in a library and the fstyp command call into that library.

The problem is, fstyp(8) depends on Capsicum, and if it were a library function, it would have to fork; otherwise the whole calling process would become sandboxed.