Skip to content

Commit

Permalink
Treat extended attribute ltfs.mediaPool.name like a virtual extended …
Browse files Browse the repository at this point in the history
…attribute. Allow both reading and writing, and store in MAM data. (#388)
  • Loading branch information
richard42 authored Jun 29, 2023
1 parent 2897a5a commit 66f0b28
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/libltfs/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ static inline bool _xattr_is_worm_ea(const char *name)
static inline bool _xattr_is_stored_vea(const char *name)
{
if (strcmp(name, "ltfs.spannedFileOffset") &&
strcmp(name, "ltfs.mediaPool.name") &&
strcasestr(name, "ltfs.permissions.") != name &&
strcasestr(name, "ltfs.hash.") != name)
{
Expand Down Expand Up @@ -480,6 +479,7 @@ static bool _xattr_is_virtual(struct dentry *d, const char *name, struct ltfs_vo
|| ! strcmp(name, "ltfs.mediaIndexPartitionAvailableSpace")
|| ! strcmp(name, "ltfs.mediaEncrypted")
|| ! strcmp(name, "ltfs.mediaPool.additionalInfo")
|| ! strcmp(name, "ltfs.mediaPool.name")
|| ! strcmp(name, "ltfs.driveEncryptionState")
|| ! strcmp(name, "ltfs.driveEncryptionMethod")
/* Vendor specific EAs */
Expand Down Expand Up @@ -787,9 +787,18 @@ static int _xattr_get_virtual(struct dentry *d, char *buf, size_t buf_size, cons
ret = _xattr_get_cartridge_capacity(&cap, &cap.remaining_ip, &val, name, vol);
} else if (! strcmp(name, "ltfs.mediaEncrypted")) {
ret = xattr_get_string(tape_get_media_encrypted(vol->device), &val, name);
} else if (! strcmp(name, "ltfs.mediaPool.name")) {
char *tmp=NULL;
ret = tape_get_media_pool_info(vol, &val, &tmp);
if (tmp)
free(tmp);
if (ret < 0 || !val)
ret = -LTFS_NO_XATTR;
} else if (! strcmp(name, "ltfs.mediaPool.additionalInfo")) {
char *tmp=NULL;
ret = tape_get_media_pool_info(vol, &tmp, &val);
if (tmp)
free(tmp);
if (ret < 0 || !val)
ret = -LTFS_NO_XATTR;
} else if (! strcmp(name, "ltfs.driveEncryptionState")) {
Expand Down Expand Up @@ -1225,6 +1234,8 @@ static int _xattr_set_virtual(struct dentry *d, const char *name, const char *va
free(v);
} else if (! strcmp(name, "ltfs.mediaPool.additionalInfo")) {
ret = tape_set_media_pool_info(vol, value, size, false);
} else if (! strcmp(name, "ltfs.mediaPool.name")) {
ret = tape_set_media_pool_info(vol, value, size, true);
} else
ret = -LTFS_NO_XATTR;

Expand Down Expand Up @@ -1443,15 +1454,6 @@ int xattr_set(struct dentry *d, const char *name, const char *value, size_t size
}
}

if (!strcmp(name, "ltfs.mediaPool.name")) {
ret = tape_set_media_pool_info(vol, value, size, true);
if (ret < 0) {
releasewrite_mrsw(&d->meta_lock);
goto out_unlock;
}
write_idx = true;
}

/* Set extended attribute */
ret = xattr_do_set(d, name, value, size, xattr);
if (ret < 0) {
Expand Down

0 comments on commit 66f0b28

Please sign in to comment.