diff options
author | Milan Broz <mbroz@redhat.com> | 2011-01-13 14:59:52 -0500 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2011-01-13 14:59:52 -0500 |
commit | 7dbcd137414f3877737802438926d6dba7906a9a (patch) | |
tree | cb1062484dfbfab08c66d39129c63aab29ef0c30 /drivers | |
parent | 86a54a4802df10d23ccd655e2083e812fe990243 (diff) |
dm crypt: simplify compatible table output
Rename cc->cipher_mode to cc->cipher_string and store the whole of the cipher
information so it can easily be printed when processing the DM_DEV_STATUS ioctl.
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/dm-crypt.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 4c4408a2602f..9a896e1cb2ea 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
@@ -108,7 +108,7 @@ struct crypt_config { | |||
108 | struct workqueue_struct *crypt_queue; | 108 | struct workqueue_struct *crypt_queue; |
109 | 109 | ||
110 | char *cipher; | 110 | char *cipher; |
111 | char *cipher_mode; | 111 | char *cipher_string; |
112 | 112 | ||
113 | struct crypt_iv_operations *iv_gen_ops; | 113 | struct crypt_iv_operations *iv_gen_ops; |
114 | union { | 114 | union { |
@@ -1030,7 +1030,7 @@ static void crypt_dtr(struct dm_target *ti) | |||
1030 | dm_put_device(ti, cc->dev); | 1030 | dm_put_device(ti, cc->dev); |
1031 | 1031 | ||
1032 | kzfree(cc->cipher); | 1032 | kzfree(cc->cipher); |
1033 | kzfree(cc->cipher_mode); | 1033 | kzfree(cc->cipher_string); |
1034 | 1034 | ||
1035 | /* Must zero key material before freeing */ | 1035 | /* Must zero key material before freeing */ |
1036 | kzfree(cc); | 1036 | kzfree(cc); |
@@ -1050,6 +1050,10 @@ static int crypt_ctr_cipher(struct dm_target *ti, | |||
1050 | return -EINVAL; | 1050 | return -EINVAL; |
1051 | } | 1051 | } |
1052 | 1052 | ||
1053 | cc->cipher_string = kstrdup(cipher_in, GFP_KERNEL); | ||
1054 | if (!cc->cipher_string) | ||
1055 | goto bad_mem; | ||
1056 | |||
1053 | /* | 1057 | /* |
1054 | * Legacy dm-crypt cipher specification | 1058 | * Legacy dm-crypt cipher specification |
1055 | * cipher-mode-iv:ivopts | 1059 | * cipher-mode-iv:ivopts |
@@ -1061,12 +1065,6 @@ static int crypt_ctr_cipher(struct dm_target *ti, | |||
1061 | if (!cc->cipher) | 1065 | if (!cc->cipher) |
1062 | goto bad_mem; | 1066 | goto bad_mem; |
1063 | 1067 | ||
1064 | if (tmp) { | ||
1065 | cc->cipher_mode = kstrdup(tmp, GFP_KERNEL); | ||
1066 | if (!cc->cipher_mode) | ||
1067 | goto bad_mem; | ||
1068 | } | ||
1069 | |||
1070 | chainmode = strsep(&tmp, "-"); | 1068 | chainmode = strsep(&tmp, "-"); |
1071 | ivopts = strsep(&tmp, "-"); | 1069 | ivopts = strsep(&tmp, "-"); |
1072 | ivmode = strsep(&ivopts, ":"); | 1070 | ivmode = strsep(&ivopts, ":"); |
@@ -1074,10 +1072,11 @@ static int crypt_ctr_cipher(struct dm_target *ti, | |||
1074 | if (tmp) | 1072 | if (tmp) |
1075 | DMWARN("Ignoring unexpected additional cipher options"); | 1073 | DMWARN("Ignoring unexpected additional cipher options"); |
1076 | 1074 | ||
1077 | /* Compatibility mode for old dm-crypt mappings */ | 1075 | /* |
1076 | * For compatibility with the original dm-crypt mapping format, if | ||
1077 | * only the cipher name is supplied, use cbc-plain. | ||
1078 | */ | ||
1078 | if (!chainmode || (!strcmp(chainmode, "plain") && !ivmode)) { | 1079 | if (!chainmode || (!strcmp(chainmode, "plain") && !ivmode)) { |
1079 | kfree(cc->cipher_mode); | ||
1080 | cc->cipher_mode = kstrdup("cbc-plain", GFP_KERNEL); | ||
1081 | chainmode = "cbc"; | 1080 | chainmode = "cbc"; |
1082 | ivmode = "plain"; | 1081 | ivmode = "plain"; |
1083 | } | 1082 | } |
@@ -1307,10 +1306,7 @@ static int crypt_status(struct dm_target *ti, status_type_t type, | |||
1307 | break; | 1306 | break; |
1308 | 1307 | ||
1309 | case STATUSTYPE_TABLE: | 1308 | case STATUSTYPE_TABLE: |
1310 | if (cc->cipher_mode) | 1309 | DMEMIT("%s ", cc->cipher_string); |
1311 | DMEMIT("%s-%s ", cc->cipher, cc->cipher_mode); | ||
1312 | else | ||
1313 | DMEMIT("%s ", cc->cipher); | ||
1314 | 1310 | ||
1315 | if (cc->key_size > 0) { | 1311 | if (cc->key_size > 0) { |
1316 | if ((maxlen - sz) < ((cc->key_size << 1) + 1)) | 1312 | if ((maxlen - sz) < ((cc->key_size << 1) + 1)) |
@@ -1422,7 +1418,7 @@ static int crypt_iterate_devices(struct dm_target *ti, | |||
1422 | 1418 | ||
1423 | static struct target_type crypt_target = { | 1419 | static struct target_type crypt_target = { |
1424 | .name = "crypt", | 1420 | .name = "crypt", |
1425 | .version = {1, 7, 0}, | 1421 | .version = {1, 8, 0}, |
1426 | .module = THIS_MODULE, | 1422 | .module = THIS_MODULE, |
1427 | .ctr = crypt_ctr, | 1423 | .ctr = crypt_ctr, |
1428 | .dtr = crypt_dtr, | 1424 | .dtr = crypt_dtr, |