Re: [RFC,PATCH] libfs dcache_readdir() and dcache_dir_lseek() bugfix

From: Jörn Engel
Date: Fri Nov 04 2005 - 07:55:15 EST


On Fri, 4 November 2005 12:38:51 +0100, jblunck@xxxxxxx wrote:

> #include <stdio.h>
> #include <unistd.h>
> #include <dirent.h>
>
> int main(int argc, char *argv[])
> {
> DIR *dir;
> struct dirent *entry;
> unsigned int offset;
>
> if (argc < 2) {
> printf("USAGE: %s <directory>\n", argv[0]);
> return 1;
> }
>
> dir = opendir(argv[1]);
> if (!dir)
> return 1;
>
> while((entry = readdir(dir)) != NULL) {
> seekdir(dir, entry->d_off);
> printf("name=%s\tino=%d off=%d\n", entry->d_name, entry->d_ino,
> entry->d_off);
> if (*entry->d_name == '.')
> continue;

That catches "." and "..", but also ".foo". Doesn't matter for the
test, just wanted to mention it.

> if(unlink(entry->d_name) != 0)
> break;
> }
>
> closedir(dir);
> return 0;
> }


Jörn

--
With a PC, I always felt limited by the software available. On Unix,
I am limited only by my knowledge.
-- Peter J. Schoenster
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/