more advanced Nginx settings in GUI
[tomato.git] / release / src-rt-6.x.4708 / router / rc / nfs.c
blob833425618664d75d90e38fb1f42924dcb87a1e07
1 /*
2 * nfs.c
4 * Copyright (C) 2011 shibby
6 */
7 #include <rc.h>
8 #include <sys/stat.h>
10 void start_nfs(void)
12 FILE *fp;
13 char *buf;
14 char *g;
15 char *p;
16 int i;
17 char *dir,*address,*access,*sync,*subtree,*other;
19 // only if enable...
20 if( nvram_match( "nfs_enable", "1" ) )
23 // read exports from nvram
24 if ((buf = strdup(nvram_safe_get("nfs_exports"))) != NULL) {
26 // writing data to file
27 if( !( fp = fopen( "/etc/exports", "w" ) ) )
29 perror( "/etc/exports" );
30 return;
33 g = buf;
35 // dir < address < access < sync < subtree < other
37 while ((p = strsep(&g, ">")) != NULL) {
38 i = vstrsep(p, "<", &dir, &address, &access, &sync, &subtree, &other);
39 if (i!=6) continue;
40 fprintf(fp, "%s %s(%s,%s,%s,%s)\n", dir,address,access,sync,subtree,other);
42 free(buf);
45 fclose( fp );
46 chmod( "/etc/exports", 0644 );
50 xstart( "/usr/sbin/nfs.rc" );
51 return;
55 void stop_nfs(void)
57 killall("portmap", SIGTERM);
58 killall("statd", SIGTERM);
59 killall("nfsd", SIGTERM);
60 killall("mountd", SIGTERM);
61 return;