libgslutil  1.2.3
Functions
NFS mount helpers

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...
 

Detailed Description

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:

It will perform a DNS lookup to fill out the addr field of the mount(2) data.

Function Documentation

◆ gslutil_nfs_mount()

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.

Parameters
srcSource address, in form hostname:/directory.
targetTarget mountpoint, e.g. /mnt.
mountflagsFlags for mount(2).
optsOptions from nfs(5). May be 0.
err_msgBuffer for error message. May be 0.
err_msg_lenSize of error message buffer, in bytes.
Return values
-1on error (and see err_msg).
0on 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.