diff options
author | Milan Broz <gmazyland@gmail.com> | 2010-10-29 13:54:14 +0000 |
---|---|---|
committer | Milan Broz <gmazyland@gmail.com> | 2010-10-29 13:54:14 +0000 |
commit | a38cb2375ffc6d9f0a2e92f6fa266b9e0db6aa29 (patch) | |
tree | 66b6466d3c7a9712602b6f279437589661bca3f7 /lib | |
parent | dfe77be7480825fd4d42ac9eb11ef67e60780831 (diff) | |
download | cryptsetup-a38cb2375ffc6d9f0a2e92f6fa266b9e0db6aa29.tar.gz cryptsetup-a38cb2375ffc6d9f0a2e92f6fa266b9e0db6aa29.tar.bz2 cryptsetup-a38cb2375ffc6d9f0a2e92f6fa266b9e0db6aa29.zip |
* Add crypt_set_uuid() to API.
* Allow UUID setting in luksFormat and luksUUID (--uuid parameter).
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@355 36d66b0a-2a48-0410-832c-cd162a569da5
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcryptsetup.h | 11 | ||||
-rw-r--r-- | lib/libcryptsetup.sym | 1 | ||||
-rw-r--r-- | lib/setup.c | 26 |
3 files changed, 36 insertions, 2 deletions
diff --git a/lib/libcryptsetup.h b/lib/libcryptsetup.h index bed49fc..e27726e 100644 --- a/lib/libcryptsetup.h +++ b/lib/libcryptsetup.h @@ -183,6 +183,17 @@ int crypt_format(struct crypt_device *cd, void *params); /** + * Set new UUID for already existing device (if format supports it) + * + * Returns 0 on success or negative errno value otherwise. + * + * @cd - crypt device handle + * @uuid - requested UUID or NULL if it should be generated + */ +int crypt_set_uuid(struct crypt_device *cd, + const char *uuid); + +/** * Load crypt device parameters from on-disk header * * Returns 0 on success or negative errno value otherwise. diff --git a/lib/libcryptsetup.sym b/lib/libcryptsetup.sym index 9d25463..10c1dd5 100644 --- a/lib/libcryptsetup.sym +++ b/lib/libcryptsetup.sym @@ -9,6 +9,7 @@ CRYPTSETUP_1.0 { crypt_set_password_retry; crypt_set_iterarion_time; crypt_set_password_verify; + crypt_set_uuid; crypt_memory_lock; crypt_format; diff --git a/lib/setup.c b/lib/setup.c index eb34b47..af179fd 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -1186,6 +1186,30 @@ int crypt_load(struct crypt_device *cd, return r; } +int crypt_set_uuid(struct crypt_device *cd, const char *uuid) +{ + if (!isLUKS(cd->type)) { + log_err(cd, _("This operation is not supported for this device type.\n")); + return -EINVAL; + } + + if (uuid && !strncmp(uuid, cd->hdr.uuid, sizeof(cd->hdr.uuid))) { + log_dbg("UUID is the same as requested (%s) for device %s.", + uuid, cd->device); + return 0; + } + + if (uuid) + log_dbg("Requested new UUID change to %s for %s.", uuid, cd->device); + else + log_dbg("Requested new UUID refresh for %s.", cd->device); + + if (!crypt_confirm(cd, _("Do you really want to change UUID of device?"))) + return -EPERM; + + return LUKS_hdr_uuid_set(cd->device, &cd->hdr, uuid, cd); +} + int crypt_header_backup(struct crypt_device *cd, const char *requested_type, const char *backup_file) @@ -2015,8 +2039,6 @@ int crypt_dump(struct crypt_device *cd) log_std(cd, "Key Slot %d: DISABLED\n", i); } - log_std(cd, "DNAME: %s\n", crypt_get_device_name(cd) ?: ""); - return 0; } |