Bug 188214 - Manpage for fsck(8) doesn't say what happens when no -t or -T
Summary: Manpage for fsck(8) doesn't say what happens when no -t or -T
Status: Closed FIXED
Alias: None
Product: Documentation
Classification: Unclassified
Component: Books & Articles (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-doc (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-03 04:40 UTC by Ronald F. Guilmette
Modified: 2022-01-05 08:30 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ronald F. Guilmette 2014-04-03 04:40:00 UTC
It has been suggested to me that if and when fsck(8) is invoked _without_
any explicitly provided -t or -T options, fsck will, in such cases, attempt
to intuit the type of the filesystem on its own, perhaps based upon
information/clues gleened from the local /etc/fstab file and/or from some
relevant BSD disk label.

If true, then this behavior does not appear to be documented at all within
the fsck(8) manpage.

This is an important aspect of the behavior of fsck(8).  If verified, then
it should be documented in the manpage.

Fix: 

Sorry, I do not have any suggested replacement text for the relevant manpage
at this time.
How-To-Repeat: 
man 8 fsck
Comment 1 dfilter service freebsd_committer freebsd_triage 2014-05-23 15:33:01 UTC
Author: trhodes
Date: Fri May 23 14:32:57 2014
New Revision: 266586
URL: http://svnweb.freebsd.org/changeset/base/266586

Log:
  If called without -T or -t, fsck attempts to detect the
  file system type.  If this fails, fsck will fail with
  "unknown file system type" message.
  
  PR:		188214

Modified:
  head/sbin/fsck/fsck.8

Modified: head/sbin/fsck/fsck.8
==============================================================================
--- head/sbin/fsck/fsck.8	Fri May 23 11:56:32 2014	(r266585)
+++ head/sbin/fsck/fsck.8	Fri May 23 14:32:57 2014	(r266586)
@@ -29,7 +29,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 25, 2009
+.Dd May 23, 2014
 .Dt FSCK 8
 .Os
 .Sh NAME
@@ -111,6 +111,18 @@ The disk drive containing each file syst
 of the device name that ends in a digit; the remaining characters are assumed
 to be the partition and slice designators.
 .Pp
+If the
+.Fl t
+or
+.Fl T
+flags are not specified,
+.Nm
+will attempt to determine the file system type and call the
+appropriated file system check utility.
+Failure to detect the file system type will cause
+.Nm
+to fail with a message that the partition has an unknown file system type.
+.Pp
 The options are as follows:
 .Bl -tag -width indent
 .It Fl C
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 2 Allan Jude freebsd_committer freebsd_triage 2014-05-23 16:39:24 UTC
I have not checked the code to be sure, but from general usage I have
noticed that fsck(8) doesn't actually try to detect, or 'taste' the
partition, but only looks at /etc/fstab and if the type is not
specified, then returns the error.

Suggesting that it 'attempts to detect' may give the wrong impression.
Someone would have to look at the source of fsck(8) to be sure.

-- 
Allan Jude
Comment 3 Mark Linimon 2014-05-24 18:11:17 UTC
----- Forwarded message from Tom Rhodes <trhodes@FreeBSD.org> -----

Date: Sat, 24 May 2014 12:32:04 -0400
From: Tom Rhodes <trhodes@FreeBSD.org>
To: Allan Jude <allanjude@freebsd.org>
Cc: freebsd-doc@FreeBSD.org
Subject: Re: docs/188214: Manpage for fsck(8) doesn&#39;t say what happens when no -t or -T
X-Mailer: Sylpheed version 1.0.6 (GTK+ 1.2.10; x86_64-unknown-freebsd9.2)

>  Suggesting that it 'attempts to detect' may give the wrong impression.
>  Someone would have to look at the source of fsck(8) to be sure.

So, in theory, an attempt to parse /etc/fstab would be
an attempt to detect the type; however, my quick glance
at the code showed no real parsing of fstab.  But in
my case, I followed to both the T and t flags, and just
glanced at what was done would they not be specified.
That was really as far as I got, and I attempted to use
very generic language in case it only does one, or the
other, or both.  :)

Reasonable?

-- 
Tom Rhodes
_______________________________________________
freebsd-doc@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-doc
To unsubscribe, send any mail to "freebsd-doc-unsubscribe@freebsd.org"

----- End forwarded message -----
Comment 4 Benjamin Kaduk freebsd_committer freebsd_triage 2014-05-24 22:42:47 UTC
On Sat, 24 May 2014, Tom Rhodes wrote:

> So, in theory, an attempt to parse /etc/fstab would be
> an attempt to detect the type; however, my quick glance
> at the code showed no real parsing of fstab.  But in
> my case, I followed to both the T and t flags, and just
> glanced at what was done would they not be specified.
> That was really as far as I got, and I attempted to use
> very generic language in case it only does one, or the
> other, or both.  :)

When passed no device or path arguments, fsck just checks everything from 
the fstab; that's not very interesting for this question.

Given a path argument and no type argument to use, fstab is parsed using 
getfsfile() or getfsspec() around line 204 of fsck.c.  This will fail 
(well, barring special circumstances) if the argument is instead a device 
name.

Given a device name argument and no type argument to use, after the fstab 
check above, fsck opens the device and uses ioctl() to get the disklabel 
and does some magic to grab the fstype from it.  (See getfslab(), in 
fsck.c)


So, I think there is a fair bit of autodetection that is attempted.

-Ben
Comment 5 Tom Rhodes freebsd_committer freebsd_triage 2014-05-25 06:16:52 UTC
Hi Benjamin,

On Sat, 24 May 2014 17:42:47 -0400 (EDT)
Benjamin Kaduk <bjk@freebsd.org> wrote:

> On Sat, 24 May 2014, Tom Rhodes wrote:
> 
> > So, in theory, an attempt to parse /etc/fstab would be
> > an attempt to detect the type; however, my quick glance
> > at the code showed no real parsing of fstab.  But in
> > my case, I followed to both the T and t flags, and just
> > glanced at what was done would they not be specified.
> > That was really as far as I got, and I attempted to use
> > very generic language in case it only does one, or the
> > other, or both.  :)
> 
> When passed no device or path arguments, fsck just checks everything from 
> the fstab; that's not very interesting for this question.
> 
> Given a path argument and no type argument to use, fstab is parsed using 
> getfsfile() or getfsspec() around line 204 of fsck.c.  This will fail 
> (well, barring special circumstances) if the argument is instead a device 
> name.
> 
> Given a device name argument and no type argument to use, after the fstab 
> check above, fsck opens the device and uses ioctl() to get the disklabel 
> and does some magic to grab the fstype from it.  (See getfslab(), in 
> fsck.c)
> 
> 
> So, I think there is a fair bit of autodetection that is attempted.

Thanks for the deep dive - I was going to revisit this later
(i.e.: actually step through the code more) if there was a real
issue.  Thanks for saving me the time!  :)

-- 
Tom Rhodes
Comment 6 Allan Jude freebsd_committer freebsd_triage 2014-06-06 01:33:46 UTC
Tom: Is this resolved now?
Comment 7 commit-hook freebsd_committer freebsd_triage 2017-03-30 02:38:40 UTC
A commit references this bug:

Author: sevan
Date: Thu Mar 30 02:37:38 UTC 2017
New revision: 316207
URL: https://svnweb.freebsd.org/changeset/base/316207

Log:
  MFC r266586

  If called without -T or -t, fsck attempts to detect the
  file system type.  If this fails, fsck will fail with
  "unknown file system type" message.

  PR:		188214

Changes:
_U  stable/10/
  stable/10/sbin/fsck/fsck.8