Browse Source Download (without any required ccan dependencies)

Module:

nfs

Summary:

nfs client library

Author:

Ronnie Sahlberg <ronniesahlberg@gmail.com>

Dependencies:

Description:

This code offers a POSIX-like interface directly to an NFS server.

Example:

 #include <ccan/nfs/nfs.h>
 #include <err.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>

 int main(int argc, char *argv[])
 {
      struct nfs_context *nfs;
      struct stat st;

      if (argc != 4)
              errx(1, "Usage: %s <serveraddr> <export> <filename>", argv[0]);
      nfs = nfs_init_context();
      if (!nfs)
              err(1, "Initializing nfs context");

      if (nfs_mount_sync(nfs, argv[1], argv[2]) != 0)
              errx(1, "Failed to mount nfs share: %s", nfs_get_error(nfs));

      if (nfs_stat_sync(nfs, argv[3], &st) != 0)
              errx(1, "Failed to stat(%s): %s", argv[3], nfs_get_error(nfs));

      printf("Mode %04o\n", st.st_mode);
      printf("Size %u\n", (int)st.st_size);
      printf("Inode %u\n", (int)st.st_ino);

      nfs_destroy_context(nfs);
      printf("nfsclient finished\n");
      return 0;
}

License:

GPL