funcion mount y NFS
Hola, estoy intentando montar una un directorio por NFS
mediante un programita. Intento usar la funcion "mount" de
glibc. Segun "man 2 mount" es posible esta idea pasando una
estructura como ultimo parametro a la funcion:
int mount(const char *fespecial, const char * dir , const
char * tiposf, unsigned long le , const void * datos);
No soy capaz de lograrlo, no se si los campos de la estructura
los relleno mal o que. El mensaje obtenido en el "perror" es:
argumento invalido. El kernel me indica:
nfs_read_super: missing data argument
Mi codigo es el siguiente: ********************
#include <stdio.h>
#include <errno.h>
#include <netdb.h>
#include <sys/mount.h>
#include <netinet/in.h>
#include <arpa/inet.h> /* inet_ntoa */
#include <linux/nfs.h>
#include <linux/nfs_mount.h>
int main (int argc, char *argv[])
{
struct nfs_mount_data ServerNFS;
struct hostent *host_remoto;
if (argc < 2){
printf("Usage: montafs nombre_host\n");
exit(1);
}
if ( (host_remoto = gethostbyname(argv[1])) == NULL){
perror("Host no accesible");
exit(1);
}
memset(&ServerNFS, 0, sizeof(ServerNFS));
ServerNFS.version = NFS_MOUNT_VERSION;
ServerNFS.fd = -1;
strcpy(ServerNFS.root.data,"/mnt");
ServerNFS.flags = NFS_MOUNT_SOFT;
ServerNFS.rsize = 8192;
ServerNFS.wsize = 8192;
ServerNFS.timeo = 7;
ServerNFS.retrans = 3;
ServerNFS.acregmin = 3;
ServerNFS.acregmax = 60;
ServerNFS.acdirmin = 30;
ServerNFS.acdirmax = 60;
ServerNFS.addr.sin_family = AF_INET;
ServerNFS.addr.sin_port = 0;
memcpy(&ServerNFS.addr.sin_addr, host_remoto->h_addr,
host_remoto->h_length);
strcpy(ServerNFS.hostname, argv[1]);
ServerNFS.namlen = NAME_MAX;
ServerNFS.bsize = 0;
printf ("direccion estructura: %p\n", &ServerNFS);
if ( mount("HOSTREMOTO:/mnt", "/export", "nfs", MS_RDONLY, (void *)
&ServerNFS) ){
perror("\nError en montaje");
return 1;
}
return 0;
}
*****************************************
¿Alguien ha usado la funcion mount para esto?
¿Alguna idea?
Gracias.
Reply to: