bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #47261] find produces two different results for the same command


From: Dale Worley
Subject: [bug #47261] find produces two different results for the same command
Date: Wed, 02 Mar 2016 15:39:08 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:34.0) Gecko/20100101 Firefox/34.0

Follow-up Comment #7, bug #47261 (project findutils):

I wrote a script to determine what all the stat() calls are looking at, and it
turns out my guess was wrong.  There are a lot of files that find doesn't
find, and I doubt it's because they're not in the filesystem.  E.g., all of
/etc is missing.

There are the expectable differences in /proc.  But other than that, the first
run ends at:

newfstatat(/sys/kernel/debug/tracing/events/task/task_newtask)
newfstatat(/sys/kernel/debug/tracing/events/task/task_rename)
newfstatat(/sys/kernel/debug/tracing/events/raw_syscalls)
newfstatat(/sys/kernel/debug/tracing/events/raw_syscalls/sys_enter)
newfstatat(/sys/kernel/debug/tracing/events/raw_syscalls/sys_exit)

but the second run continues with:

newfstatat(/sys/kernel/debug/tracing/options)
newfstatat(/sys/kernel/debug/tracing/instances)
newfstatat(/sys/kernel/debug/tracing/per_cpu)
newfstatat(/sys/kernel/debug/tracing/per_cpu/cpu0)
newfstatat(/sys/kernel/debug/tracing/trace_stat)
newfstatat(/sys/kernel/debug/usb)

and goes on to walk through /usr and /etc.

Looking at the end of the first run shows no obvious reason why find would
terminate prematurely.

The script I used is:

#! /bin/perl

use strict;

my($debug) = 0;
my($cwd) = '';
my(@file);

while (<>) {
    chomp;
    print "$_ = '$_' n" if $debug;
    if (m/^open("(.*)", O_[^)]+) += (d+)$/) {
        my($name) = $1;
        my($fd) = $2;
        $file[$fd] = &append($cwd, $name);
        print "$file[$fd] = '$file[$fd]'n" if $debug;
    } elsif (m/^openat([^,]+, "(.*)", O_[^)]+) += (d+)$/) {
        my($name) = $1;
        my($fd) = $2;
        $file[$fd] = &append($cwd, $name);
        print "$file[$fd] = '$file[$fd]'n" if $debug;
    } elsif (m/^fchdir((d+))/) {
        my($fd) = $1;
        $cwd = $file[$fd];
        print "$cwd = '$cwd'n" if $debug;
    } elsif (m/^newfstatat([^,]+, "(.*)", {/) {
        my($name) = $1;
        $name = &append($cwd, $name);
        $name = '/' if $name eq '';
        print "newfstatat(", $name, ")n";
    }
}

sub append {
    my($cwd, $name) = @_;

    if ($name eq '.') {
        $name = $cwd;
    } elsif ($name eq '..') {
        $name = $cwd;
        $name =~ s%/[^/]*$%%;
    } elsif ($name !~ m%^/%) {
        $name = $cwd . '/' . $name;
    } elsif ($name eq '/') {
        $name = '';
    }
    
    return $name;
}


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?47261>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]