libgslutil
1.2.3
|
Functions | |
int | gslutil_nfs_mount (const char *src, const char *target, unsigned long mountflags, const char *opts, char *err_msg, int err_msg_len) |
Mount an NFS filesystem. More... | |
A simple wrapper function around mount(2)
that help to mount an NFS filesystem. It can be used to programatically mount an NFS filesystem on demand, much like calling mount -t nfs
. The wrapper function provide two things beyond mount(2)
: DNS lookups and policy defaults.
Technically this requires a 2.6.23 kernel, as it uses the more advanced textual version of the opaque data pointer. Its policy defaults are:
hard
ac
nolock
cto
It will perform a DNS lookup to fill out the addr
field of the mount(2)
data.
int gslutil_nfs_mount | ( | const char * | src, |
const char * | target, | ||
unsigned long | mountflags, | ||
const char * | opts, | ||
char * | err_msg, | ||
int | err_msg_len | ||
) |
Mount an NFS filesystem.
src | Source address, in form hostname:/directory . |
target | Target mountpoint, e.g. /mnt . |
mountflags | Flags for mount(2) . |
opts | Options from nfs(5) . May be 0. |
err_msg | Buffer for error message. May be 0. |
err_msg_len | Size of error message buffer, in bytes. |
-1 | on error (and see err_msg). |
0 | on success. |
A wrapper function around mount(2)
which helps perform an NFS mount. It performs a DNS lookup on the hostname in src and builds an option string suitable for passing to the kernel (fs/nfs/super.c
), and then actually calls mount(2)
.
On any error, this function returns -1, and writes a descriptive error message in to err_msg (unless it is null, in which case the error cannot be recovered). Don't rely on errno, since some of the types of error are from getaddrinfo(3)
and others are from internal checks in the function.