Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144606437
D48874.1775714729.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D48874.1775714729.diff
View Options
diff --git a/sbin/swapon/swapon.c b/sbin/swapon/swapon.c
--- a/sbin/swapon/swapon.c
+++ b/sbin/swapon/swapon.c
@@ -231,6 +231,7 @@
fnmatch(MD_NAME "[0-9]*", name, 0) == 0 ||
strncmp(_PATH_DEV MD_NAME, name,
sizeof(_PATH_DEV) + sizeof(MD_NAME)) == 0 ||
+ strncmp(MD_NAME ".eli", name, sizeof(MD_NAME ".eli")) == 0 ||
strncmp(MD_NAME, name, sizeof(MD_NAME)) == 0))
return (swap_on_off_md(name, mntops, doingall));
@@ -327,6 +328,8 @@
return (NULL);
}
Tflag = " -T ";
+ } else if ((p = strstr(token, "file=")) == token) {
+ /* ignore known option */
} else if (strcmp(token, "late") == 0) {
/* ignore known option */
} else if (strcmp(token, "noauto") == 0) {
@@ -416,24 +419,37 @@
char *p, *vnodefile;
size_t linelen;
u_long ul;
+ const char *suffix;
+ char *dname;
+ int name_len;
fd = -1;
sfd = NULL;
- if (strlen(name) == (sizeof(MD_NAME) - 1))
+ dname = strdup(name);
+ name_len = strlen(name) - strlen(".eli");
+ /* dname will be name without (.eli) suffix */
+ if (name_len > 0 && strcmp(suffix = &name[name_len], ".eli") == 0) {
+ suffix++;
+ dname[name_len] = '\0';
+ } else
+ suffix = NULL;
+ if (strlen(dname) == (sizeof(MD_NAME) - 1))
mdunit = -1;
else {
errno = 0;
- ul = strtoul(name + 2, &p, 10);
+ ul = strtoul(dname + 2, &p, 10);
if (errno == 0) {
if (*p != '\0' || ul > INT_MAX)
errno = EINVAL;
}
if (errno) {
- warn("Bad device unit: %s", name);
+ warn("Bad device unit: %s", dname);
+ free(dname);
return (NULL);
}
mdunit = (int)ul;
}
+ free(dname);
vnodefile = NULL;
if ((p = strstr(mntops, "file=")) != NULL) {
@@ -573,10 +589,19 @@
}
}
}
- snprintf(mdpath, sizeof(mdpath), "%s%s%d", _PATH_DEV,
- MD_NAME, mdunit);
- mdpath[sizeof(mdpath) - 1] = '\0';
- ret = swap_on_off_sfile(mdpath, doingall);
+
+ if (suffix != NULL && strcmp("eli", suffix) == 0) {
+ /* Swap on encrypted device by GEOM_ELI. */
+ snprintf(mdpath, sizeof(mdpath), "%s%s%d.eli", _PATH_DEV,
+ MD_NAME, mdunit);
+ mdpath[sizeof(mdpath) - 1] = '\0';
+ ret = swap_on_off_geli(mdpath, mntops, doingall);
+ } else {
+ snprintf(mdpath, sizeof(mdpath), "%s%s%d", _PATH_DEV,
+ MD_NAME, mdunit);
+ mdpath[sizeof(mdpath) - 1] = '\0';
+ ret = swap_on_off_sfile(mdpath, doingall);
+ }
if (which_prog == SWAPOFF) {
if (ret != NULL) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 9, 6:05 AM (15 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28306947
Default Alt Text
D48874.1775714729.diff (2 KB)
Attached To
Mode
D48874: swapon: parse md.eli device for encrypted swapfile from fstab
Attached
Detach File
Event Timeline
Log In to Comment