FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora User

 
 
LinkBack Thread Tools
 
Old 01-07-2012, 05:48 PM
JB
 
Default "find" problem

Dean S. Messing <deanm <at> sharplabs.com> writes:

>
> On my F13 machine,
>
> find / ! -fstype ext4 -prune -o -print
>
> prints every file that is in an ext4 filesystem mounted on /, and prunes
> those in any other type of fs.
>
> On my F15 the same command prints nothing. Why might that be?
>

I have a hunch regarding this problem.
It may be related to systemd and /etc/mtab.

Up to F14 (the system I have in front of me; /dev/sda2 is "/"):
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 8062384 4070156 3910344 52% /
...
$ ls -l /etc/mtab
-rw-r--r-- 1 root root 242 Jan 7 11:20 /etc/mtab
$ cat /etc/mtab
/dev/sda2 / ext4 rw 0 0
...
$ mount
/dev/sda2 on / type ext4 (rw)
...
$ ls -al /proc/mounts
lrwxrwxrwx 1 root root 11 Jan 7 19:00 /proc/mounts -> self/mounts
$ cat /proc/self/mounts
rootfs / rootfs rw 0 0
/dev/sda2 / ext4 rw,relatime,barrier=1,data=ordered 0 0
...

Since systemd implementation on F15 and onward /etc/mtab is symlinked to
/proc/self/mounts (the other system I have in front of me is F16; /dev/sda8 is
is "/"):

$ df
Filesystem 1K-blocks Used Available Use% Mounted on
rootfs 15116288 3590644 11372116 24% /
/dev/sda8 15116288 3590644 11372116 24% /
...
$ ls -al /etc/mtab
lrwxrwxrwx 1 root root 12 Dec 4 12:26 /etc/mtab -> /proc/mounts
$ cat /etc/mtab
rootfs / rootfs rw 0 0
/dev/sda8 / ext4 rw,relatime,user_xattr,barrier=1,data=ordered 0 0
...

NOTE: the difference between /proc/mounts above and mount outputs.
$ mount
/dev/sda8 on / type ext4 (rw,relatime,user_xattr,barrier=1,data=ordered)
...

$ ls -al /proc/mounts
lrwxrwxrwx 1 root root 11 Jan 7 19:19 /proc/mounts -> self/mounts

NOTE:
systemd requires that /etc/mtab be a symlink to /proc/self/mounts, or
the following warning will be printed:
/etc/mtab is not a symlink or not pointing to /proc/self/mounts. This is not
supported anymore. Please make sure to replace this file by a symlink to avoid
incorrect or misleading mount(8) output.
# ln -fs /proc/self/mounts /etc/mtab
Without doing this, features such as automounting through /etc/fstab will be
unavailable.

One more hint (formally unrelated as your "find" does not use Olevel);
on F14 and F16 (no difference):
$ man find
-P ...
-L ...
-H ...
...
2 Any -type or -xtype tests are performed after any tests
based only on the names of files, but before any tests
that require information from the inode. On many modern
versions of Unix, file types are returned by readdir()
and so these predicates are faster to evaluate than pred‐
icates which need to stat the file first. If you use the
-fstype FOO predicate and specify a filsystem type FOO
which is not known (that is, present in `/etc/mtab') at
the time find starts, that predicate is equivalent to
-false.

Did the /etc/mtab being a symlink or that pecularity with optimization created
code execution conditions that make "find" behave differently ?

Some more ouput.

On F14:
# find / ! -fstype ext4 -print -prune
/var/lib/nfs/rpc_pipefs
/dev
/sys
/proc
# find / ! -fstype ext4 -prune -o -print
/
/.pulse
/.pulse/dd64759292eef8babdfc0cd400000013-runtime
/selinux
/selinux/booleans
/media
/media/.hal-mtab
/.autofsck
/usr
/usr/local
/usr/local/lib
...

On F16:
# find / ! -fstype ext4 -print -prune
/
# find / ! -fstype ext4 -prune -o -print
#

I am not able to put a finger on it yet; you may have more luck.
JB


--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org
 
Old 01-08-2012, 02:03 AM
 
Default "find" problem

On 07 January 2012 at 20:02:21 +1100, Cameron Simpson wrote:
> On 06Jan2012 23:29, Dean S. Messing <deanm@sharplabs.com> wrote:
> | In doing more experimenting with find, I discovered that
> | / is evidently fstype "rootfs", whatever that is.
>
> Interesting.
>
> | Looking in /etc/mtab I see:
> | rootfs / rootfs rw 0 0
>
> I was going to suggest you run the "mount" command, but I see you're
> ahead of me.

Yeah, I ran "mount" first and it _does not_ show up there.
But it does in /etc/mtab, which in F15 is just a symlink to /proc/self/mounts.

> | and
> | /dev/mapper/vg00-lv_root / ext4
> | rw,relatime,user_xattr,acl,barrier=1,stripe=32,dat a=ordered 0 0
> |
> | In fact,
> | find / -fstype rootfs -print
> | prints all the files and ordinary directories under /.
>
> Which makes sense, given the above.

Yep.

> | None of the ext4 mounts are entered, nor are /proc or /sys, &c.
>
> As you'd hope!

Well, I hoped for much more, but I didn't get it. :-)

> | find / -fstype ext4 -print
> | only prints the entries in ext4 directories mounted in /.
>
> Well at least it is all nice and consistent.

Yes.

> | This behaviour thoroughly breaks some of my scripts.
>
> Fun fun fun. What assumptions are you making (aside from ext4 == regular
> filesystem)? Are you simply trying to avoid /proc and /dev etc? And NFS
> mounts I guess?

Approximately. Here is the key line from one of the scripts.

find / ( ! -fstype ext2 ! -fstype ext3 ! -fstype ext4 $w ) -prune
-o <my processing>

$w is built earlier in the script as follows:

for pp in $PRUNEPATHS
do
w="$w -o -wholename $pp"
done

$PRUNEPATHS is a list of directories I also want to prune from the tree
before processing begins.

I suppose I can just add rootfs to the list of -fstype switches, but
I'm not sure what side effects this will have since "rootfs" is not
really a "file type". It also is no longer portable.

How much nicer it would be to return to how it "should" work!

Dean
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org
 

Thread Tools




All times are GMT. The time now is 06:43 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org