Bug 1607772
| Summary: | [RFE] : To have a generic argument like " -xmount " to exclude all mount points in find command output. | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Parikshit Khedekar <pkhedeka> |
| Component: | findutils | Assignee: | Kamil Dudka <kdudka> |
| Status: | CLOSED DUPLICATE | QA Contact: | BaseOS QE - Apps <qe-baseos-apps> |
| Severity: | high | Docs Contact: | |
| Priority: | high | ||
| Version: | 7.6 | CC: | bwelterl, frank.hofmann, kabbott, kdudka, pkhedeka, rmetrich |
| Target Milestone: | rc | Keywords: | FutureFeature |
| Target Release: | --- | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2018-11-19 13:19:54 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
| Bug Depends On: | |||
| Bug Blocks: | 1643104 | ||
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") 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 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? 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 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? This does the job ("printf" subshell):
$ find / -xdev -maxdepth 1 $(printf -- "! -path %s " $(awk '$2 != "/" { print $2 }' /proc/mounts))
@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.
I have proposed a patch upstream: http://lists.gnu.org/archive/html/bug-findutils/2018-11/msg00000.html 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. 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 *** |
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.