I find the name of the xdev option counterintuitive. For me it seems like the abbreviation of 'cross device (search)'. However it does the opposite, it restricts the search to a single file system. The alternative but somewhat obsolete name is "mount", which is more memorizable. What is the history behind the naming of this option?

2 Answers 2


It most probably stands for cross-device indeed, though in effect it means do not cross devices.

In the original implementation on BSD in 1985, the code had:

int    Xdev = 1;       /* true if SHOULD cross devices (file systems) */
   else if (EQ(a, "-xdev")) {
           Xdev = 0;

Where Xdev was an internal variable used to track whether devices should be crossed. The -xdev predicate sets that to 0.

David Korn at AT&T added a similar predicate a few years later for SVR4 with a -mount alias for it (that mirrors the FTW_MOUNT flag of the new tree walking library).

I don't find the -mount option particularly better. Assuming it stands for single-mount, it's also misleading on Linux at least where you can have several mount points for a file system.

$ mkdir -p a/b b
$ sudo mount --bind a b

Now b is a mountpoint on the same device as . and a.

$ find . -xdev
$ find . -mount

find doesn't cross-devices when processing b, but it's a different mount point so -mount (as single-mount) is more misleading that -xdev (as long as you remember it's about preventing crossing devices).

  • Unless you can present us the SCCS history for find on SunOS, you cannot verify whether SunOS or BSD introduced the -xdev feature.
    – schily
    Nov 5, 2018 at 15:51
  • @schily, the commit I link is dated 1985-06-07, shortly after SunOS 2.0 was released (wikipedia mentions May 1985). SunOS 2.0 didn't have -xdev, SunOS 3.0 was not shipped before September 1985. I couldn't verify whether 3.0 had -xdev. 3.2 definitely had (with a SCCS id for find.c of find.c 1.1 86/07/08 SMI). As you say, there was probably a lot of collaboration between Sun and Berkeley.In any case, it's not unfair to call those early SunOS systems BSDs, like macOS is now often classified as a BSD system. Nov 5, 2018 at 16:31
  • Never trust in SCCS SIDs in sources taken from univertity source trees. Sun did call a recursive get -k followed by a creation of a dummy SCCS tree based on these files. As a result, the SIDs always were 1.1 with the date of the creation of the related university source tree. Given that there have been more people working at Sun, the probability that this did come from Sun is high in special since the user serge was only active for a few months in 1985 and mostly caused putbacks that definitly did come from other sources.
    – schily
    Nov 5, 2018 at 16:41

It is even more complex that you might believe.

In the AT&T implementation for find, the feature is from nftw() which has been introduced with SVr4 and nftw() did come with a flag FTW_MOUNT that stopped at mount points and did not report files with a different st_dev entry.

The SVr4 find command did have both -mount and -xdev in 1988 and -xdev was an alias to -mount.

On the other side, SunOS and BSD had a -xdev in 1985 already and since the SunOS/ BSD findwas not implemented on top of *ftw(), it could use a different sematic and it did. find -xdev on SunOS stopped descending after the mount point with the different st_dev has been printed.

Then in 1992, the first POSIX standard that included more than just libc and file formats (like tar) mentioned find with -xdev only. The problem with that POSIX standard is that-xdev has to report mount points and to stop after reporting the moint points while the AT&T implementation stopped before reporting mount points.

GNU find is an implementation that follows the POSIX.1-1992 text.

As a result, we recently discussed a related bug report on the POSIX standard teleconference and decided to enhance the standard with a -mount primary and with a FTW_XDEV flag in nftw().

find -mount has to behave the way as find did behave on AT&T UNIX and must not report mount points.

find -xdev has to behave the way it was written in the POSIX standard and needs to report mount points and stop then with descending the tree.

This requiresAT&T UNIX based find implementations to change their implementation for -xdev and to let GNU find change the behavior of -mount.

BTW: AFAIK, sfind/libfind is currently the only implementation that already follows the new rules.

Since libfidnd implemented the needed code already before the final agreement for POSIX has been set up, it implements a -mount+ primary and -xdev now has become an alias to -mount+ which is easier to memorize for stop at mount points but in addition report them.

  • 1
    GNU find existed before 1992. Note that at least on Linux, devices (same filesystems, or subsets of same filesystems) can be mounted on several directory entries in the filesystem, so -xdev may cross mountpoints if it's a mountpoint of the same filesystem. Nov 5, 2018 at 14:14
  • 1
    A GNU find changelog entry from 1990 has: For -xdev, process filesystem mountpoints (but don't descend them), instead of skipping them entirely., so it was an intentional change back then. Nov 5, 2018 at 14:19
  • So why do you believe that GNU find implemented it wrong, in special as the implemented behavior is in conflict with the documented behavior for nftw()?
    – schily
    Nov 5, 2018 at 14:19
  • On the same 1990 date, another changelog entry mentions POSIX for xargs, so it seems possible indeed that GNU find used to behave like SVR4 but changed to match text in some POSIX draft. Nov 5, 2018 at 14:22
  • BTW, do you know when du -x was added? It seems it wasn't there in svr4 Nov 5, 2018 at 14:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .