error mounting shared folders programmatically

Discussions about using Linux guests in VirtualBox.
Post Reply
Bernon66
Posts: 1
Joined: 13. Apr 2011, 22:22
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Linux

error mounting shared folders programmatically

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