---
name: "dpns_readdirxr"
section: "3"
platform: "linux"
package: "libdpm-dev"
version: "1.10.0-2+b3"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/dpns_readdirxr"
---

# dpns\_readdirxr(3)

read DPNS directory opened by dpns\_opendir in the name server

## NAME

dpns\_readdirxr - read DPNS directory opened by **dpns\_opendir** in the name server

## SYNOPSIS

**#include \<sys/types.h\>**\
 **#include "dpns\_api.h"**

**struct dpns\_direnrep \*dpns\_readdirxr (dpns\_DIR \****dirp***,** **char \****se***)**

## DESCRIPTION

**dpns\_readdirxr** reads the DPNS directory opened by **dpns\_opendir** in the name server. This routine returns a pointer to a structure containing the current directory entry (basename, guid and filesize) and the replica information.

```
struct dpns_rep_info {
	u_signed64	fileid;
	char		status;
	char		*host;
	char		*sfn;
};
struct dpns_direnrep {
	u_signed64	fileid;
	char		guid[CA_MAXGUIDLEN+1];
	mode_t		filemode;
	u_signed64	filesize;
	int		nbreplicas;
	struct dpns_rep_info *rep;	/* array of replica info structures */
	unsigned short	d_reclen;	/* length of this entry */
	char		d_name[1];	/* basename in variable length */
};
```

**dpns\_readdirxr** caches a variable number of such entries, depending on the filename size, to minimize the number of requests to the name server.

- *dirp*

  specifies the pointer value returned by **dpns\_opendir**.

- *se*

  allows to restrict the replica entries to a given SE.

## RETURN VALUE

This routine returns a pointer to a structure containing the current directory entry if the operation was successful or NULL if the end of the directory was reached or if the operation failed. When the end of the directory is encountered, serrno is not changed. If the operation failed, **serrno** is set appropriately.

As dpns\_readdirxr returns a null pointer both at the end of the directory and on error, an application wishing to check for error situations should set **serrno** to 0, then call dpns\_readdirxr, then check **serrno** and if it is non-zero, assume an error has occurred.

## ERRORS

- **EBADF**

  File descriptor in DIR structure is invalid.

- **ENOMEM**

  Memory could not be allocated for unmarshalling the reply.

- **EFAULT**

  *dirp* is a NULL pointer.

- **EINVAL**

  The length of *se* exceeds **CA\_MAXHOSTNAMELEN**.

- **SECOMERR**

  Communication error.

- **ENSNACT**

  Name server is not running or is being shutdown.

## SEE ALSO

**[dpns\_closedir(3)](/dpns_closedir/3.md)**, **[dpns\_opendir(3)](/dpns_opendir/3.md)**, **[dpns\_rewinddir(3)](/dpns_rewinddir/3.md)**

## AUTHOR

**LCG Grid Deployment** Team
