Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157020127
D20599.id58510.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
967 B
Referenced Files
None
Subscribers
None
D20599.id58510.diff
View Options
Index: swapon.c
===================================================================
--- swapon.c
+++ swapon.c
@@ -721,14 +721,39 @@
return (WEXITSTATUS(status));
}
+static void
+swap_trim(const char *name)
+{
+
+ struct stat sb;
+ off_t ioarg[2];
+ int fd;
+
+ fd = open(name, O_RDONLY | O_DIRECT);
+ if (fd < 0)
+ return;
+ if (fstat(fd, &sb) >= 0) {
+ ioarg[0] = 0; /* start address */
+ if (S_ISREG(sb.st_mode) || S_ISDIR(sb.st_mode)) {
+ ioarg[1] = sb.st_size;
+ ioctl(fd, DIOCGDELETE, ioarg);
+ } else if ((S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) &&
+ ioctl(fd, DIOCGMEDIASIZE, &ioarg[1]) >= 0)
+ ioctl(fd, DIOCGDELETE, ioarg);
+ }
+ close(fd);
+}
+
static const char *
swap_on_off_sfile(const char *name, int doingall)
{
+
int error;
- if (which_prog == SWAPON)
+ if (which_prog == SWAPON) {
+ swap_trim(name);
error = swapon(name);
- else /* SWAPOFF */
+ } else /* SWAPOFF */
error = swapoff(name);
if (error == -1) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, May 18, 11:57 PM (14 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33277842
Default Alt Text
D20599.id58510.diff (967 B)
Attached To
Mode
D20599: simple trimming before swapon
Attached
Detach File
Event Timeline
Log In to Comment