43 if ( ! obj.
opts.empty() )
57 MIL <<
"~Mount()" << endl;
64 MIL <<
"~Mount() end" << endl;
68 const std::string & target,
69 const std::string & filesystem,
70 const std::string & options,
73 const char *
const argv[] = {
76 "-o", options.c_str(),
95 while ( output.length() > 0)
100 ret = output.find_first_of (
"\n" );
101 if ( ret != std::string::npos )
103 value.assign ( output, 0, ret );
110 DBG <<
"stdout: " << value << endl;
112 if ( value.find (
"is already mounted on" ) != std::string::npos )
114 err =
"Media already mounted";
116 else if ( value.find (
"ermission denied" ) != std::string::npos )
118 err =
"Permission denied";
120 else if ( value.find (
"wrong fs type" ) != std::string::npos )
122 err =
"Invalid filesystem on media";
124 else if ( value.find (
"No medium found" ) != std::string::npos )
126 err =
"No medium found";
128 else if ( value.find (
"Not a directory" ) != std::string::npos )
132 err =
"Nfs path is not a directory";
136 err =
"Unable to find directory on the media";
150 else if ( status != 0 && err ==
"" )
152 err =
"Mounting media failed";
156 WAR <<
"mount " << source <<
" " << target <<
": " << err << endl;
159 MIL <<
"mounted " << source <<
" " << target << endl;
165 const char *
const argv[] = {
184 while ( output.length() > 0)
189 ret = output.find_first_of (
"\n" );
190 if ( ret != std::string::npos )
192 value.assign ( output, 0, ret );
199 DBG <<
"stdout: " << value << endl;
206 if ( value.find (
"device is busy" ) != std::string::npos )
208 err =
"Device is busy";
221 else if ( status != 0 && err ==
"" )
223 err =
"Unmounting media failed";
227 WAR <<
"umount " << path <<
": " << err << endl;
230 MIL <<
"unmounted " << path << endl;
278 MountEntries entries;
279 std::vector<std::string> mtabs;
280 bool verbose =
false;
284 mtabs.push_back(
"/proc/mounts");
292 mtabs.push_back(
"/etc/mtab");
296 mtabs.push_back(mtab);
299 std::vector<std::string>::const_iterator t;
300 for( t=mtabs.begin(); t != mtabs.end(); ++t)
304 DBG <<
"Reading mount table from '" << *t <<
"'" << std::endl;
306 FILE *fp = setmntent(t->c_str(),
"re");
309 char buf[PATH_MAX * 4];
312 memset(buf, 0,
sizeof(buf));
313 memset(&ent, 0,
sizeof(ent));
315 while( getmntent_r(fp, &ent, buf,
sizeof(buf)) != NULL)
317 if( ent.mnt_fsname && *ent.mnt_fsname &&
318 ent.mnt_dir && *ent.mnt_dir &&
319 ent.mnt_type && *ent.mnt_type &&
320 ent.mnt_opts && *ent.mnt_opts)
323 ent.mnt_fsname, ent.mnt_dir,
324 ent.mnt_type, ent.mnt_opts,
325 ent.mnt_freq, ent.mnt_passno
333 if ( entry.
src.size() > 1
334 && entry.
src[entry.
src.size()-1] ==
'/' )
336 entry.
src.erase( entry.
src.size()-1 );
338 entries.push_back(entry);
340 memset(buf, 0,
sizeof(buf));
341 memset(&ent, 0,
sizeof(ent));
348 WAR <<
"Unable to read any entry from the mount table '" << *t <<
"'" 362 WAR <<
"Failed to read the mount table '" << *t <<
"': "
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
bool kill()
Kill the program.
String related utilities and Regular expression matching.
std::string receiveLine()
Read one line from the input stream.
std::string type
filesystem / mount type
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
Stderr_Disposition
Define symbols for different policies on the handling of stderr.
int close()
Wait for the progamm to complete.
std::string opts
mount options
A "struct mntent" like mount entry structure, but using std::strings.
Wrapper class for ::stat/::lstat.
std::string strerror(int errno_r)
Return string describing the error_r code.
Easy-to use interface to the ZYPP dependency resolver.
std::string src
name of mounted file system
std::string dir
file system path prefix