This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

mount() in C library

Hi

I try to use the following c function to mount a nfs directory in my c program on a DM8168 DaVinci EVM board using EZSDK 5.02.

mount("10.112.12.150:/home/chan/media", "/home/tt/media", "nfs", 0, "-o nolock");

It always fails.  However, the C function, umount(), is working.

Even when I do the mount in the console, "mount -o nolock 10.112.12.150:/home/chan/media /home/tt/media" would fail, but put busybox before this mount command would make it work.

busybox mount -o nolock 10.112.12.150:/home/chan/media /home/tt/media

Any kind of help is appreciated.

Wai Kwok

 

  • Some speculation on my part. No expert at this. I would guess that your "mount" command paths to a real "mount" binary. On most embedded systems, it is usually a symbolic link to "busybox" with "mount" as a command line parameter. In that case, "mount" and "busybox mount" are the same executable. You can try "which mount" to see what "mount" really is.

    Maybe you have to explicitly say it's NFS:

    mount 10.112.12.150:/home/chan/media /home/tt/media -t nfs -o nolock

    I'v seen some posts on this forum where NFS mounts requires the address repeated as an option. Typical command line:

    mount 10.112.12.150:/home/chan/media /home/tt/media -t nfs -o rw,nolock,addr=10.112.12.150

    The busybox implementation does not simply pass the command line argument to mount(). The source is here:

    http://git.busybox.net/busybox/tree/util-linux/mount.c

    They pass a nfs_mount_data structure instead a string for the last parameter. They do a lot of work initializing that structure. Although I think the kernel supports both a structure and a plain string. I don't know why they do what they do.

  • I think I can help with this:

    As explained here ( http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/717/p/140168/505340.aspx#505340 ), in the ez-sdk the mount command that is accesible through the system path, is implemented as a symbolic link to mount.util-linux-ng , which does not have support for nfs mounts.

    Busybox on the filesystem provided by the SDK has limited support for nfs, so if you just need read only access to you nfs mounts, an easy workaround is to delete or rename /bin/mount, and create a new symlink this way:

    ln -s /bin/busybox /bin/mount

    If you want full support for read-write nfs mounts, I think that what you have to do, is install nfs-utils in your system.

    I hope this helps.

  • Thanks very much for all the answers. The busybox mount is good enough as my application only requires read only file access. BTW, does the C function call the mount command, /bin/mount?

  • Good question. I cannot test it right now, as I don't have access to my EVM today, but an easy way to test that would be to move the mount file to some place outside the system path (mv /bin/mount /home/root/mount ), execute your code, watch the results, and put it back in it's place ( mv /home/root/mount /bin/mount ).

  • I believe mount() is in GNU's libc that is wrapper around a system call to the kernel. The kernel source is at fs/namespace.c. I don't think mount() shells out and runs "bin/mount". The "/bin/mount" is probably a program that just parses commands lines and passes off the kernel call as well. Source is supposed to be in the utils-linux package.