Skip to content

Conversation

@lowBudgetHypothermia
Copy link
Collaborator

This was done to allow the copytool to archive to the same fs (TSM) from different lustre instances.

This was done to allow the copytool to archive to the same fs (TSM)
from different lustre instances.
{.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?

Comment on lines 399 to 400
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. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants