Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
ltsm (0.9.3) unstable; urgency=low

* Added option to set fsname manually

-- Samuel Hasert <[email protected]> Tue, 06 Jan 2026 10:26:20 +0200

ltsm (0.9.2) unstable; urgency=low

* Increased buffersize to 16 MiB
Expand Down
3 changes: 3 additions & 0 deletions rpm/ltsm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ rm -rf %{buildroot}

%changelog

* Tue Jan 06 2026 Samuel Hasert <[email protected]> 0.9.3
- Added option to set fsname manually

* Mon Sep 15 2025 Samuel Hasert <[email protected]> 0.9.2
- Increased buffersize to 16 MiB

Expand Down
14 changes: 12 additions & 2 deletions src/lhsmtool_tsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ static void usage(const char *cmd_name, const int rc)
"\t\t""hostname of tsm server\n"
"\t-c, --conf <file>\n"
"\t\t""option conf file\n"
"\t-f, --fsname\n"
"\t\t""set fsname manually\n"
"\t-v, --verbose {error, warn, message, info, debug}"
" [default: %s]\n"
"\t\t""produce more verbose output\n"
Expand Down Expand Up @@ -297,6 +299,7 @@ static int ct_parseopts(int argc, char *argv[])
{.name = "owner", .has_arg = required_argument, .flag = NULL, .val = 'o'},
{.name = "servername", .has_arg = required_argument, .flag = NULL, .val = 's'},
{.name = "conf", .has_arg = required_argument, .flag = NULL, .val = 'c'},
{.name = "fsname", .has_arg = no_argument, .flag = NULL, .val = 'f'},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no_argument?

Why not required_argument (like with --conf)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the default should be that if no flag is given it defaults to assigning it to whatever mount is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

man getopt_long:

has_arg
       is:  no_argument (or 0) if the option does not take an argument;
       required_argument (or 1) if the option requires an argument;  or
       optional_argument  (or  2) if the option takes an optional argu‐
       ment.

Reading that, I am surprised, that it works at all…

There are two questions:

  1. Is the option (including argument to the option) optional or required?
  2. IF one gives the option, is the argument optional, required (or ignored)?

I guess, you want (1) optional (2) required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think optional_argument means that you can give --fsname without any arguments. That does not feel right to me?

{.name = "verbose", .has_arg = required_argument, .flag = NULL, .val = 'v'},
{.name = "dry-run", .has_arg = no_argument, .flag = &opt.o_dry_run, .val = 1},
{.name = "restore-stripe", .has_arg = no_argument, .flag = &opt.o_restore_stripe, .val = 1},
Expand All @@ -308,7 +311,7 @@ static int ct_parseopts(int argc, char *argv[])
int c, rc;
optind = 0;

while ((c = getopt_long(argc, argv, "a:t:n:p:o:s:c:v:h",
while ((c = getopt_long(argc, argv, "a:t:n:p:o:s:c:f:v:h",
long_opts, NULL)) != -1) {
switch (c) {
case 'a': {
Expand Down Expand Up @@ -345,6 +348,11 @@ static int ct_parseopts(int argc, char *argv[])
read_conf(optarg);
break;
}
case 'f': {
strncpy(opt.o_fsname, optarg,
DSM_MAX_FSNAME_LENGTH);
break;
}
case 'v': {
if (OPTNCMP("error", optarg))
opt.o_verbose = API_MSG_ERROR;
Expand Down Expand Up @@ -388,7 +396,9 @@ static int ct_parseopts(int argc, char *argv[])
opt.o_mnt_fd = -1;

/* Filespace name is set to Lustre mount point. */
strncpy(opt.o_fsname, opt.o_mnt, DSM_MAX_FSNAME_LENGTH);
if (!opt.o_fsname[0])
strncpy(opt.o_fsname, opt.o_mnt, DSM_MAX_FSNAME_LENGTH);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider using braces, even for single line commands:

	if (!opt.o_fsname[0]) {
        strncpy(opt.o_fsname, opt.o_mnt, DSM_MAX_FSNAME_LENGTH);
    }

Copy link
Collaborator Author

@lowBudgetHypothermia lowBudgetHypothermia Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The braces were left out to stay somewhat congruent with another condition check 2 lines below it. Do you want me to change them both?

if (len_fsname > 2 && opt.o_fsname[len_fsname - 1] == '/')
		opt.o_fsname[len_fsname - 1] = '\0';

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just give new code braces. :-)


const size_t len_fsname = strlen(opt.o_fsname);
if (len_fsname > 2 && opt.o_fsname[len_fsname - 1] == '/')
opt.o_fsname[len_fsname - 1] = '\0';
Expand Down