Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177425468
D33846.1794351373.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
867 B
Referenced Files
None
Subscribers
None
D33846.1794351373.diff
View Options
Index: sbin/swapon/swapon.c
===================================================================
--- sbin/swapon/swapon.c
+++ sbin/swapon/swapon.c
@@ -756,6 +756,24 @@
fd = open(name, O_WRONLY);
if (fd < 0)
errx(1, "Cannot open %s", name);
+
+ /*
+ * Hack: see if the file is already in use as a swap device. If so,
+ * don't attempt to erase its blocks since we may end up clearing
+ * swapped-out data. Currently there is no surefire way to determine
+ * whether a file is a swap device other than by attempting to enable it
+ * as such, and observing EBUSY.
+ */
+ error = swapon(name);
+ if (error != 0) {
+ error = errno;
+ (void)close(fd);
+ errno = error;
+ return (-1);
+ }
+ if (swapoff(name, SWAPOFF_FORCE) != 0)
+ err(1, "swapoff(%s)", name);
+
/* Find the device size. */
if (fstat(fd, &sb) < 0)
errx(1, "Cannot stat %s", name);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 10, 10:56 PM (19 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41648472
Default Alt Text
D33846.1794351373.diff (867 B)
Attached To
Mode
D33846: swapon: Don't honour "trimonce" for active swap devices
Attached
Detach File
Event Timeline