Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to avoid crossing filesystem boundaries #321

Closed
wavexx opened this issue Jan 14, 2017 · 8 comments
Closed

Switch to avoid crossing filesystem boundaries #321

wavexx opened this issue Jan 14, 2017 · 8 comments
Labels
enhancement An enhancement to the functionality of the software. icebox A feature that is recognized as possibly desirable, but is unlikely to implemented any time soon.

Comments

@wavexx
Copy link

wavexx commented Jan 14, 2017

It's often useful to search only files that reside on the same filesystem as the search paths, same as find -xdev or ag --one-device. I find ag's "one-device" switch to be misleading, as it's more correctly described by find as "do not cross filesystem boundaries", since the restriction applies to each search path in turn (which can span more than one device).

@BurntSushi
Copy link
Owner

This needs to be implemented in walkdir (see: BurntSushi/walkdir#8) and ignore's parallel iterator, and then exposed up through ripgrep as a command line flag.

I agree with the naming choice. Using find's flag name seems fine. It looks like GNU grep doesn't have a similar flag?

@BurntSushi BurntSushi added the enhancement An enhancement to the functionality of the software. label Jan 18, 2017
@wavexx
Copy link
Author

wavexx commented Jan 18, 2017 via email

@BurntSushi BurntSushi added the icebox A feature that is recognized as possibly desirable, but is unlikely to implemented any time soon. label Apr 9, 2017
@BurntSushi
Copy link
Owner

I think I'm liking the name --mount for this. It's supported by find, is relatively short, and feels a bit more generic than --xdev.

Does anyone know the provenance of the name --xdev? I guess "dev" means "device" (which seems consistent with the dev attribute in the stat structure) and I guess x means "cross" or "don't cross" in this case.

@ssokolow
Copy link

ssokolow commented Aug 25, 2018

Does anyone know the provenance of the name --xdev? I guess "dev" means "device" (which seems consistent with the dev attribute in the stat structure) and I guess x means "cross" or "don't cross" in this case.

I suspect you're correct there, given that tools like ncdu use the short option -x and describe it as follows:

-x Do not cross filesystem boundaries, i.e. only count files and directories on the same filesystem as the directory being scanned.

Also, I'm not so sure about --mount. It doesn't feel at all intuitive to me, which is probably why the manpage for GNU find lists -mount it as being a compatibility alias for -xdev rather than the other way around.

@okdana
Copy link
Contributor

okdana commented Aug 25, 2018

Does anyone know the provenance of the name --xdev?

In 2.11BSD find uses a global variable called Xdev that is commented as true if SHOULD cross devices; the -xdev 'primary' flips it off. Probably the latter is named after the former? Seems like -noxdev or something would have made more sense; not that -mount is especially better

I suspect you're correct there, given that tools like ncdu use the short option -x

I think du -x comes from BSD's find -x, which was a later alias/replacement for -xdev. GNU du gave -x the long option name --one-file-system, which has also been borrowed into GNU cp, GNU rm, GNU tar, BSD tar, and rsync (... and ncdu, apparently)

@BurntSushi
Copy link
Owner

@okdana Ah nice, thanks! The prevalence of --one-file-system makes a compelling argument for that name. I guess we should probably go with that? It's also seemingly the most accurate. The only downside is that it's kind of long.

@ssokolow
Copy link

Another thing which just occurred to me is that I like the x-based names (-x, -xdev, etc.) because, in addition to "crossing device boundaries", they also associate it with options like --exclude in my mind, which is technically accurate. (You're eXcluding stuff outside the current filesystem.)

BurntSushi added a commit that referenced this issue Aug 26, 2018
This commit adds a 'same_file_system' option to the walk builder. For
single threaded walking, it defers to the walkdir crate, which has the
same option. The bulk of this commit implements this flag for the parallel
walker. We add one very feeble test for this.

The parallel walker is now officially a complete mess.

Closes #321
BurntSushi added a commit that referenced this issue Aug 26, 2018
This commit adds a 'same_file_system' option to the walk builder. For
single threaded walking, it defers to the walkdir crate, which has the
same option. The bulk of this commit implements this flag for the parallel
walker. We add one very feeble test for this.

The parallel walker is now officially a complete mess.

Closes #321
@wavexx
Copy link
Author

wavexx commented Dec 3, 2018

I know it's late to comment on this, but if I explicitly pass two directories on different devices to perform searches on:

$ rg pat /dev1/ /dev2/

I do expect rg to scan/descend on both, as these were given explicitly. In this sense, I really preferred the original term "same device" or "do not cross boundaries" (aka xdev) more than 'ag --one-device' as I originally pointed out, as "one" in this context is just a special case.

This is just for the sake of discussion, I know the name has already been settled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement to the functionality of the software. icebox A feature that is recognized as possibly desirable, but is unlikely to implemented any time soon.
Projects
None yet
Development

No branches or pull requests

4 participants