losetup: rewrite loop setup
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
bcdbdc72cb
commit
c7e0925def
|
@ -114,6 +114,7 @@ enum {
|
|||
LOOPDEV_FL_NOIOCTL = (1 << 6),
|
||||
LOOPDEV_FL_DEVSUBDIR = (1 << 7),
|
||||
LOOPDEV_FL_CONTROL = (1 << 8), /* system with /dev/loop-control */
|
||||
LOOPDEV_FL_SIZELIMIT = (1 << 9)
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -139,6 +140,7 @@ extern void loopcxt_deinit(struct loopdev_cxt *lc);
|
|||
extern void loopcxt_enable_debug(struct loopdev_cxt *lc, int enable);
|
||||
|
||||
extern int loopcxt_set_device(struct loopdev_cxt *lc, const char *device);
|
||||
extern int loopcxt_has_device(struct loopdev_cxt *lc);
|
||||
extern char *loopcxt_strdup_device(struct loopdev_cxt *lc);
|
||||
extern const char *loopcxt_get_device(struct loopdev_cxt *lc);
|
||||
extern struct sysfs_cxt *loopcxt_get_sysfs(struct loopdev_cxt *lc);
|
||||
|
|
|
@ -118,6 +118,11 @@ int loopcxt_set_device(struct loopdev_cxt *lc, const char *device)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int loopcxt_has_device(struct loopdev_cxt *lc)
|
||||
{
|
||||
return lc && *lc->device;
|
||||
}
|
||||
|
||||
/*
|
||||
* @lc: context
|
||||
* @flags: LOOPDEV_FL_* flags
|
||||
|
@ -948,12 +953,15 @@ int loopcxt_set_encryption(struct loopdev_cxt *lc,
|
|||
lc->info.lo_encrypt_key_size = 0;
|
||||
break;
|
||||
default:
|
||||
DBG(lc, loopdev_debug("setting encryption key"));
|
||||
memset(lc->info.lo_encrypt_key, 0, LO_KEY_SIZE);
|
||||
strncpy((char *)lc->info.lo_encrypt_key, password, LO_KEY_SIZE);
|
||||
lc->info.lo_encrypt_key[LO_KEY_SIZE - 1] = '\0';
|
||||
lc->info.lo_encrypt_key_size = LO_KEY_SIZE;
|
||||
break;
|
||||
}
|
||||
|
||||
DBG(lc, loopdev_debug("encryption successfully set"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue