Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils: Copying source filename to avoid missing info [v2]. #3134

Merged
merged 1 commit into from Sep 6, 2019

Conversation

@jcfaracco
Copy link
Contributor

commented Sep 5, 2019

Some applications use information from LOOP_GET_STATUS64. The
file associated with loop device is pointed inside structure field
lo_file_name. The current code is setting up a loop device without
this information. A legacy example of code checking this in cryptsetup:

static char *_ioctl_backing_file(const char *loop)
{
    struct loop_info64 lo64 = {0};
    int loop_fd;

    loop_fd = open(loop, O_RDONLY);
    if (loop_fd < 0)
        return NULL;

    if (ioctl(loop_fd, LOOP_GET_STATUS64, &lo64) < 0) {
        close(loop_fd);
        return NULL;
    }

    lo64.lo_file_name[LO_NAME_SIZE-2] = '*';
    lo64.lo_file_name[LO_NAME_SIZE-1] = 0;

    close(loop_fd);
    return strdup((char*)lo64.lo_file_name);
}

It will return an empty string because lo_file_name was not set.

v1: missing string casting for lo_file_name.

Signed-off-by: Julio Faracco jcfaracco@gmail.com

utils: Copying source filename to avoid missing info.
Some applications use information from LOOP_GET_STATUS64. The file
associated with loop device is pointed inside structure field
`lo_file_name`. The current code is setting up a loop device without
this information. A legacy example of code checking this is cryptsetup:

    static char *_ioctl_backing_file(const char *loop)
    {
        struct loop_info64 lo64 = {0};
        int loop_fd;

        loop_fd = open(loop, O_RDONLY);
        if (loop_fd < 0)
            return NULL;

        if (ioctl(loop_fd, LOOP_GET_STATUS64, &lo64) < 0) {
            close(loop_fd);
            return NULL;
        }

        lo64.lo_file_name[LO_NAME_SIZE-2] = '*';
        lo64.lo_file_name[LO_NAME_SIZE-1] = 0;

        close(loop_fd);
        return strdup((char*)lo64.lo_file_name);
    }

It will return an empty string because lo_file_name was not set.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
@lxc-jenkins

This comment has been minimized.

Copy link

commented Sep 5, 2019

This pull request didn't trigger Jenkins as its author isn't in the whitelist.

An organization member must perform one of the following:

  • To have this branch tested by Jenkins, use the "ok to test" command.
  • To have a one time test done, use the "test this please" command.

Those commands are simple Github comments of the format: "jenkins: COMMAND"

@brauner brauner merged commit d62ac98 into lxc:master Sep 6, 2019

3 checks passed

Branch target Branch target is correct
Details
DCO All commits signed-off
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@brauner

This comment has been minimized.

Copy link
Member

commented Sep 6, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.