Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fw32.git;a=commitdiff;h=6af4d224fab78659c13ab1903827f0addd96f557
commit 6af4d224fab78659c13ab1903827f0addd96f557 Author: James Buren <r...@frugalware.org> Date: Wed Nov 2 03:52:48 2011 -0500 fw32.c: add is_mounted diff --git a/fw32.c b/fw32.c index 241e234..d1d8d87 100644 --- a/fw32.c +++ b/fw32.c @@ -7,6 +7,8 @@ #include <limits.h> #include <assert.h> +#define FW32_ROOT "/usr/lib/fw32" + static void error(const char *fmt,...) { @@ -61,4 +63,47 @@ mkdir_parents(const char *s) error("Failed to create directory: %s\n",path); } +static bool +is_mounted(const char *path) +{ + FILE *f; + char line[LINE_MAX], *s, *e; + bool found; + + assert(path); + + f = fopen("/proc/mounts","rb"); + + if(!f) + error("Cannot open /proc/mounts for reading.\n"); + + found = false; + + while(fgets(line,sizeof line,f)) + { + s = strchr(line,' '); + + if(!s) + continue; + + e = strchr(++s,' '); + + if(!e) + continue; + + *e = 0; + + if(strcmp(s,path)) + { + found = true; + + break; + } + } + + fclose(f); + + return found; +} + int main(int argc,char **argv) { mkdir_parents(argv[1]); } _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git