Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F103539474
D33846.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
867 B
Referenced Files
None
Subscribers
None
D33846.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
Wed, Nov 27, 6:38 AM (21 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14880456
Default Alt Text
D33846.diff (867 B)
Attached To
Mode
D33846: swapon: Don't honour "trimonce" for active swap devices
Attached
Detach File
Event Timeline
Log In to Comment