True. And this also has been taken care of.
--Subrata--
On Tue, 2007-11-13 at 13:33 +0800, Cai Qian wrote:
> Hi,
>
> The test case attempts to read all /proc/<pid> directories. However,
> processes may disappear during the test, so we have seen errors like
> this,
>
> /proc/2143: lstat: No such file or directory
>
> It can happen like this, just after readdir(2) got the name of the
> directory 2143, the process 2143 may be terminated. In addition, there
> are windows among lstat(2), open(2), and read(2) for this failure to
> happen too.
>
> Also, it is inefficient to read all /proc/<pid> directories, which are
> identical structures.
>
> The following patch skip read of all /proc/<pid> directories except
> /proc/self. Therefore, it make sure that at least one /proc/<pid> has
> been read, and also the directory will stay as long as the life time of
> the test.
>
> Regards,
> CQ
>
> plain text document attachment (skip_pid.patch)
> --- testcases/kernel/fs/proc/proc01.c.p1 2007-11-13 12:35:59.000000000
> +0800
> +++ testcases/kernel/fs/proc/proc01.c 2007-11-13 12:57:43.000000000 +0800
> @@ -34,6 +34,7 @@
> #include <dirent.h> /* for opendir(), readdir(), closedir() */
> #include <unistd.h>
> #include <fcntl.h>
> +#include <fnmatch.h>
>
> #include "test.h"
> #include "usctest.h"
> @@ -51,6 +52,7 @@
> static char *opt_buffsizestr;
>
> static char *procpath = "/proc";
> +static char selfpath[] = "/proc/self";
> size_t buffsize = 1024;
>
> /* FIXME: would it overflow on 32bits systems with >4Go RAM (HIGHMEM) ? */
> @@ -142,14 +144,14 @@
> return 0;
> }
>
> - /* prevent loops .. */
> - if (S_ISLNK(statbuf.st_mode))
> + /* prevent loops, but read /proc/self. */
> + if (S_ISLNK(statbuf.st_mode) && strcmp(obj, selfpath))
> return 0;
>
> total_obj++;
>
> /* Take appropriate action, depending on the file type */
> - if (S_ISDIR(statbuf.st_mode)) {
> + if (S_ISDIR(statbuf.st_mode) || !strcmp(obj, selfpath)) {
> /* object is a directory */
>
> /* Open the directory to get access to what is in it */
> @@ -166,10 +168,12 @@
> for (dir_ent = (struct dirent *)readdir(dir);
> dir_ent != NULL; dir_ent = (struct dirent *)readdir(dir)) {
>
> - /* Ignore "." or ".." */
> + /* Ignore ".", "..", "kcore", and "/proc/<pid>". */
> if (!strcmp(dir_ent->d_name, ".")
> || !strcmp(dir_ent->d_name, "..")
> - || !strcmp(dir_ent->d_name, "kcore"))
> + || !strcmp(dir_ent->d_name, "kcore")
> + || (!fnmatch("[0-9]*", dir_ent->d_name,
> FNM_PATHNAME)
> + && !strcmp(obj, procpath)))
> continue;
>
> if (opt_verbose)
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________ Ltp-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ltp-list
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list