On Fri, 4 November 2005 12:38:51 +0100, [email protected] 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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]