Page 1 of 1

error mounting shared folders programmatically

Posted: 13. Apr 2011, 23:26
by Bernon66
Host: Win7, Guest: Ubuntu 10.10 (Linux 2.6.35-28-generic), VBox: 4.0.4r70112, uid=root

When attempting to mount shared folders via C code, getting error 71 (Protocol Error).
I am NOT running the program from the mount folder.
I have tried using a different name for the share and the mount target but that did not help.
When I manually mount, it works.

Code: Select all

     mount -t vboxsf vm_shared /mnt/vm_shared
I am running the program as root.

Test Code:

Code: Select all

#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mount.h>

void main(void) 
{
    int r;
    r = mount("vm_shared", "/mnt/vm_shared", "vboxsf", 0, "user,exec,rw");
    if(r == -1)
        printf("%d - %s\n", errno, strerror(errno));
}
I have tried various strings for the data (last) parameter including NULL (gives an invalid argument error), "", "rw", "rw,exec" and various others (all give protocol error).

Any ideas?

Thank you.