public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
* fsck files w/relative paths
@ 2013-01-20 23:27 Mike Frysinger
  2013-01-25 15:17 ` Karel Zak
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Frysinger @ 2013-01-20 23:27 UTC (permalink / raw)
  To: util-linux-ng

[-- Attachment #1: Type: Text/Plain, Size: 1068 bytes --]

if i create a dummy local fs in a file:
$ dd if=/dev/zero of=foo count=1 seek=1000
$ mke2fs -F foo

now trying to run fsck on it:
$ fsck ./foo
fsck from util-linux 2.22.2
Usage: fsck.ext4 [-panyrcdfvtDFV] [-b superblock] [-B blocksize]
                [-I inode_buffer_blocks] [-P process_inode_size]
                [-l|-L bad_blocks_file] [-C fd] [-j external_journal]
                [-E extended-options] device

that's weird ...

running it through strace shows it behaves as if no args were provided 
(num_devices=0), so it looks up my rootfs details, and then runs fsck:
[pid 28095] execve("/sbin/fsck.ext4", ["fsck.ext4", "./foo", "/dev/sdd2"], [/* 
69 vars */]) = 0

reading the code, it expects files to have absolute paths.  so running:
$ fsck $PWD/foo
works just fine

we could tweak parse_argv() so that it checks for argv[0] == '.' in addition 
to argv[0] == '/'.  but that wouldn't fix other relative paths like:
$ fsck images/foo
$ fsck foo

should we treat all non-options as devices ?  would that break anything ?
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: fsck files w/relative paths
  2013-01-20 23:27 fsck files w/relative paths Mike Frysinger
@ 2013-01-25 15:17 ` Karel Zak
  2013-01-25 17:02   ` Mike Frysinger
  0 siblings, 1 reply; 5+ messages in thread
From: Karel Zak @ 2013-01-25 15:17 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: util-linux-ng

On Sun, Jan 20, 2013 at 06:27:22PM -0500, Mike Frysinger wrote:
> we could tweak parse_argv() so that it checks for argv[0] == '.' in addition 
> to argv[0] == '/'.  but that wouldn't fix other relative paths like:
> $ fsck images/foo
> $ fsck foo

Hmm... maybe add a hint to the fsck man page is the best solution :-)

> should we treat all non-options as devices ?  would that break anything ?

I don't think it's a good idea.

All unknown stuff is by default interpreted as filesystem specific options
(options for fsck.<type>) and it's pretty common that people don't use
"--" separator between fsck and fsck.<type> options.

 Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: fsck files w/relative paths
  2013-01-25 15:17 ` Karel Zak
@ 2013-01-25 17:02   ` Mike Frysinger
  2013-01-25 17:36     ` Karel Zak
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Frysinger @ 2013-01-25 17:02 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux-ng

[-- Attachment #1: Type: Text/Plain, Size: 1228 bytes --]

On Friday 25 January 2013 10:17:36 Karel Zak wrote:
> On Sun, Jan 20, 2013 at 06:27:22PM -0500, Mike Frysinger wrote:
> > we could tweak parse_argv() so that it checks for argv[0] == '.' in
> > addition to argv[0] == '/'.  but that wouldn't fix other relative paths
> > like: $ fsck images/foo
> > $ fsck foo
> 
> Hmm... maybe add a hint to the fsck man page is the best solution :-)
> 
> > should we treat all non-options as devices ?  would that break anything ?
> 
> I don't think it's a good idea.
> 
> All unknown stuff is by default interpreted as filesystem specific options
> (options for fsck.<type>) and it's pretty common that people don't use
> "--" separator between fsck and fsck.<type> options.

well, i didn't mean non-fsck options, but non-options.  i.e. things that don't 
start with dashes.  are there fscks which use non-options as something other 
than "file/device to check" ?

