Ticket #5679: isMounted.patch

File isMounted.patch, 10.3 KB (added by Nigel, 17 years ago)
  • mythtv/libs/libmyth/mythmedia.h

     
    8686
    8787    MediaType getMediaType() const { return m_MediaType; }
    8888
    89     bool isSuperMount() const { return m_SuperMount; }
     89    bool isSuperMount()      const { return m_SuperMount; }
    9090
    9191    virtual MediaError  testMedia() { return MEDIAERR_UNSUPPORTED; }
    9292    virtual bool openDevice();
     
    9999    virtual MediaError unlock();
    100100    virtual bool performMountCmd( bool DoMount );
    101101
    102     bool mount() {  return performMountCmd(true); }
     102    bool mount()   { return performMountCmd(true); }
    103103    bool unmount() { return performMountCmd(false); }
    104     bool isMounted(bool bVerify = false);
    105104
     105    bool isMounted(bool bVerify = true);
     106    bool findMountPath();
     107
    106108    void RegisterMediaExtensions(uint mediatype,
    107109                                 const QString& extensions);
    108110
  • mythplugins/mythgallery/mythgallery/iconview.cpp

     
    317317    MediaMonitor *mon = MediaMonitor::GetMediaMonitor();
    318318    if (m_currDevice && mon && mon->ValidateAndLock(m_currDevice))
    319319    {
    320         bool mounted = m_currDevice->isMounted(true);
     320        bool mounted = m_currDevice->isMounted();
    321321        if (!mounted)
    322322            mounted = m_currDevice->mount();
    323323
     
    460460    {
    461461        m_currDevice = item->GetMediaDevice();
    462462
    463         if (!m_currDevice->isMounted())
     463        if (!m_currDevice->isMounted(false))
    464464            m_currDevice->mount();
    465465
    466466        item->SetPath(m_currDevice->getMountPath(), true);
  • mythtv/libs/libmyth/mediamonitor-unix.cpp

     
    161161        sysfs.cd(*it);
    162162
    163163        QFile removable(sysfs.absFilePath("removable"));
    164         if (removable.exists())
     164        if (removable.exists() && removable.open(QIODevice::ReadOnly))
    165165        {
    166             removable.open(QIODevice::ReadOnly);
    167166            int c = removable.getch();
    168167            removable.close();
    169168
  • mythtv/libs/libmyth/mythcdrom-freebsd.cpp

     
    5454            if (errno == EBUSY)
    5555            {
    5656                //cout << "errno == EBUSY" << endl;
    57                 return isMounted(true) ? MEDIAERR_OK : MEDIAERR_FAILED;
     57                return isMounted() ? MEDIAERR_OK : MEDIAERR_FAILED;
    5858            }
    5959            else
    6060            {
  • mythtv/libs/libmyth/mythcdrom-linux.cpp

     
    327327            VERBOSE(VB_MEDIA+VB_EXTRA, LOC + ":testMedia - failed to open "
    328328                                           + getDevicePath() + ENO);
    329329            if (errno == EBUSY)
    330                 return isMounted(true) ? MEDIAERR_OK : MEDIAERR_FAILED;
     330                return isMounted() ? MEDIAERR_OK : MEDIAERR_FAILED;
    331331            else
    332332                return MEDIAERR_FAILED;
    333333        }
     
    387387                    return m_Status;
    388388                // If the disc is ok and we already know it's mediatype
    389389                // returns MOUNTED.
    390                 if (isMounted(true))
     390                if (isMounted())
    391391                    return setStatus(MEDIASTAT_MOUNTED, OpenedHere);
    392392                break;
    393393            case CDS_TRAY_OPEN:
     
    448448
    449449                        // the base class's onDeviceMounted will do fine
    450450                        // grained detection of the type of data on this disc
    451                         if (isMounted(true))
     451                        if (isMounted())
    452452                            onDeviceMounted();
    453453                        else
    454454                            if (mount())
     
    456456                            else
    457457                                return setStatus(MEDIASTAT_ERROR, OpenedHere);
    458458
    459                         if (isMounted(true))
     459                        if (isMounted())
    460460                        {
    461461                            // pretend we're NOTMOUNTED so setStatus emits
    462462                            // a signal
     
    488488                            return setStatus(MEDIASTAT_USEABLE, OpenedHere);
    489489                        #else
    490490                            mount();
    491                             if (isMounted(true))
     491                            if (isMounted())
    492492                            {
    493493                                // pretend we're NOTMOUNTED so setStatus
    494494                                // emits a signal
     
    528528                VERBOSE(VB_MEDIA, QString("Current status == ") +
    529529                        MythMediaDevice::MediaStatusStrings[m_Status]);
    530530                VERBOSE(VB_MEDIA, "Setting status to not mounted?");
    531                 if (isMounted(true))
     531                if (isMounted())
    532532                    setStatus(MEDIASTAT_MOUNTED, OpenedHere);
    533533                else
    534534                    setStatus(MEDIASTAT_NOTMOUNTED, OpenedHere);
  • mythtv/libs/libmyth/mythhdd.cpp

     
    3131 */
    3232MediaStatus MythHDD::checkMedia(void)
    3333{
    34     if (isMounted(true))
     34    if (isMounted())
    3535    {
    3636        // A lazy way to present volume name for the user to eject.
    3737        // Hotplug devices are usually something like /media/VOLUME
     
    4646    {
    4747        // a removable device was just plugged in try to mount it.
    4848        mount();
    49         if (isMounted(true))
     49        if (isMounted())
    5050        {
    5151            m_Status = MEDIASTAT_NOTMOUNTED;
    5252            return setStatus(MEDIASTAT_MOUNTED);
  • mythtv/libs/libmyth/mythmedia.cpp

     
    2222#   define O_NONBLOCK 0
    2323#endif
    2424
    25 #define LOC      QString("MythMediaDevice:")
    26 #define LOC_WARN QString("MythMediaDevice, Warning: ")
    27 #define LOC_ERR  QString("MythMediaDevice, Error: ")
     25#define LOC QString("MythMediaDevice:")
    2826
    2927static const QString PATHTO_PMOUNT("/usr/bin/pmount");
    3028static const QString PATHTO_PUMOUNT("/usr/bin/pumount");
     
    10199
    102100bool MythMediaDevice::performMountCmd(bool DoMount)
    103101{
    104     if (DoMount && isMounted(true))
     102    if (DoMount && isMounted())
    105103    {
    106104        VERBOSE(VB_MEDIA, "MythMediaDevice::performMountCmd(true)"
    107105                          " - Logic Error? Device already mounted.");
     
    133131            {
    134132                // we cannot tell beforehand what the pmount mount point is
    135133                // so verify the mount status of the device
    136                 isMounted(true);
     134                if (!findMountPath())
     135                {
     136                    VERBOSE(VB_MEDIA, "performMountCmd() attempted to"
     137                                      + " mount media, but failed?");
     138                    return false;
     139                }
    137140                m_Status = MEDIASTAT_MOUNTED;
    138141                onDeviceMounted();
    139142                VERBOSE(VB_GENERAL,
     
    141144            }
    142145            else
    143146                onDeviceUnmounted();
     147
    144148            return true;
    145149        }
    146150        else
    147         {
    148151            VERBOSE(VB_GENERAL, QString("Failed to mount %1.")
    149152                                       .arg(m_DevicePath));
    150         }
    151153    }
    152154    else
    153155    {
     
    163165        }
    164166        else
    165167            onDeviceUnmounted();
     168
    166169        return true;
    167170    }
    168171    return false;
     
    322325/// \brief Tells us if m_DevicePath is a mounted device.
    323326bool MythMediaDevice::isMounted(bool Verify)
    324327{
    325     if (!Verify)
     328    if (Verify)
     329        return findMountPath();
     330    else
    326331        return (m_Status == MEDIASTAT_MOUNTED);
     332}
    327333
     334/// \brief Try to find a mount of m_DevicePath in the mounts file.
     335bool MythMediaDevice::findMountPath()
     336{
    328337    if (m_DevicePath.isEmpty())
    329338    {
    330         VERBOSE(VB_MEDIA, LOC + ":isMounted() - logic error, no device path");
     339        VERBOSE(VB_MEDIA,
     340                LOC + ":findMountPath() - logic error, no device path");
    331341        return false;
    332342    }
    333343
     
    398408
    399409    if (print_verbose_messages & VB_MEDIA)
    400410    {
    401         debug = LOC + ":isMounted() - mount of '"
     411        debug = LOC + ":findMountPath() - mount of '"
    402412                + m_DevicePath + "' not found.\n"
    403413                + "                 Device name/type | Current mountpoint\n"
    404414                + "                 -----------------+-------------------\n"
     
    427437            case MEDIASTAT_OPEN:
    428438            case MEDIASTAT_NODISK:
    429439            case MEDIASTAT_NOTMOUNTED:
    430                 if (isMounted(true))
     440                if (isMounted())
    431441                    unmount();
    432442                break;
    433443            case MEDIASTAT_UNKNOWN:
  • mythtv/libs/libmyth/mythmediamonitor.cpp

     
    125125        // Caller can also request mounted drives to be listed (e.g. USB flash)
    126126
    127127        if (QString(typeid(**it).name()).contains("MythCDROM") ||
    128                (showMounted && (*it)->isMounted()))
     128               (showMounted && (*it)->isMounted(false)))
    129129            drives.append(*it);
    130130    }
    131131
     
    228228        return;
    229229    }
    230230
    231     if (device->isMounted(true))
     231    if (device->isMounted())
    232232    {
    233233        VERBOSE(VB_MEDIA, QString("Disk %1 is mounted? Unmounting").arg(dev));
    234234        device->unmount();
    235235
    236         if (device->isMounted(true))
     236        if (device->isMounted())
    237237        {
    238238            ShowOkPopup(tr("Failed to unmount %1").arg(dev));
    239239            return;