diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2011-03-09 12:15:57 +0100 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2011-03-09 12:15:57 +0100 |
commit | 06aca6c3facc4e48d0170fb766b47d919b5258e0 (patch) | |
tree | bc880c351a109706b7419835aa0b6223a9fdab85 /apt-pkg/contrib/cdromutl.cc | |
parent | 0245fd39e5bfb74c45cd70b815b603565e9529b6 (diff) | |
parent | f7cbd1fbc57bc13dfc2ebc246453ab0875d4151a (diff) |
cherry pick from lp:~mvo/apt/mvo
Diffstat (limited to 'apt-pkg/contrib/cdromutl.cc')
-rw-r--r-- | apt-pkg/contrib/cdromutl.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 68b980407..cf1c0c29b 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -15,6 +15,7 @@ #include <apt-pkg/md5.h> #include <apt-pkg/fileutl.h> #include <apt-pkg/configuration.h> +#include <apt-pkg/strutl.h> #include <apti18n.h> @@ -234,3 +235,33 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version) return true; } /*}}}*/ + +// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/ +char* FindMountPointForDevice(const char *devnode) +{ + char buf[255]; + char *out[10]; + int i=0; + + // this is the order that mount uses as well + const char *mount[] = { "/etc/mtab", + "/proc/mount", + NULL }; + + for (i=0; mount[i] != NULL; i++) { + if (FileExists(mount[i])) { + FILE *f=fopen(mount[i], "r"); + while ( fgets(buf, sizeof(buf), f) != NULL) { + if (strncmp(buf, devnode, strlen(devnode)) == 0) { + if(TokSplitString(' ', buf, out, 10)) + return strdup(out[1]); + } + } + fclose(f); + } + } + + return NULL; +} + + |