From 99caeb8e345e01ce8c243a4284f5a2353fc2009e Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Mon, 7 Jul 2014 11:33:29 -0400
Subject: [PATCH] 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.
---
.../kernel/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 d6f1916..4c97144 100644
a
|
b
|
public:
|
105 | 105 | size_t BufferSize() const { return 32 * kFrameSize; } |
106 | 106 | // TODO: for now |
107 | 107 | |
108 | | void DisableCDDBLookUps(); |
| 108 | void SetCDDBLookupsEnabled(bool doLookup); |
109 | 109 | |
110 | 110 | static void DetermineName(uint32 cddbId, int device, char* name, |
111 | 111 | size_t length); |
… |
… |
private:
|
129 | 129 | ino_t fNextID; |
130 | 130 | char* fName; |
131 | 131 | off_t fNumBlocks; |
| 132 | bool fIgnoreCDDBLookupChanges; |
132 | 133 | |
133 | 134 | // root directory contents - we don't support other directories |
134 | 135 | Inode* fFirstEntry; |
… |
… |
Volume::Volume(fs_volume* fsVolume)
|
569 | 570 | fNextID(1), |
570 | 571 | fName(NULL), |
571 | 572 | fNumBlocks(0), |
| 573 | fIgnoreCDDBLookupChanges(false), |
572 | 574 | fFirstEntry(NULL) |
573 | 575 | { |
574 | 576 | } |
… |
… |
Volume::Mount(const char* device)
|
730 | 732 | fRootNode->AddAttribute(kCddbIdAttribute, B_UINT32_TYPE, fDiscID); |
731 | 733 | |
732 | 734 | // Add CD:do_lookup attribute. |
733 | | fRootNode->AddAttribute(kDoLookupAttribute, B_BOOL_TYPE, true, |
734 | | (const uint8*)&doLookup, sizeof(bool)); |
| 735 | SetCDDBLookupsEnabled(true); |
735 | 736 | |
736 | 737 | // Add CD:toc attribute. |
737 | 738 | fRootNode->AddAttribute(kTocAttribute, B_RAW_TYPE, true, |
… |
… |
Volume::Find(const char* name)
|
805 | 806 | |
806 | 807 | |
807 | 808 | void |
808 | | Volume::DisableCDDBLookUps() |
| 809 | Volume::SetCDDBLookupsEnabled(bool doLookup) |
809 | 810 | { |
810 | | bool doLookup = false; |
811 | | RootNode().AddAttribute(kDoLookupAttribute, B_BOOL_TYPE, true, |
812 | | (const uint8*)&doLookup, sizeof(bool)); |
| 811 | if (!fIgnoreCDDBLookupChanges) { |
| 812 | fRootNode->AddAttribute(kDoLookupAttribute, B_BOOL_TYPE, true, |
| 813 | (const uint8*)&doLookup, sizeof(bool)); |
| 814 | } |
813 | 815 | } |
814 | 816 | |
815 | 817 | |
… |
… |
Volume::_StoreAttributes()
|
958 | 960 | void |
959 | 961 | Volume::_RestoreSharedAttributes() |
960 | 962 | { |
961 | | // device attributes overwrite shared attributes |
| 963 | // Don't affect CDDB lookup status while changing shared attributes |
| 964 | fIgnoreCDDBLookupChanges = true; |
962 | 965 | |
| 966 | // device attributes overwrite shared attributes |
963 | 967 | int fd = _OpenAttributes(O_RDONLY, kSharedAttributes); |
964 | 968 | if (fd >= 0) { |
965 | 969 | read_attributes(fd, fRootNode); |
… |
… |
Volume::_RestoreSharedAttributes()
|
971 | 975 | read_attributes(fd, fRootNode); |
972 | 976 | close(fd); |
973 | 977 | } |
| 978 | |
| 979 | fIgnoreCDDBLookupChanges = false; |
974 | 980 | } |
975 | 981 | |
976 | 982 | |
… |
… |
cdda_write_fs_stat(fs_volume* _volume, const struct fs_info* info, uint32 mask)
|
1540 | 1546 | |
1541 | 1547 | if ((mask & FS_WRITE_FSINFO_NAME) != 0) { |
1542 | 1548 | status = volume->SetName(info->volume_name); |
1543 | | if (status == B_OK) { |
1544 | | // The volume had its name changed from outside the filesystem |
1545 | | // add-on. Disable CDDB lookups. Note this will usually mean that |
1546 | | // the user manually renamed the volume or that cddblinkd (or other |
1547 | | // program) did this so we do not want to do it again. |
1548 | | volume->DisableCDDBLookUps(); |
1549 | | } |
1550 | 1549 | } |
1551 | 1550 | |
1552 | 1551 | return status; |
… |
… |
cdda_rename(fs_volume* _volume, fs_vnode* _oldDir, const char* oldName,
|
1811 | 1810 | // add-on. Disable CDDB lookups. Note this will usually mean that the |
1812 | 1811 | // user manually renamed a track or that cddblinkd (or other program) |
1813 | 1812 | // did this so we do not want to do it again. |
1814 | | volume->DisableCDDBLookUps(); |
| 1813 | volume->SetCDDBLookupsEnabled(false); |
1815 | 1814 | |
1816 | 1815 | notify_entry_moved(volume->ID(), volume->RootNode().ID(), oldName, |
1817 | 1816 | volume->RootNode().ID(), newName, inode->ID()); |