🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #13452

funcion mount y NFS

#13452
From: Javi Roman
Date: Sat, 17 Feb 2001 10:29
81 lines
3159 bytes
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.
Technical Details
Message-ID: <3A8E52A7.8C910FC8@wanadoo.es>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!nntp.cs.ubc.ca!sunqbc.risq.qc.ca!cpk-news-hub1.bbnplanet.com!news.gtei.net!opentransit.net!newsfeed.comtenidos.com!m2newsfeeder01!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,194f9a2f6ecea2e8,start
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2001-02-17 02:42:03 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!nntp.cs.ubc.ca!sunqbc.risq.qc.ca!cpk-news-hub1.bbnplanet.com!news.gtei.net!opentransit.net!newsfeed.comtenidos.com!m2newsfeeder01!not-for-mail
From: Javi Roman <javiroman@wanadoo.es>
Newsgroups: es.comp.os.linux.programacion
Subject: funcion mount y NFS
Date: Sat, 17 Feb 2001 11:29:59 +0100
Organization: Wanadoo
Lines: 82
Message-ID: <3A8E52A7.8C910FC8@wanadoo.es>
NNTP-Posting-Host: usuario3-36-18-4.dialup.uni2.es
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: m2wpersoisp01.wanadoo.es 982405787 3442 62.36.18.4 (17 Feb 2001 10:29:47 GMT)
X-Complaints-To: usenet@m2wpersoisp01.wanadoo.es
NNTP-Posting-Date: Sat, 17 Feb 2001 10:29:47 +0000 (UTC)
X-Mailer: Mozilla 4.75 [es] (X11; U; Linux 2.2.16-22 i686)
X-Accept-Language: en