nmount or mount (2)

I am trying to mount a ufs device using the function calls mount() or nmount(). The man pages are extremely elusive on this. Does anyone have a sample code I could use?

Aharon :q
 
When in doubt, look at other people's code.

excerpt from /usr/src/sbin/mount_ufs/mount_ufs.c
Code:
 iov = NULL;
  iovlen = 0;
  build_iovec(&iov, &iovlen, "fstype", "ufs", -1);
  build_iovec(&iov, &iovlen, "fspath", mntpath, -1);
  build_iovec(&iov, &iovlen, "from", dev, -1);
  build_iovec(&iov, &iovlen, "flags", &ufs_flags, sizeof ufs_flags);
  build_iovec(&iov, &iovlen, "export", &export, sizeof export);
  if ([red]nmount(iov, iovlen, mntflags)[/red] < 0)
    err(1, "%s", dev);
  exit(0);

A small example of mount() can be found in /usr/src/sbin/mount/mount_ufs.c ... There are probably more examples to be found:
% find /usr/src -type f -exec grep -H mount\( {} \;
(Better use textproc/p5-ack btw.)
 
Back
Top