RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1607772 - [RFE] : To have a generic argument like " -xmount " to exclude all mount points in find command output.
Summary: [RFE] : To have a generic argument like " -xmount " to exclude all mount po...
Keywords:
Status: CLOSED DUPLICATE of bug 1634659
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: findutils
Version: 7.6
Hardware: All
OS: Linux
high
high
Target Milestone: rc
: ---
Assignee: Kamil Dudka
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks: 1643104
TreeView+ depends on / blocked
 
Reported: 2018-07-24 08:56 UTC by Parikshit Khedekar
Modified: 2019-06-11 20:22 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-11-19 13:19:54 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Parikshit Khedekar 2018-07-24 08:56:14 UTC
1. Proposed title of this feature request  

 -Have a generic argument like -xmount option to exclude all mount points in find command output.


      
2. What is the nature and description of the request?  

Findutils should have a default argument option to exclude all mount points that has the random fstype.

EX: 

$ find /proc -maxdepth 0 -xdev
/proc
customer would like to have something like as,

$ find /proc -maxdepth 0 -xmount
$ 
      
3. Why does the customer need this? (List the business requirements here)  
Customer have raised this concern as the ouput of find command contains the parent directory and it becomes difficult to feed the output of this to some processes.

4. How would the customer like to achieve this? (List the functional requirements here)  

$ find /proc -maxdepth 0 -xdev
/proc
customer would like to have something like as,

$ find /proc -maxdepth 0 -xmount
$ 

    
5. Is there already an existing RFE upstream or in Red Hat Bugzilla?  

No, there is no such RFE or functionality available in upstream as well.
      
6. Does the customer have any specific timeline dependencies and which release would they like to target (i.e. RHEL5, RHEL6)?  

Expected to have in RHEL 7

7. Is the sales team involved in this request and do they have any additional input?  
No
    
8. List any affected packages or components.  

findutils
      
9. Would the customer be able to assist in testing this functionality if implemented?  

Yes.

Comment 3 Kamil Dudka 2018-07-24 12:04:18 UTC
It is not clear what exactly is requested here.  They want to "exclude all mount points in the output".  What about the subtrees behind the mount points -- should they be also excluded or not?

The options -xdev or -mount prevent 'find' from traversing over the mount points but do not exclude the mount point themselves because it rarely makes sense.  For example the following command would do nothing because / is always a mount point:

$ find -xmount / ...

What do they need it for?  If the mounts to be excluded are of a different file system type (like in the /proc case), they could be excluded by the -fstype test:

$ find ... -xdev -fstype $(find $REFERENCE_PATH -maxdepth 0 -printf "%F\n")

Comment 4 Karl Abbott 2018-07-24 12:12:39 UTC
Yes, the customer would like to exclude the subtrees behind the mount points.

From the customer:

What I'd like is something like:
$ find /proc -maxdepth 0 -xmount
$ 
So I can feed the output to a process and not have to worry about statting a mounted fs.

So that is their intention with this request.

They'd expect the / mount to be included, but that would be the only exception.

Cheers,
Karl

Comment 5 Kamil Dudka 2018-07-24 12:41:41 UTC
Do you have a better example?

While / is always mounted, /proc is almost always mounted.  What is the actual purpose of the command in your example?  Do they just want to check whether /proc is mounted or not?

Comment 6 Karl Abbott 2018-07-25 11:51:00 UTC
Kamil,

They want to be able to take the output of the command feed it to another process. This process goes through the output and runs a stat against whatever you feed it. The customer does not want stat to be run against a mounted filesystem and thus the reason they want find to exclude any directories that are serving as mount points on the system.

Cheers,
Karl

Comment 7 Kamil Dudka 2018-07-25 13:37:44 UTC
If the mounted file systems to be skipped are of a different different type than the file system being traversed, I believe that a solution already exists -- see comment #3.  Could you please confirm whether it is actually the case?

If not, I could imagine a proposal for option like -samedev, which would work similarly to -samefile except it would ignore the inode number.  Would such a solution work for the customer?

Comment 8 Renaud Métrich 2018-08-08 13:37:53 UTC
This does the job ("printf" subshell):

$ find / -xdev -maxdepth 1 $(printf -- "! -path %s " $(awk '$2 != "/" { print $2 }' /proc/mounts))

Comment 9 FrankH. 2018-08-30 08:27:08 UTC
@Renaud: you do two subshells, for both printf and awk. Nothing else but awk is needed:

$ find / -xdev -maxdepth 1 $(awk '$2 != "/" { printf("! -path %s ", $2) } /proc/mounts)

creates the same output.

Comment 10 Kamil Dudka 2018-11-01 16:09:41 UTC
I have proposed a patch upstream:

http://lists.gnu.org/archive/html/bug-findutils/2018-11/msg00000.html

Comment 11 Kamil Dudka 2018-11-02 09:23:10 UTC
Erik Blake pointed out that there is already a POSIX requirement for the -mount option of find to behave differently than -xdev and prevent the mount points from being processed:

https://lists.gnu.org/archive/html/bug-findutils/2018-11/msg00001.html
https://lists.gnu.org/archive/html/bug-findutils/2018-09/msg00050.html

There is, however, no implementation of the requirement upstream yet.

Comment 12 Kamil Dudka 2018-11-19 13:19:54 UTC
Upstream has rejected the proposed patch because they intend to solve this by changing the behavior of the -mount option.  Therefore I am closing this as a duplicate of bug #1634659, which requests it.  But it needs to be implemented in GNU findutils upstream (and likely in the gnulib's FTS implementation first).

*** This bug has been marked as a duplicate of bug 1634659 ***


Note You need to log in before you can comment on or make changes to this bug.