03-26-2008
Quote:
One trap I always keep falling into is forgetting to glue back the entry from a readdir to the directory I read it from, i.e. using a relative file name in the wrong (e.g. grandparent) directory.
I tried this and unfortunately had no luck
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello!
I've moved a web from my RHEL5 Apache/2.2.3 machine to a Sun Solaris 5.9 Apache/2.2.6 (Unix) PHP/5.2.5 mod_ssl/2.2.6 machine.
The web worked just fine on the rhel5 machine and most of the php pages works fine on the solaris machine to but not the one where I read a directory and prints... (1 Reply)
Discussion started by: Esaia
1 Replies
2. Shell Programming and Scripting
Hello all,
Here's the deal...I have one directory with many subdirs and files.
What I want to find out is who is keeping old files and directories...say files and dirs that they didn't use since a number of n days, only one level under the initial dir. Output to a file.
A script for... (5 Replies)
Discussion started by: ejianu
5 Replies
3. UNIX for Dummies Questions & Answers
greetings. I'm using debian lenny, bash shell environment.
It is my understanding that by default, the useradd command should create subdirectories under the /home directory, with the same name as the user being created, but this is not happening.
I checked useradd -D and it showed, among... (2 Replies)
Discussion started by: fguy
2 Replies
4. Shell Programming and Scripting
Hello
I have some directories and files created under /export/local/user
I would like to delete directories only under /export/local/user, created before 3 days
Can someone help me with command to do this task?
Thanks (4 Replies)
Discussion started by: needyourhelp10
4 Replies
5. Shell Programming and Scripting
Hi,
I have a challenging requiremant to be done in one day:(
there is directory in which a new directory gets created per hour i.e 24 directories per a day like below.
Dec 01 00:04 2011.12.12-23
Dec 01 01:11 2011.12.10-07
Dec 01 01:11 2011.12.10-08
Dec 01 01:11 2011.12.10-09
Dec 01... (2 Replies)
Discussion started by: mahesh Madpathi
2 Replies
6. Programming
code:
#include<iostream>
#include <dirent.h>
using namespace std;
int main()
{
DIR*dir;
dir = opendir("/");
if (dir !=NULL)
{
struct dirent * abcd;
while ((abcd=readdir (dir))!=NULL)
{
cout << abcd -> d_name;
}
}}
output : this gives the output of Directory "/"
ques : (1 Reply)
Discussion started by: console
1 Replies
7. Homework & Coursework Questions
code:
#include<iostream>
#include <dirent.h>
using namespace std;
int main()
{
DIR*dir;
dir = opendir("/");
if (dir !=NULL)
{
struct dirent * abcd;
while ((abcd=readdir (dir))!=NULL)
{
cout << abcd -> d_name;
}
}}
output : this gives the output of Directory "/"
ques : (1 Reply)
Discussion started by: console
1 Replies
8. Solaris
I have searched this quite a long time but couldn't find the right method for me to use. I need to assign read write permission to the user for specific directories and it's sub directories and files. I do not want to use ACL. This is for Solaris. Please help. (1 Reply)
Discussion started by: blinkingdan
1 Replies
9. Shell Programming and Scripting
Hi All,
I am new in scripting and working in a project where we have RSyslog servers over CentOS v7 and more than 200 network devices are sending logs to each RSyslog servers. For each network devices individual folders create on the name of the each network devices IP addresses.The main... (7 Replies)
Discussion started by: Pinaki
7 Replies
LEARN ABOUT PLAN9
readdir_r
READDIR_R(3) Linux Programmer's Manual READDIR_R(3)
NAME
readdir_r - read a directory
SYNOPSIS
#include <dirent.h>
int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
readdir_r():
_POSIX_C_SOURCE
|| /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
DESCRIPTION
This function is deprecated; use readdir(3) instead.
The readdir_r() function was invented as a reentrant version of readdir(3). It reads the next directory entry from the directory stream
dirp, and returns it in the caller-allocated buffer pointed to by entry. For details of the dirent structure, see readdir(3).
A pointer to the returned buffer is placed in *result; if the end of the directory stream was encountered, then NULL is instead returned in
*result.
It is recommended that applications use readdir(3) instead of readdir_r(). Furthermore, since version 2.24, glibc deprecates readdir_r().
The reasons are as follows:
* On systems where NAME_MAX is undefined, calling readdir_r() may be unsafe because the interface does not allow the caller to specify the
length of the buffer used for the returned directory entry.
* On some systems, readdir_r() can't read directory entries with very long names. When the glibc implementation encounters such a name,
readdir_r() fails with the error ENAMETOOLONG after the final directory entry has been read. On some other systems, readdir_r() may
return a success status, but the returned d_name field may not be null terminated or may be truncated.
* In the current POSIX.1 specification (POSIX.1-2008), readdir(3) is not required to be thread-safe. However, in modern implementations
(including the glibc implementation), concurrent calls to readdir(3) that specify different directory streams are thread-safe. There-
fore, the use of readdir_r() is generally unnecessary in multithreaded programs. In cases where multiple threads must read from the
same directory stream, using readdir(3) with external synchronization is still preferable to the use of readdir_r(), for the reasons
given in the points above.
* It is expected that a future version of POSIX.1 will make readdir_r() obsolete, and require that readdir(3) be thread-safe when concur-
rently employed on different directory streams.
RETURN VALUE
The readdir_r() function returns 0 on success. On error, it returns a positive error number (listed under ERRORS). If the end of the
directory stream is reached, readdir_r() returns 0, and returns NULL in *result.
ERRORS
EBADF Invalid directory stream descriptor dirp.
ENAMETOOLONG
A directory entry whose name was too long to be read was encountered.
ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7).
+------------+---------------+---------+
|Interface | Attribute | Value |
+------------+---------------+---------+
|readdir_r() | Thread safety | MT-Safe |
+------------+---------------+---------+
CONFORMING TO
POSIX.1-2001, POSIX.1-2008.
SEE ALSO
readdir(3)
COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the
latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
2016-03-01 READDIR_R(3)