[haiku-commits] haiku: hrev47477 - src/add-ons/kernel/file_systems/cdda

  • From: jerome.duval@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 9 Jul 2014 20:55:34 +0200 (CEST)

hrev47477 adds 2 changesets to branch 'master'
old head: 0b38b0a1362ee252627818dbbd7e282913e7b56a
new head: 8566c721c784837934429855b3179d45ae538ed7
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=8566c72+%5E0b38b0a

----------------------------------------------------------------------------

e8f82cd: file_systems/cdda: avoid leaking the attributes fd.
  
  * see bug #9528.

                                   [ Jérôme Duval <jerome.duval@xxxxxxxxx> ]

8566c72: file_systems/cdda: Various fixes.
  
   * When restoring shared attributes, don't affect CDDB:lookup status
   * Volume renames should not affect CDDB:lookup status, only file renames 
should
  
  This fixes some of the "cddb_daemon not updating CD info" problems.
  
  Signed-off-by: Jérôme Duval <jerome.duval@xxxxxxxxx>

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

1 file changed, 18 insertions(+), 17 deletions(-)
.../file_systems/cdda/kernel_interface.cpp       | 35 ++++++++++----------

############################################################################

Commit:      e8f82cdb6e50237defefe705c1a75e8cde33e0e7
URL:         http://cgit.haiku-os.org/haiku/commit/?id=e8f82cd
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Wed Jul  9 18:42:55 2014 UTC

Ticket:      https://dev.haiku-os.org/ticket/9528

file_systems/cdda: avoid leaking the attributes fd.

* see bug #9528.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp 
b/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp
index d6f1916..125429c 100644
--- a/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp
+++ b/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp
@@ -738,8 +738,10 @@ Volume::Mount(const char* device)
                (const uint8*)toc, B_BENDIAN_TO_HOST_INT16(toc->data_length) + 
2);
 
        _RestoreSharedAttributes();
-       if (fd >= 0)
+       if (fd >= 0) {
                _RestoreAttributes(fd);
+               close(fd);
+       }
 
        // determine volume title
        DetermineName(fDiscID, fDevice, title, sizeof(title));

############################################################################

Revision:    hrev47477
Commit:      8566c721c784837934429855b3179d45ae538ed7
URL:         http://cgit.haiku-os.org/haiku/commit/?id=8566c72
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Mon Jul  7 15:33:29 2014 UTC
Committer:   Jérôme Duval <jerome.duval@xxxxxxxxx>
Commit-Date: Wed Jul  9 18:54:38 2014 UTC

file_systems/cdda: Various fixes.

 * When restoring shared attributes, don't affect CDDB:lookup status
 * Volume renames should not affect CDDB:lookup status, only file renames should

This fixes some of the "cddb_daemon not updating CD info" problems.

Signed-off-by: Jérôme Duval <jerome.duval@xxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp 
b/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp
index 125429c..7d748ae 100644
--- a/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp
+++ b/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp
@@ -105,7 +105,7 @@ public:
                        size_t                  BufferSize() const { return 32 
* kFrameSize; }
                                                                // TODO: for now
 
-                       void                    DisableCDDBLookUps();
+                       void                    SetCDDBLookupsEnabled(bool 
doLookup);
 
        static  void                    DetermineName(uint32 cddbId, int 
device, char* name,
                                                                size_t length);
@@ -129,6 +129,7 @@ private:
                        ino_t                   fNextID;
                        char*                   fName;
                        off_t                   fNumBlocks;
+                       bool                    fIgnoreCDDBLookupChanges;
 
                        // root directory contents - we don't support other 
directories
                        Inode*                  fFirstEntry;
@@ -569,6 +570,7 @@ Volume::Volume(fs_volume* fsVolume)
        fNextID(1),
        fName(NULL),
        fNumBlocks(0),
+       fIgnoreCDDBLookupChanges(false),
        fFirstEntry(NULL)
 {
 }
@@ -730,8 +732,7 @@ Volume::Mount(const char* device)
        fRootNode->AddAttribute(kCddbIdAttribute, B_UINT32_TYPE, fDiscID);
 
        // Add CD:do_lookup attribute.
-       fRootNode->AddAttribute(kDoLookupAttribute, B_BOOL_TYPE, true,
-               (const uint8*)&doLookup, sizeof(bool));
+       SetCDDBLookupsEnabled(true);
 
        // Add CD:toc attribute.
        fRootNode->AddAttribute(kTocAttribute, B_RAW_TYPE, true,
@@ -807,11 +808,12 @@ Volume::Find(const char* name)
 
 
 void
-Volume::DisableCDDBLookUps()
+Volume::SetCDDBLookupsEnabled(bool doLookup)
 {
-       bool doLookup = false;
-       RootNode().AddAttribute(kDoLookupAttribute, B_BOOL_TYPE, true,
-               (const uint8*)&doLookup, sizeof(bool));
+       if (!fIgnoreCDDBLookupChanges) {
+               fRootNode->AddAttribute(kDoLookupAttribute, B_BOOL_TYPE, true,
+                       (const uint8*)&doLookup, sizeof(bool));
+       }
 }
 
 
@@ -960,8 +962,10 @@ Volume::_StoreAttributes()
 void
 Volume::_RestoreSharedAttributes()
 {
-       // device attributes overwrite shared attributes
+       // Don't affect CDDB lookup status while changing shared attributes
+       fIgnoreCDDBLookupChanges = true;
 
+       // device attributes overwrite shared attributes
        int fd = _OpenAttributes(O_RDONLY, kSharedAttributes);
        if (fd >= 0) {
                read_attributes(fd, fRootNode);
@@ -973,6 +977,8 @@ Volume::_RestoreSharedAttributes()
                read_attributes(fd, fRootNode);
                close(fd);
        }
+
+       fIgnoreCDDBLookupChanges = false;
 }
 
 
@@ -1542,13 +1548,6 @@ cdda_write_fs_stat(fs_volume* _volume, const struct 
fs_info* info, uint32 mask)
 
        if ((mask & FS_WRITE_FSINFO_NAME) != 0) {
                status = volume->SetName(info->volume_name);
-               if (status == B_OK) {
-                       // The volume had its name changed from outside the 
filesystem
-                       // add-on. Disable CDDB lookups. Note this will usually 
mean that
-                       // the user manually renamed the volume or that 
cddblinkd (or other
-                       // program) did this so we do not want to do it again.
-                       volume->DisableCDDBLookUps();
-               }
        }
 
        return status;
@@ -1813,7 +1812,7 @@ cdda_rename(fs_volume* _volume, fs_vnode* _oldDir, const 
char* oldName,
                // add-on. Disable CDDB lookups. Note this will usually mean 
that the
                // user manually renamed a track or that cddblinkd (or other 
program)
                // did this so we do not want to do it again.
-               volume->DisableCDDBLookUps();
+               volume->SetCDDBLookupsEnabled(false);
 
                notify_entry_moved(volume->ID(), volume->RootNode().ID(), 
oldName,
                        volume->RootNode().ID(), newName, inode->ID());


Other related posts:

  • » [haiku-commits] haiku: hrev47477 - src/add-ons/kernel/file_systems/cdda - jerome . duval