From d926ff99ee87ee8fe801f23c29052f8320942112 Mon Sep 17 00:00:00 2001 From: shufps Date: Fri, 18 Sep 2026 07:54:11 +0200 Subject: [PATCH 1/2] create index at mount option --- messages/bin_ltfs/root.txt | 1 + src/libltfs/ltfs.h | 1 + src/ltfs_fuse.h | 1 + src/main.c | 12 ++++++++++++ 4 files changed, 15 insertions(+) diff --git a/messages/bin_ltfs/root.txt b/messages/bin_ltfs/root.txt index 3a9cd000..7cba61ac 100644 --- a/messages/bin_ltfs/root.txt +++ b/messages/bin_ltfs/root.txt @@ -244,5 +244,6 @@ root:table { // Reserved 14466I 14467I:string { " -o syslogtrace Enable diagnostic output to stderr and syslog(same as verbose=303)" } // Reserved 14468I + 14469I:string { " -o capture_index_at_mount Capture latest index to work directory at mount" } } } diff --git a/src/libltfs/ltfs.h b/src/libltfs/ltfs.h index 5a792f55..53d4cd4f 100644 --- a/src/libltfs/ltfs.h +++ b/src/libltfs/ltfs.h @@ -561,6 +561,7 @@ typedef enum { #define SYNC_EA "Sync by EA" #define SYNC_CLOSE "Sync on close" #define SYNC_DNO_SPACE "Dcache no space" +#define SYNC_MOUNT "Mount" #define SYNC_UNMOUNT "Unmount" #define SYNC_UNMOUNT_NOMEM "Unmount - no memory" #define SYNC_MOVE "Unmount - %" PRIu64 diff --git a/src/ltfs_fuse.h b/src/ltfs_fuse.h index 3cf79f17..cae0cffa 100644 --- a/src/ltfs_fuse.h +++ b/src/ltfs_fuse.h @@ -128,6 +128,7 @@ struct ltfs_fuse_data { int release_device; /**< Release device? */ int allow_other; /**< Allow all users to access the volume? */ int capture_index; /**< Capture index information to work directory at unmount */ + int capture_index_at_mount; /**< Capture index information to work directory at mount */ char *symlink_str; /**< Symbolic Link type fetched by option (live or posix)*/ char *str_append_only_mode; /**< option sting of scsi_append_only_mode */ int append_only_mode; /**< Use append-only mode */ diff --git a/src/main.c b/src/main.c index 05696035..b0ee56cb 100644 --- a/src/main.c +++ b/src/main.c @@ -134,6 +134,7 @@ static struct fuse_opt ltfs_options[] = { LTFS_OPT("allow_other", allow_other, 1), LTFS_OPT("noallow_other", allow_other, 0), LTFS_OPT("capture_index", capture_index, 1), + LTFS_OPT("capture_index_at_mount", capture_index_at_mount, 1), LTFS_OPT("symlink_type=%s", symlink_str, 0), LTFS_OPT("scsi_append_only_mode=%s", str_append_only_mode, 0), LTFS_OPT_KEY("-a", KEY_ADVANCED_HELP), @@ -173,6 +174,7 @@ void single_drive_advanced_usage(const char *default_driver, struct ltfs_fuse_da ltfsresult(14437I); /* -o rollback_mount */ ltfsresult(14448I); /* -o release_device */ ltfsresult(14456I); /* -o capture_index */ + ltfsresult(14469I); /* -o capture_index_at_mount */ ltfsresult(14463I); /* -o scsi_append_only_mode= */ ltfsresult(14406I); /* -a */ /* TODO: future use for WORM */ @@ -1093,6 +1095,16 @@ int single_drive_main(struct fuse_args *args, struct ltfs_fuse_data *priv) return 1; } + /* + * Capture the index to the work directory right after mount, if requested. + * The index is already in memory at this point, so this costs no tape access. + * Failing to write it must not prevent the mount, so the return value is + * ignored here; ltfs_save_index_to_disk() logs its own errors. + */ + if (priv->capture_index_at_mount) { + ltfs_save_index_to_disk(priv->work_directory, SYNC_MOUNT, false, priv->data); + } + /* Set up index criteria */ if (priv->index_rules) { ret = pathname_format(priv->index_rules, &index_rules_utf8, false, false); From c616ecb88370e23c2ff8ddad82a052a59bd0fbb7 Mon Sep 17 00:00:00 2001 From: shufps Date: Fri, 18 Sep 2026 08:29:58 +0200 Subject: [PATCH 2/2] removed previous test, added `ltfs.captureIndex` --- messages/bin_ltfs/root.txt | 1 - src/libltfs/ltfs.h | 2 +- src/libltfs/xattr.c | 4 ++++ src/ltfs_fuse.h | 1 - src/main.c | 12 ------------ 5 files changed, 5 insertions(+), 15 deletions(-) diff --git a/messages/bin_ltfs/root.txt b/messages/bin_ltfs/root.txt index 7cba61ac..3a9cd000 100644 --- a/messages/bin_ltfs/root.txt +++ b/messages/bin_ltfs/root.txt @@ -244,6 +244,5 @@ root:table { // Reserved 14466I 14467I:string { " -o syslogtrace Enable diagnostic output to stderr and syslog(same as verbose=303)" } // Reserved 14468I - 14469I:string { " -o capture_index_at_mount Capture latest index to work directory at mount" } } } diff --git a/src/libltfs/ltfs.h b/src/libltfs/ltfs.h index 53d4cd4f..bf0342b0 100644 --- a/src/libltfs/ltfs.h +++ b/src/libltfs/ltfs.h @@ -561,7 +561,7 @@ typedef enum { #define SYNC_EA "Sync by EA" #define SYNC_CLOSE "Sync on close" #define SYNC_DNO_SPACE "Dcache no space" -#define SYNC_MOUNT "Mount" +#define SYNC_CAPTURE_EA "Capture by EA" #define SYNC_UNMOUNT "Unmount" #define SYNC_UNMOUNT_NOMEM "Unmount - no memory" #define SYNC_MOVE "Unmount - %" PRIu64 diff --git a/src/libltfs/xattr.c b/src/libltfs/xattr.c index e44a3c8c..da87c85f 100644 --- a/src/libltfs/xattr.c +++ b/src/libltfs/xattr.c @@ -446,6 +446,7 @@ static bool _xattr_is_virtual(struct dentry *d, const char *name, struct ltfs_vo || ! strcmp(name, "ltfs.indexVersion") || ! strcmp(name, "ltfs.labelVersion") || ! strcmp(name, "ltfs.sync") + || ! strcmp(name, "ltfs.captureIndex") || ! strcmp(name, "ltfs.indexGeneration") || ! strcmp(name, "ltfs.indexTime") || ! strcmp(name, "ltfs.policyExists") @@ -905,6 +906,9 @@ static int _xattr_set_virtual(struct dentry *d, const char *name, const char *va if (! strcmp(name, "ltfs.sync") && d == vol->index->root) ret = ltfs_sync_index(SYNC_EA, false, vol); + else if (! strcmp(name, "ltfs.captureIndex") && d == vol->index->root) + /* Write the current in-memory index to the work directory. No tape access. */ + ret = ltfs_save_index_to_disk(vol->work_directory, SYNC_CAPTURE_EA, false, vol); else if (! strcmp(name, "ltfs.commitMessage") && d == vol->index->root) { char *value_null_terminated, *new_value; diff --git a/src/ltfs_fuse.h b/src/ltfs_fuse.h index cae0cffa..3cf79f17 100644 --- a/src/ltfs_fuse.h +++ b/src/ltfs_fuse.h @@ -128,7 +128,6 @@ struct ltfs_fuse_data { int release_device; /**< Release device? */ int allow_other; /**< Allow all users to access the volume? */ int capture_index; /**< Capture index information to work directory at unmount */ - int capture_index_at_mount; /**< Capture index information to work directory at mount */ char *symlink_str; /**< Symbolic Link type fetched by option (live or posix)*/ char *str_append_only_mode; /**< option sting of scsi_append_only_mode */ int append_only_mode; /**< Use append-only mode */ diff --git a/src/main.c b/src/main.c index b0ee56cb..05696035 100644 --- a/src/main.c +++ b/src/main.c @@ -134,7 +134,6 @@ static struct fuse_opt ltfs_options[] = { LTFS_OPT("allow_other", allow_other, 1), LTFS_OPT("noallow_other", allow_other, 0), LTFS_OPT("capture_index", capture_index, 1), - LTFS_OPT("capture_index_at_mount", capture_index_at_mount, 1), LTFS_OPT("symlink_type=%s", symlink_str, 0), LTFS_OPT("scsi_append_only_mode=%s", str_append_only_mode, 0), LTFS_OPT_KEY("-a", KEY_ADVANCED_HELP), @@ -174,7 +173,6 @@ void single_drive_advanced_usage(const char *default_driver, struct ltfs_fuse_da ltfsresult(14437I); /* -o rollback_mount */ ltfsresult(14448I); /* -o release_device */ ltfsresult(14456I); /* -o capture_index */ - ltfsresult(14469I); /* -o capture_index_at_mount */ ltfsresult(14463I); /* -o scsi_append_only_mode= */ ltfsresult(14406I); /* -a */ /* TODO: future use for WORM */ @@ -1095,16 +1093,6 @@ int single_drive_main(struct fuse_args *args, struct ltfs_fuse_data *priv) return 1; } - /* - * Capture the index to the work directory right after mount, if requested. - * The index is already in memory at this point, so this costs no tape access. - * Failing to write it must not prevent the mount, so the return value is - * ignored here; ltfs_save_index_to_disk() logs its own errors. - */ - if (priv->capture_index_at_mount) { - ltfs_save_index_to_disk(priv->work_directory, SYNC_MOUNT, false, priv->data); - } - /* Set up index criteria */ if (priv->index_rules) { ret = pathname_format(priv->index_rules, &index_rules_utf8, false, false);