From 8566c721c784837934429855b3179d45ae538ed7 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Mon, 7 Jul 2014 11:33:29 -0400 Subject: [PATCH] file_systems/cdda: Various fixes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- .../file_systems/cdda/kernel_interface.cpp | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) 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 125429c558..7d748ae364 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());