Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pathbuf(9) [netbsd man page]

PATHBUF(9)						   BSD Kernel Developer's Manual						PATHBUF(9)

NAME
pathbuf, pathbuf_create, pathbuf_assimilate, pathbuf_copyin, pathbuf_destroy -- path buffer abstraction SYNOPSIS
#include <sys/namei.h> struct pathbuf * pathbuf_create(const char *path); struct pathbuf * pathbuf_assimilate(char *pnbuf); int pathbuf_copyin(const char *userpath, struct pathbuf **ret); void pathbuf_destroy(struct pathbuf *path); DESCRIPTION
The pathbuf interface is used to carry around pathnames. This helps simplify the namei(9) interface. A pathbuf should be thought of as a path name string combined with whatever flags and metadata are needed to interpret it correctly. It is an abstract type; the internals are hidden within the namei(9) implementation. The pathbuf_create() function allocates and initializes a new pathbuf containing a copy of the path string path, which should be a kernel pointer. The return value should be checked for being NULL in case the system is out of memory. Passing a path name larger than PATH_MAX will cause an assertion failure. The pathbuf_copyin() function allocates and initializes a new pathbuf containing a path string copied from user space with copyinstr(9). It returns an error code. The pathbuf_assimilate() function creates a pathbuf using the string buffer provided as pnbuf. This buffer must be of size PATH_MAX and must have been allocated with PNBUF_GET(). The buffer is ``taken over'' by the returned pathbuf and will be released when the pathbuf is destroyed. Note: to avoid confusion and pointer bugs, pathbuf_assimilate() should only be used where absolutely necessary; e.g. the NFS server code uses it to generate pathbufs from strings fetched from mbufs. The pathbuf_destroy() function deallocates a pathbuf. Caution: because calling namei(9) loads pointers to memory belonging to the pathbuf into the nameidata structure, a pathbuf should only be destroyed by the namei() caller once all manipulations of the nameidata are complete. Also note that calling namei() destroys the contents of the pathbuf. Do not reuse a pathbuf for a second call to namei(). CODE REFERENCES
The pathbuf code is part of the name lookup code in sys/kern/vfs_lookup.c. SEE ALSO
namei(9) BUGS
There are cases where it is necessary to get the path string left behind after namei() has run. This produces an effect similar to realpath(3). The interface for doing this is, for the time being, intentionally undocumented and subject to change. BSD
November 30, 2010 BSD

Check Out this Related Man Page

CONFSTR(3)						     Linux Programmer's Manual							CONFSTR(3)

NAME
confstr - get configuration dependent string variables SYNOPSIS
#include <unistd.h> size_t confstr(int name, char *buf, size_t len); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): confstr(): _POSIX_C_SOURCE >= 2 || _XOPEN_SOURCE DESCRIPTION
confstr() gets the value of configuration-dependent string variables. The name argument is the system variable to be queried. The following variables are supported: _CS_GNU_LIBC_VERSION (GNU C library only; since glibc 2.3.2) A string which identifies the GNU C library version on this system (e.g, "glibc 2.3.4"). _CS_GNU_LIBPTHREAD_VERSION (GNU C library only; since glibc 2.3.2) A string which identifies the POSIX implementation supplied by this C library (e.g, "NPTL 2.3.4" or "linuxthreads-0.10"). _CS_PATH A value for the PATH variable which indicates where all the POSIX.2 standard utilities can be found. If buf is not NULL and len is not zero, confstr() copies the value of the string to buf truncated to len - 1 characters if necessary, with a null byte ('') as terminator. This can be detected by comparing the return value of confstr() against len. If len is zero and buf is NULL, confstr() just returns the value as defined below. RETURN VALUE
If name is a valid configuration variable, confstr() returns the number of bytes (including the terminating null byte) that would be required to hold the entire value of that variable. This value may be greater than len, which means that the value in buf is truncated. If name is a valid configuration variable, but that variable does not have a value, then confstr() returns 0. If name does not correspond to a valid configuration variable, confstr() returns 0, and errno is set to EINVAL. ERRORS
EINVAL If the value of name is invalid. CONFORMING TO
POSIX.1-2001. EXAMPLE
The following code fragment determines the path where to find the POSIX.2 system utilities: char *pathbuf; size_t n; n = confstr(_CS_PATH,NULL,(size_t) 0); pathbuf = malloc(n); if (pathbuf == NULL) abort(); confstr(_CS_PATH, pathbuf, n); SEE ALSO
sh(1), exec(3), system(3) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2010-02-03 CONFSTR(3)
Man Page