summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-03-09 14:38:07 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-03-13 13:58:45 +0100
commit454b97a57ff3b7ced87ac359658adecaae7af7ee (patch)
tree0cff9eabf2662c577220b52df070c698010163d2 /apt-pkg
parent79bde56ea93b396e509fff0ad7a490f949aa5aa4 (diff)
no error for non-existing mountpoints in MountCdrom
The mountpoint might be auto-generated by the mount command so pushing an error on the stack will confuse the following code and let it believe an unrecoverable error occured while potentially everything is okay. Same goes for umount as a non-existing mountpoint is by definition not mounted.
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/cdromutl.cc28
1 files changed, 20 insertions, 8 deletions
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index 176cc2024..f850e08a5 100644
--- a/apt-pkg/contrib/cdromutl.cc
+++ b/apt-pkg/contrib/cdromutl.cc
@@ -74,7 +74,13 @@ bool IsMounted(string &Path)
leave /etc/mtab inconsitant. We drop all messages this produces. */
bool UnmountCdrom(string Path)
{
- if (IsMounted(Path) == false)
+ // do not generate errors, even if the mountpoint does not exist
+ // the mountpoint might be auto-created by the mount command
+ // and a non-existing mountpoint is surely not mounted
+ _error->PushToStack();
+ bool const mounted = IsMounted(Path);
+ _error->RevertToStack();
+ if (mounted == false)
return true;
for (int i=0;i<3;i++)
@@ -86,8 +92,9 @@ bool UnmountCdrom(string Path)
if (Child == 0)
{
// Make all the fds /dev/null
- for (int I = 0; I != 3; I++)
- dup2(open("/dev/null",O_RDWR),I);
+ int const null_fd = open("/dev/null",O_RDWR);
+ for (int I = 0; I != 3; ++I)
+ dup2(null_fd, I);
if (_config->Exists("Acquire::cdrom::"+Path+"::UMount") == true)
{
@@ -121,19 +128,24 @@ bool UnmountCdrom(string Path)
/* We fork mount and drop all messages */
bool MountCdrom(string Path, string DeviceName)
{
- if (IsMounted(Path) == true)
+ // do not generate errors, even if the mountpoint does not exist
+ // the mountpoint might be auto-created by the mount command
+ _error->PushToStack();
+ bool const mounted = IsMounted(Path);
+ _error->RevertToStack();
+ if (mounted == true)
return true;
-
+
int Child = ExecFork();
// The child
if (Child == 0)
{
// Make all the fds /dev/null
- int null_fd = open("/dev/null",O_RDWR);
- for (int I = 0; I != 3; I++)
+ int const null_fd = open("/dev/null",O_RDWR);
+ for (int I = 0; I != 3; ++I)
dup2(null_fd, I);
-
+
if (_config->Exists("Acquire::cdrom::"+Path+"::Mount") == true)
{
if (system(_config->Find("Acquire::cdrom::"+Path+"::Mount").c_str()) != 0)