Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fallback lvs comparison to false. #72

Closed
wants to merge 1 commit into from

2 participants

@sidnei

If lvs invocation fails or doesn't return any output, then lv flags comparison to false.

Signed-off-by: Sidnei da Silva sidnei.da.silva@canonical.com

Sidnei da Silva Fallback lvs comparison to false.
If lvs invocation fails or doesn't return any output, then lv flags comparison to false.

Signed-off-by: Sidnei da Silva <sidnei.da.silva@canonical.com>
1b5356c
@hallyn hallyn closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 21, 2013
  1. Fallback lvs comparison to false.

    Sidnei da Silva authored
    If lvs invocation fails or doesn't return any output, then lv flags comparison to false.
    
    Signed-off-by: Sidnei da Silva <sidnei.da.silva@canonical.com>
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 12 deletions.
  1. +7 −12 src/lxc/bdev.c
View
19 src/lxc/bdev.c
@@ -813,7 +813,7 @@ static int lvm_umount(struct bdev *bdev)
static int lvm_compare_lv_attr(const char *path, int pos, const char expected) {
FILE *f;
- int ret, len, start=0;
+ int ret, len, status, start=0;
char *cmd, output[12];
const char *lvscmd = "lvs --unbuffered --noheadings -o lv_attr %s 2>/dev/null";
@@ -833,21 +833,16 @@ static int lvm_compare_lv_attr(const char *path, int pos, const char expected) {
return -1;
}
- if (fgets(output, 12, f) == NULL) {
- process_lock();
- (void) pclose(f);
- process_unlock();
- return -1;
- }
+ ret = fgets(output, 12, f) == NULL;
process_lock();
- ret = pclose(f);
+ status = pclose(f);
process_unlock();
- if (!WIFEXITED(ret)) {
- SYSERROR("error executing lvs");
- return -1;
- }
+ if (ret || WEXITSTATUS(status))
+ // Assume either vg or lvs do not exist, default
+ // comparison to false.
+ return 0;
len = strlen(output);
while(start < len && output[start] == ' ') start++;
Something went wrong with that request. Please try again.