Page MenuHomeFreeBSD

D20599.id58510.diff
No OneTemporary

D20599.id58510.diff

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

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)

Event Timeline