6 #include <Application.h>
10 #include <sys/socket.h>
11 #include <arpa/inet.h>
13 #include <fs_volume.h>
14 int mount(const char *filesystem
, const char *where
, const char *device
, ulong flags
, void *parameters
, size_t len
)
17 return fs_mount_volume(where
, device
, filesystem
, flags
, (const char *)parameters
);
23 struct mount_nfs_params
25 unsigned int serverIP
;
33 void usage (const char *exename
);
35 void usage (const char *exename
)
37 printf ("usage: %s server:export mountpoint uid gid\n",exename
);
40 int main (int argc
, char **argv
)
43 signal(SIGINT
, SIG_IGN
);
44 signal(SIGHUP
, SIG_IGN
);
46 //BApplication theApp ("application/x-vnd.barecode-mount_nfs");
55 if (stat(argv
[2],&st
)<B_NO_ERROR
)
57 printf ("mountpoint does not exist\n");
61 char *colon
=strchr(argv
[1],':');
69 int serverLength
=colon
-argv
[1];
70 char *server
=new char[serverLength
+1];
71 memcpy (server
,argv
[1],serverLength
);
72 server
[serverLength
]=0;
76 ent
=gethostbyname (server
);
80 printf ("could not get server ip\n");
85 unsigned int serverIP
=ntohl(*((unsigned int *)ent
->h_addr
));
87 mount_nfs_params params
;
89 params
.serverIP
=serverIP
;
91 params
._export
=colon
+1;
93 sscanf (argv
[3],"%d",¶ms
.uid
);
94 sscanf (argv
[4],"%d",¶ms
.gid
);
97 gethostname (hostname
,256);
99 params
.hostname
=hostname
;
101 sprintf(buf
, "nfs:%s:%s,uid=%u,gid=%u,hostname=%s",
102 inet_ntoa(*((struct in_addr
*)ent
->h_addr
)),
108 int result
=mount ("nfs",argv
[2],NULL
,0,buf
,strlen(buf
));
109 //int result=mount ("nfs",argv[2],NULL,0,¶ms,sizeof(params));
113 if (result
<B_NO_ERROR
)
115 printf ("mount failed (%s)\n",strerror(result
));