- Created a static version of Attribute::IsProtectedNamespace() that takes an
attribute name as input. Handy for whyen we do not have an Attribute object around. - Made the non-static version fall back to the static version. - Also check for the protected namespace when creating attributes. For consistency, we should also not be able to create attributes in this namespace. - Added some new style violations. ;) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27082 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -148,6 +148,7 @@ class Attribute : public DoublyLinkedListLinkImpl<Attribute> {
|
|||||||
uint8* Data() const { return fData; }
|
uint8* Data() const { return fData; }
|
||||||
|
|
||||||
bool IsProtectedNamespace();
|
bool IsProtectedNamespace();
|
||||||
|
static bool IsProtectedNamespace(const char* name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char* fName;
|
char* fName;
|
||||||
@@ -1052,8 +1053,17 @@ Attribute::IsProtectedNamespace()
|
|||||||
{
|
{
|
||||||
// Check if the attribute is in the restricted namespace. Attributes in
|
// Check if the attribute is in the restricted namespace. Attributes in
|
||||||
// this namespace should not be edited by the user as they are handled
|
// this namespace should not be edited by the user as they are handled
|
||||||
// internally by the add-on.
|
// internally by the add-on. Calls the static version.
|
||||||
return strncmp(kProtectedAttrNamespace, fName,
|
return IsProtectedNamespace(fName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
Attribute::IsProtectedNamespace(const char* name)
|
||||||
|
{
|
||||||
|
// Convenience static version of the above method. Usually called when we
|
||||||
|
// don't have a constructed Attribute object handy.
|
||||||
|
return strncmp(kProtectedAttrNamespace, name,
|
||||||
strlen(kProtectedAttrNamespace)) == 0;
|
strlen(kProtectedAttrNamespace)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1932,10 +1942,14 @@ cdda_create_attr(fs_volume* _volume, fs_vnode* _node, const char* name,
|
|||||||
|
|
||||||
Attribute* attribute = inode->FindAttribute(name);
|
Attribute* attribute = inode->FindAttribute(name);
|
||||||
if (attribute == NULL) {
|
if (attribute == NULL) {
|
||||||
|
if (Attribute::IsProtectedNamespace(name))
|
||||||
|
return B_NOT_ALLOWED;
|
||||||
status_t status = inode->AddAttribute(name, type, true, NULL, 0);
|
status_t status = inode->AddAttribute(name, type, true, NULL, 0);
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
} else if ((openMode & O_EXCL) == 0) {
|
} else if ((openMode & O_EXCL) == 0) {
|
||||||
|
if (attribute->IsProtectedNamespace())
|
||||||
|
return B_NOT_ALLOWED;
|
||||||
attribute->SetType(type);
|
attribute->SetType(type);
|
||||||
if ((openMode & O_TRUNC) != 0)
|
if ((openMode & O_TRUNC) != 0)
|
||||||
attribute->Truncate();
|
attribute->Truncate();
|
||||||
|
|||||||
Reference in New Issue
Block a user