Ticket #5679: isMounted.2.patch
File isMounted.2.patch, 10.3 KB (added by , 16 years ago) |
---|
-
mythtv/libs/libmyth/mythmedia.h
86 86 87 87 MediaType getMediaType() const { return m_MediaType; } 88 88 89 bool isSuperMount() const { return m_SuperMount; }89 bool isSuperMount() const { return m_SuperMount; } 90 90 91 91 virtual MediaError testMedia() { return MEDIAERR_UNSUPPORTED; } 92 92 virtual bool openDevice(); … … 99 99 virtual MediaError unlock(); 100 100 virtual bool performMountCmd( bool DoMount ); 101 101 102 bool mount() { return performMountCmd(true);}102 bool mount() { return performMountCmd(true); } 103 103 bool unmount() { return performMountCmd(false); } 104 bool isMounted(bool bVerify = false);105 104 105 bool isMounted(bool bVerify = true); 106 bool findMountPath(); 107 106 108 void RegisterMediaExtensions(uint mediatype, 107 109 const QString& extensions); 108 110 -
mythplugins/mythgallery/mythgallery/iconview.cpp
317 317 MediaMonitor *mon = MediaMonitor::GetMediaMonitor(); 318 318 if (m_currDevice && mon && mon->ValidateAndLock(m_currDevice)) 319 319 { 320 bool mounted = m_currDevice->isMounted( true);320 bool mounted = m_currDevice->isMounted(); 321 321 if (!mounted) 322 322 mounted = m_currDevice->mount(); 323 323 … … 460 460 { 461 461 m_currDevice = item->GetMediaDevice(); 462 462 463 if (!m_currDevice->isMounted( ))463 if (!m_currDevice->isMounted(false)) 464 464 m_currDevice->mount(); 465 465 466 466 item->SetPath(m_currDevice->getMountPath(), true); -
mythtv/libs/libmyth/mediamonitor-unix.cpp
161 161 sysfs.cd(*it); 162 162 163 163 QFile removable(sysfs.absFilePath("removable")); 164 if (removable.exists() )164 if (removable.exists() && removable.open(QIODevice::ReadOnly)) 165 165 { 166 removable.open(QIODevice::ReadOnly);167 166 int c = removable.getch(); 168 167 removable.close(); 169 168 -
mythtv/libs/libmyth/mythcdrom-freebsd.cpp
54 54 if (errno == EBUSY) 55 55 { 56 56 //cout << "errno == EBUSY" << endl; 57 return isMounted( true) ? MEDIAERR_OK : MEDIAERR_FAILED;57 return isMounted() ? MEDIAERR_OK : MEDIAERR_FAILED; 58 58 } 59 59 else 60 60 { -
mythtv/libs/libmyth/mythcdrom-linux.cpp
327 327 VERBOSE(VB_MEDIA+VB_EXTRA, LOC + ":testMedia - failed to open " 328 328 + getDevicePath() + ENO); 329 329 if (errno == EBUSY) 330 return isMounted( true) ? MEDIAERR_OK : MEDIAERR_FAILED;330 return isMounted() ? MEDIAERR_OK : MEDIAERR_FAILED; 331 331 else 332 332 return MEDIAERR_FAILED; 333 333 } … … 387 387 return m_Status; 388 388 // If the disc is ok and we already know it's mediatype 389 389 // returns MOUNTED. 390 if (isMounted( true))390 if (isMounted()) 391 391 return setStatus(MEDIASTAT_MOUNTED, OpenedHere); 392 392 break; 393 393 case CDS_TRAY_OPEN: … … 448 448 449 449 // the base class's onDeviceMounted will do fine 450 450 // grained detection of the type of data on this disc 451 if (isMounted( true))451 if (isMounted()) 452 452 onDeviceMounted(); 453 453 else 454 454 if (mount()) … … 456 456 else 457 457 return setStatus(MEDIASTAT_ERROR, OpenedHere); 458 458 459 if (isMounted( true))459 if (isMounted()) 460 460 { 461 461 // pretend we're NOTMOUNTED so setStatus emits 462 462 // a signal … … 488 488 return setStatus(MEDIASTAT_USEABLE, OpenedHere); 489 489 #else 490 490 mount(); 491 if (isMounted( true))491 if (isMounted()) 492 492 { 493 493 // pretend we're NOTMOUNTED so setStatus 494 494 // emits a signal … … 528 528 VERBOSE(VB_MEDIA, QString("Current status == ") + 529 529 MythMediaDevice::MediaStatusStrings[m_Status]); 530 530 VERBOSE(VB_MEDIA, "Setting status to not mounted?"); 531 if (isMounted( true))531 if (isMounted()) 532 532 setStatus(MEDIASTAT_MOUNTED, OpenedHere); 533 533 else 534 534 setStatus(MEDIASTAT_NOTMOUNTED, OpenedHere); -
mythtv/libs/libmyth/mythhdd.cpp
31 31 */ 32 32 MediaStatus MythHDD::checkMedia(void) 33 33 { 34 if (isMounted( true))34 if (isMounted()) 35 35 { 36 36 // A lazy way to present volume name for the user to eject. 37 37 // Hotplug devices are usually something like /media/VOLUME … … 46 46 { 47 47 // a removable device was just plugged in try to mount it. 48 48 mount(); 49 if (isMounted( true))49 if (isMounted()) 50 50 { 51 51 m_Status = MEDIASTAT_NOTMOUNTED; 52 52 return setStatus(MEDIASTAT_MOUNTED); -
mythtv/libs/libmyth/mythmedia.cpp
22 22 # define O_NONBLOCK 0 23 23 #endif 24 24 25 #define LOC QString("MythMediaDevice:") 26 #define LOC_WARN QString("MythMediaDevice, Warning: ") 27 #define LOC_ERR QString("MythMediaDevice, Error: ") 25 #define LOC QString("MythMediaDevice:") 28 26 29 27 static const QString PATHTO_PMOUNT("/usr/bin/pmount"); 30 28 static const QString PATHTO_PUMOUNT("/usr/bin/pumount"); … … 101 99 102 100 bool MythMediaDevice::performMountCmd(bool DoMount) 103 101 { 104 if (DoMount && isMounted( true))102 if (DoMount && isMounted()) 105 103 { 106 104 VERBOSE(VB_MEDIA, "MythMediaDevice::performMountCmd(true)" 107 105 " - Logic Error? Device already mounted."); … … 133 131 { 134 132 // we cannot tell beforehand what the pmount mount point is 135 133 // so verify the mount status of the device 136 isMounted(true); 134 if (!findMountPath()) 135 { 136 VERBOSE(VB_MEDIA, "performMountCmd() attempted to" 137 " find mounted media, but failed?"); 138 return false; 139 } 137 140 m_Status = MEDIASTAT_MOUNTED; 138 141 onDeviceMounted(); 139 142 VERBOSE(VB_GENERAL, … … 141 144 } 142 145 else 143 146 onDeviceUnmounted(); 147 144 148 return true; 145 149 } 146 150 else 147 {148 151 VERBOSE(VB_GENERAL, QString("Failed to mount %1.") 149 152 .arg(m_DevicePath)); 150 }151 153 } 152 154 else 153 155 { … … 163 165 } 164 166 else 165 167 onDeviceUnmounted(); 168 166 169 return true; 167 170 } 168 171 return false; … … 322 325 /// \brief Tells us if m_DevicePath is a mounted device. 323 326 bool MythMediaDevice::isMounted(bool Verify) 324 327 { 325 if (!Verify) 328 if (Verify) 329 return findMountPath(); 330 else 326 331 return (m_Status == MEDIASTAT_MOUNTED); 332 } 327 333 334 /// \brief Try to find a mount of m_DevicePath in the mounts file. 335 bool MythMediaDevice::findMountPath() 336 { 328 337 if (m_DevicePath.isEmpty()) 329 338 { 330 VERBOSE(VB_MEDIA, LOC + ":isMounted() - logic error, no device path"); 339 VERBOSE(VB_MEDIA, 340 LOC + ":findMountPath() - logic error, no device path"); 331 341 return false; 332 342 } 333 343 … … 398 408 399 409 if (print_verbose_messages & VB_MEDIA) 400 410 { 401 debug = LOC + ": isMounted() - mount of '"411 debug = LOC + ":findMountPath() - mount of '" 402 412 + m_DevicePath + "' not found.\n" 403 413 + " Device name/type | Current mountpoint\n" 404 414 + " -----------------+-------------------\n" … … 427 437 case MEDIASTAT_OPEN: 428 438 case MEDIASTAT_NODISK: 429 439 case MEDIASTAT_NOTMOUNTED: 430 if (isMounted( true))440 if (isMounted()) 431 441 unmount(); 432 442 break; 433 443 case MEDIASTAT_UNKNOWN: -
mythtv/libs/libmyth/mythmediamonitor.cpp
125 125 // Caller can also request mounted drives to be listed (e.g. USB flash) 126 126 127 127 if (QString(typeid(**it).name()).contains("MythCDROM") || 128 (showMounted && (*it)->isMounted( )))128 (showMounted && (*it)->isMounted(false))) 129 129 drives.append(*it); 130 130 } 131 131 … … 228 228 return; 229 229 } 230 230 231 if (device->isMounted( true))231 if (device->isMounted()) 232 232 { 233 233 VERBOSE(VB_MEDIA, QString("Disk %1 is mounted? Unmounting").arg(dev)); 234 234 device->unmount(); 235 235 236 if (device->isMounted( true))236 if (device->isMounted()) 237 237 { 238 238 ShowOkPopup(tr("Failed to unmount %1").arg(dev)); 239 239 return;