mirror of
git://git.sv.gnu.org/findutils.git
synced 2026-01-25 03:39:19 +01:00
find: make -mount POSIX 2024 compliant
* find/defs.h (struct options): Add mount member and rename stay_on_filesystem to xdev. * find/ftsfind.c (find): Set FTS_MOUNT flag when -mount is enabled. * find/parser.c (parse_table): Use a separate parser for -mount. (parse_mount): Declare and define function. (parse_xdev): Use xdev option flag. * find/util.c (set_option_defaults): Initialize new struct members. * doc/find.texi (node Filesystems): Add new section describing the new behaviour of -mount and specify the current behaviour of -xdev. * find/find.1: Document the new -mount behaviour and specify current behaviour of -xdev. * NEWS (Changes in find): Mention the -mount behaviour change.
This commit is contained in:
3
NEWS
3
NEWS
@@ -28,6 +28,9 @@ GNU findutils NEWS - User visible changes. -*- outline -*- (allout)
|
||||
are passed with a leading dash, e.g. '-!'. Future releases will not accept
|
||||
that any more. Accepting that was rather a bug "since the beginning".
|
||||
|
||||
The -mount option is now POSIX 2024 compliant. Find will ignore files on
|
||||
different devices as opposed to being a mere alias for -xdev. [#54745]
|
||||
|
||||
** Documentation Changes
|
||||
|
||||
The forthcoming Issue 8 of the POSIX standard will standardise "find
|
||||
|
||||
@@ -1624,10 +1624,12 @@ them.
|
||||
There are two ways to avoid searching certain filesystems. One way is
|
||||
to tell @code{find} to only search one filesystem:
|
||||
|
||||
@deffn Option -mount
|
||||
Ignore files on other devices.
|
||||
@end deffn
|
||||
|
||||
@deffn Option -xdev
|
||||
@deffnx Option -mount
|
||||
Don't descend directories on other filesystems. These options are
|
||||
synonyms.
|
||||
Don't descend into directories on other devices.
|
||||
@end deffn
|
||||
|
||||
The other way is to check the type of filesystem each file is on, and
|
||||
|
||||
@@ -549,8 +549,11 @@ struct options
|
||||
are non-directories. */
|
||||
bool no_leaf_check;
|
||||
|
||||
/* If true, skip files on other devices. */
|
||||
bool mount;
|
||||
|
||||
/* If true, don't cross filesystem boundaries. */
|
||||
bool stay_on_filesystem;
|
||||
bool xdev;
|
||||
|
||||
/* If true, we ignore the problem where we find that a directory entry
|
||||
* no longer exists by the time we get around to processing it.
|
||||
@@ -648,7 +651,7 @@ struct state
|
||||
int starting_path_length;
|
||||
|
||||
/* If true, don't descend past current directory.
|
||||
Can be set by -prune, -maxdepth, and -xdev/-mount. */
|
||||
Can be set by -prune, -maxdepth, -mount and -xdev. */
|
||||
bool stop_at_current_level;
|
||||
|
||||
/* Status value to return to system. */
|
||||
|
||||
10
find/find.1
10
find/find.1
@@ -630,10 +630,7 @@ non-negative integer). Using
|
||||
means process all files except the starting-points.
|
||||
|
||||
.IP \-mount
|
||||
Don't descend directories on other filesystems. An alternate name for
|
||||
.BR \-xdev ,
|
||||
for compatibility with some other versions of
|
||||
.BR find .
|
||||
Ignore files on other devices.
|
||||
|
||||
.IP \-noignore_readdir_race
|
||||
Turns off the effect of
|
||||
@@ -659,7 +656,7 @@ to stat them; this gives a significant increase in search speed.
|
||||
Print the \fBfind\fR version number and exit.
|
||||
|
||||
.IP \-xdev
|
||||
Don't descend directories on other filesystems.
|
||||
Don't descend into directories on other devices.
|
||||
|
||||
.SS TESTS
|
||||
Some tests, for example
|
||||
@@ -1989,7 +1986,7 @@ For closest compliance to the POSIX standard, you should set the
|
||||
.B POSIXLY_CORRECT
|
||||
environment variable.
|
||||
The following options are specified in the POSIX standard
|
||||
(IEEE Std 1003.1-2008, 2016 Edition):
|
||||
(IEEE Std 1003.1-2024 Edition):
|
||||
|
||||
.IP \fB\-H\fR
|
||||
This option is supported.
|
||||
@@ -2053,6 +2050,7 @@ The primaries
|
||||
.BR \-exec ,
|
||||
.BR \-group ,
|
||||
.BR \-links ,
|
||||
.BR \-mount ,
|
||||
.BR \-mtime ,
|
||||
.BR \-nogroup ,
|
||||
.BR \-nouser ,
|
||||
|
||||
@@ -480,7 +480,10 @@ find (char *arg)
|
||||
break;
|
||||
}
|
||||
|
||||
if (options.stay_on_filesystem)
|
||||
if (options.mount)
|
||||
ftsoptions |= FTS_MOUNT;
|
||||
|
||||
if (options.xdev)
|
||||
ftsoptions |= FTS_XDEV;
|
||||
|
||||
p = fts_open (arglist, ftsoptions, nullptr);
|
||||
|
||||
@@ -122,6 +122,7 @@ static bool parse_ls (const struct parser_table*, char *argv[], int *
|
||||
static bool parse_maxdepth (const struct parser_table*, char *argv[], int *arg_ptr);
|
||||
static bool parse_mindepth (const struct parser_table*, char *argv[], int *arg_ptr);
|
||||
static bool parse_mmin (const struct parser_table*, char *argv[], int *arg_ptr);
|
||||
static bool parse_mount (const struct parser_table*, char *argv[], int *arg_ptr);
|
||||
static bool parse_name (const struct parser_table*, char *argv[], int *arg_ptr);
|
||||
static bool parse_negate (const struct parser_table*, char *argv[], int *arg_ptr);
|
||||
static bool parse_newer (const struct parser_table*, char *argv[], int *arg_ptr);
|
||||
@@ -214,7 +215,7 @@ static struct parser_table const parse_table[] =
|
||||
{ ARG_OPTION, "ignore_readdir_race", parse_ignore_race, nullptr }, /* GNU */
|
||||
{ ARG_OPTION, "maxdepth", parse_maxdepth, nullptr }, /* GNU */
|
||||
{ ARG_OPTION, "mindepth", parse_mindepth, nullptr }, /* GNU */
|
||||
{ ARG_OPTION, "mount", parse_xdev, nullptr }, /* Unix */
|
||||
{ ARG_OPTION, "mount", parse_mount, nullptr }, /* POSIX */
|
||||
{ ARG_OPTION, "noleaf", parse_noleaf, nullptr }, /* GNU */
|
||||
{ ARG_OPTION, "noignore_readdir_race", parse_noignore_race, nullptr }, /* GNU */
|
||||
{ ARG_OPTION, "xdev", parse_xdev, nullptr }, /* POSIX */
|
||||
@@ -2476,10 +2477,17 @@ parse_context (const struct parser_table* entry, char **argv, int *arg_ptr)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
parse_mount (const struct parser_table* entry, char **argv, int *arg_ptr)
|
||||
{
|
||||
options.mount = true;
|
||||
return parse_noop (entry, argv, arg_ptr);
|
||||
}
|
||||
|
||||
static bool
|
||||
parse_xdev (const struct parser_table* entry, char **argv, int *arg_ptr)
|
||||
{
|
||||
options.stay_on_filesystem = true;
|
||||
options.xdev = true;
|
||||
return parse_noop (entry, argv, arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -1010,7 +1010,7 @@ set_option_defaults (struct options *p)
|
||||
p->cur_day_start.tv_nsec = p->start_time.tv_nsec;
|
||||
|
||||
p->full_days = false;
|
||||
p->stay_on_filesystem = false;
|
||||
p->mount = p->xdev = false;
|
||||
p->ignore_readdir_race = false;
|
||||
|
||||
if (p->posixly_correct)
|
||||
|
||||
Reference in New Issue
Block a user