really, the fsck checking here is simply to determine whether it has to 
automatically look up the root device and append that to the command line.  if 
the user specified a file/device, then that shouldn't happen.  we could even 
resort to doing a stat() on the non-options to see if it exists.
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: fsck files w/relative paths
  2013-01-25 17:02   ` Mike Frysinger
@ 2013-01-25 17:36     ` Karel Zak
  2013-01-25 19:55       ` Mike Frysinger
  0 siblings, 1 reply; 5+ messages in thread
From: Karel Zak @ 2013-01-25 17:36 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: util-linux-ng

On Fri, Jan 25, 2013 at 12:02:01PM -0500, Mike Frysinger wrote:
> On Friday 25 January 2013 10:17:36 Karel Zak wrote:
> > On Sun, Jan 20, 2013 at 06:27:22PM -0500, Mike Frysinger wrote:
> > > we could tweak parse_argv() so that it checks for argv[0] == '.' in
> > > addition to argv[0] == '/'.  but that wouldn't fix other relative paths
> > > like: $ fsck images/foo
> > > $ fsck foo
> > 
> > Hmm... maybe add a hint to the fsck man page is the best solution :-)
> > 
> > > should we treat all non-options as devices ?  would that break anything ?
> > 
> > I don't think it's a good idea.
> > 
> > All unknown stuff is by default interpreted as filesystem specific options
> > (options for fsck.<type>) and it's pretty common that people don't use
> > "--" separator between fsck and fsck.<type> options.
> 
> well, i didn't mean non-fsck options, but non-options.  i.e. things that don't 

I understand..

> start with dashes.  are there fscks which use non-options as something other 
> than "file/device to check" ?

 fsck.ext4 -L bad_block_file  /dev/sda1

or whatever... and note that we have no clue about all possible fsck
implementations (not all is public and open source..)

> really, the fsck checking here is simply to determine whether it has to 
> automatically look up the root device and append that to the command line.  if 
> the user specified a file/device, then that shouldn't happen.  we could even 
> resort to doing a stat() on the non-options to see if it exists.

.. so because we have no clue about -L we will call stat() for
bad_block_file.

IMHO require absolute paths seems like a better solution :-)

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: fsck files w/relative paths
  2013-01-25 17:36     ` Karel Zak
@ 2013-01-25 19:55       ` Mike Frysinger
  0 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2013-01-25 19:55 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux-ng

[-- Attachment #1: Type: Text/Plain, Size: 1836 bytes --]

On Friday 25 January 2013 12:36:23 Karel Zak wrote:
> On Fri, Jan 25, 2013 at 12:02:01PM -0500, Mike Frysinger wrote:
> > On Friday 25 January 2013 10:17:36 Karel Zak wrote:
> > > On Sun, Jan 20, 2013 at 06:27:22PM -0500, Mike Frysinger wrote:
> > > > we could tweak parse_argv() so that it checks for argv[0] == '.' in
> > > > addition to argv[0] == '/'.  but that wouldn't fix other relative
> > > > paths like: $ fsck images/foo
> > > > $ fsck foo
> > > 
> > > Hmm... maybe add a hint to the fsck man page is the best solution :-)
> > > 
> > > > should we treat all non-options as devices ?  would that break
> > > > anything ?
> > > 
> > > I don't think it's a good idea.
> > > 
> > > All unknown stuff is by default interpreted as filesystem specific
> > > options (options for fsck.<type>) and it's pretty common that people
> > > don't use "--" separator between fsck and fsck.<type> options.
> > 
> > well, i didn't mean non-fsck options, but non-options.  i.e. things that
> > don't
> 
> I understand..
> 
> > start with dashes.  are there fscks which use non-options as something
> > other than "file/device to check" ?
> 
>  fsck.ext4 -L bad_block_file  /dev/sda1
> 
> or whatever... and note that we have no clue about all possible fsck
> implementations (not all is public and open source..)

i would highlight the man page says people are supposed to use -- to separate 
fsck-specific options from fsck-specific ones.

as to your example here though, that shows that things are also broken.  if 
you give an absolute path to the bad_block_file, then the auto-silencing of the 
root partition is run.

compare:
	fsck -L bad_block_file
	fsck -L $PWD/bad_block_file

the first will auto-append the root device while the latter will not for no 
apparent reason to the user
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-01-25 19:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-20 23:27 fsck files w/relative paths Mike Frysinger
2013-01-25 15:17 ` Karel Zak
2013-01-25 17:02   ` Mike Frysinger
2013-01-25 17:36     ` Karel Zak
2013-01-25 19:55       ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox