Lines 114-123
Link Here
|
114 |
{ 'l', "keylen", "0", G_TYPE_NUMBER }, |
114 |
{ 'l', "keylen", "0", G_TYPE_NUMBER }, |
115 |
{ 'P', "nonewpassphrase", NULL, G_TYPE_BOOL }, |
115 |
{ 'P', "nonewpassphrase", NULL, G_TYPE_BOOL }, |
116 |
{ 's', "sectorsize", "0", G_TYPE_NUMBER }, |
116 |
{ 's', "sectorsize", "0", G_TYPE_NUMBER }, |
|
|
117 |
{ 't', "trim", NULL, G_TYPE_BOOL }, |
117 |
{ 'V', "mdversion", "-1", G_TYPE_NUMBER }, |
118 |
{ 'V', "mdversion", "-1", G_TYPE_NUMBER }, |
118 |
G_OPT_SENTINEL |
119 |
G_OPT_SENTINEL |
119 |
}, |
120 |
}, |
120 |
"[-bPv] [-a aalgo] [-B backupfile] [-e ealgo] [-i iterations] [-l keylen] [-J newpassfile] [-K newkeyfile] [-s sectorsize] [-V version] prov" |
121 |
"[-bPtv] [-a aalgo] [-B backupfile] [-e ealgo] [-i iterations] [-l keylen] [-J newpassfile] [-K newkeyfile] [-s sectorsize] [-V version] prov" |
121 |
}, |
122 |
}, |
122 |
{ "label", G_FLAG_VERBOSE, eli_main, |
123 |
{ "label", G_FLAG_VERBOSE, eli_main, |
123 |
{ |
124 |
{ |
Lines 170-186
Link Here
|
170 |
{ 'e', "ealgo", GELI_ENC_ALGO, G_TYPE_STRING }, |
171 |
{ 'e', "ealgo", GELI_ENC_ALGO, G_TYPE_STRING }, |
171 |
{ 'l', "keylen", "0", G_TYPE_NUMBER }, |
172 |
{ 'l', "keylen", "0", G_TYPE_NUMBER }, |
172 |
{ 's', "sectorsize", "0", G_TYPE_NUMBER }, |
173 |
{ 's', "sectorsize", "0", G_TYPE_NUMBER }, |
|
|
174 |
{ 't', "trim", NULL, G_TYPE_BOOL }, |
173 |
G_OPT_SENTINEL |
175 |
G_OPT_SENTINEL |
174 |
}, |
176 |
}, |
175 |
"[-d] [-a aalgo] [-e ealgo] [-l keylen] [-s sectorsize] prov" |
177 |
"[-dt] [-a aalgo] [-e ealgo] [-l keylen] [-s sectorsize] prov" |
176 |
}, |
178 |
}, |
177 |
{ "configure", G_FLAG_VERBOSE, eli_main, |
179 |
{ "configure", G_FLAG_VERBOSE, eli_main, |
178 |
{ |
180 |
{ |
179 |
{ 'b', "boot", NULL, G_TYPE_BOOL }, |
181 |
{ 'b', "boot", NULL, G_TYPE_BOOL }, |
180 |
{ 'B', "noboot", NULL, G_TYPE_BOOL }, |
182 |
{ 'B', "noboot", NULL, G_TYPE_BOOL }, |
|
|
183 |
{ 't', "trim", NULL, G_TYPE_BOOL }, |
184 |
{ 'T', "notrim", NULL, G_TYPE_BOOL }, |
181 |
G_OPT_SENTINEL |
185 |
G_OPT_SENTINEL |
182 |
}, |
186 |
}, |
183 |
"[-bB] prov ..." |
187 |
"[-bBtT] prov ..." |
184 |
}, |
188 |
}, |
185 |
{ "setkey", G_FLAG_VERBOSE, eli_main, |
189 |
{ "setkey", G_FLAG_VERBOSE, eli_main, |
186 |
{ |
190 |
{ |
Lines 698-703
Link Here
|
698 |
md.md_flags = 0; |
702 |
md.md_flags = 0; |
699 |
if (gctl_get_int(req, "boot")) |
703 |
if (gctl_get_int(req, "boot")) |
700 |
md.md_flags |= G_ELI_FLAG_BOOT; |
704 |
md.md_flags |= G_ELI_FLAG_BOOT; |
|
|
705 |
if (gctl_get_int(req, "trim")) |
706 |
md.md_flags |= G_ELI_FLAG_DELETE; |
701 |
md.md_ealgo = CRYPTO_ALGORITHM_MIN - 1; |
707 |
md.md_ealgo = CRYPTO_ALGORITHM_MIN - 1; |
702 |
str = gctl_get_ascii(req, "aalgo"); |
708 |
str = gctl_get_ascii(req, "aalgo"); |
703 |
if (*str != '\0') { |
709 |
if (*str != '\0') { |
Lines 899-924
Link Here
|
899 |
} |
905 |
} |
900 |
|
906 |
|
901 |
static void |
907 |
static void |
902 |
eli_configure_detached(struct gctl_req *req, const char *prov, bool boot) |
908 |
eli_configure_detached(struct gctl_req *req, const char *prov, int boot, |
|
|
909 |
int trim) |
903 |
{ |
910 |
{ |
904 |
struct g_eli_metadata md; |
911 |
struct g_eli_metadata md; |
|
|
912 |
bool changed = 0; |
905 |
|
913 |
|
906 |
if (eli_metadata_read(req, prov, &md) == -1) |
914 |
if (eli_metadata_read(req, prov, &md) == -1) |
907 |
return; |
915 |
return; |
908 |
|
916 |
|
909 |
if (boot && (md.md_flags & G_ELI_FLAG_BOOT)) { |
917 |
if (boot == 1 && (md.md_flags & G_ELI_FLAG_BOOT)) { |
910 |
if (verbose) |
918 |
if (verbose) |
911 |
printf("BOOT flag already configured for %s.\n", prov); |
919 |
printf("BOOT flag already configured for %s.\n", prov); |
912 |
} else if (!boot && !(md.md_flags & G_ELI_FLAG_BOOT)) { |
920 |
} else if (boot == 0 && !(md.md_flags & G_ELI_FLAG_BOOT)) { |
913 |
if (verbose) |
921 |
if (verbose) |
914 |
printf("BOOT flag not configured for %s.\n", prov); |
922 |
printf("BOOT flag not configured for %s.\n", prov); |
915 |
} else { |
923 |
} else if (boot >= 0) { |
916 |
if (boot) |
924 |
if (boot) |
917 |
md.md_flags |= G_ELI_FLAG_BOOT; |
925 |
md.md_flags |= G_ELI_FLAG_BOOT; |
918 |
else |
926 |
else |
919 |
md.md_flags &= ~G_ELI_FLAG_BOOT; |
927 |
md.md_flags &= ~G_ELI_FLAG_BOOT; |
|
|
928 |
changed = 1; |
929 |
} |
930 |
|
931 |
if (trim == 1 && (md.md_flags & G_ELI_FLAG_DELETE)) { |
932 |
if (verbose) |
933 |
printf("TRIM flag already configured for %s.\n", prov); |
934 |
} else if (trim == 0 && !(md.md_flags & G_ELI_FLAG_DELETE)) { |
935 |
if (verbose) |
936 |
printf("TRIM flag not configured for %s.\n", prov); |
937 |
} else if (trim >= 0) { |
938 |
if (trim) |
939 |
md.md_flags |= G_ELI_FLAG_DELETE; |
940 |
else |
941 |
md.md_flags &= ~G_ELI_FLAG_DELETE; |
942 |
changed = 1; |
943 |
} |
944 |
|
945 |
if (changed) |
920 |
eli_metadata_store(req, prov, &md); |
946 |
eli_metadata_store(req, prov, &md); |
921 |
} |
|
|
922 |
bzero(&md, sizeof(md)); |
947 |
bzero(&md, sizeof(md)); |
923 |
} |
948 |
} |
924 |
|
949 |
|
Lines 926-932
Link Here
|
926 |
eli_configure(struct gctl_req *req) |
951 |
eli_configure(struct gctl_req *req) |
927 |
{ |
952 |
{ |
928 |
const char *prov; |
953 |
const char *prov; |
929 |
bool boot, noboot; |
954 |
bool boot, noboot, trim, notrim; |
|
|
955 |
int doboot, dotrim; |
930 |
int i, nargs; |
956 |
int i, nargs; |
931 |
|
957 |
|
932 |
nargs = gctl_get_int(req, "nargs"); |
958 |
nargs = gctl_get_int(req, "nargs"); |
Lines 937-948
Link Here
|
937 |
|
963 |
|
938 |
boot = gctl_get_int(req, "boot"); |
964 |
boot = gctl_get_int(req, "boot"); |
939 |
noboot = gctl_get_int(req, "noboot"); |
965 |
noboot = gctl_get_int(req, "noboot"); |
|
|
966 |
trim = gctl_get_int(req, "trim"); |
967 |
notrim = gctl_get_int(req, "notrim"); |
940 |
|
968 |
|
|
|
969 |
doboot = -1; |
941 |
if (boot && noboot) { |
970 |
if (boot && noboot) { |
942 |
gctl_error(req, "Options -b and -B are mutually exclusive."); |
971 |
gctl_error(req, "Options -b and -B are mutually exclusive."); |
943 |
return; |
972 |
return; |
944 |
} |
973 |
} |
945 |
if (!boot && !noboot) { |
974 |
if (boot) |
|
|
975 |
doboot = 1; |
976 |
else if (noboot) |
977 |
doboot = 0; |
978 |
|
979 |
dotrim = -1; |
980 |
if (trim && notrim) { |
981 |
gctl_error(req, "Options -t and -T are mutually exclusive."); |
982 |
return; |
983 |
} |
984 |
if (trim) |
985 |
dotrim = 1; |
986 |
else if (notrim) |
987 |
dotrim = 0; |
988 |
|
989 |
if (doboot == -1 && dotrim == -1) { |
946 |
gctl_error(req, "No option given."); |
990 |
gctl_error(req, "No option given."); |
947 |
return; |
991 |
return; |
948 |
} |
992 |
} |
Lines 953-959
Link Here
|
953 |
for (i = 0; i < nargs; i++) { |
997 |
for (i = 0; i < nargs; i++) { |
954 |
prov = gctl_get_ascii(req, "arg%d", i); |
998 |
prov = gctl_get_ascii(req, "arg%d", i); |
955 |
if (!eli_is_attached(prov)) |
999 |
if (!eli_is_attached(prov)) |
956 |
eli_configure_detached(req, prov, boot); |
1000 |
eli_configure_detached(req, prov, doboot, dotrim); |
957 |
} |
1001 |
} |
958 |
} |
1002 |
} |
959 |
|
1003 |
|