$(INSTALL_PROG) tools/debug/fb_test userspace/usr/bin/
$(INSTALL_PROG) tools/crashme/crashme userspace/usr/bin/
$(INSTALL_PROG) tools/eatmem/eatmem userspace/usr/bin/
+ $(INSTALL_PROG) tools/discard_io/discard_io userspace/usr/bin/
fio/fio: fio/fio
$(MAKE) -j$$(($(NCPUS) * 2)) -C fio
SUBDIRS += eatmem
SUBDIRS += crashme
SUBDIRS += read_intr
+SUBDIRS += discard_io
.PHONY: all
all:
--- /dev/null
+TARGETS-y := discard_io
+TARGETS := $(TARGETS-y)
+
+INSTALL_BIN-y := discard_io
+INSTALL_BIN := $(INSTALL_BIN-y)
+
+
+.PHONY: all
+all: build
+
+.PHONY: build
+build: $(TARGETS)
+
+.PHONY: install
+install: build
+ $(INSTALL_DIR) $(DESTDIR)$(BINDIR)
+ $(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
+
+.PHONY: clean
+clean:
+ $(RM) *.o $(TARGETS) *~ $(DEPS)
+
+%.o: %.c $(HDRS) Makefile
+ $(CC) -c $(CFLAGS) -o $@ $<
+
--- /dev/null
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <linux/fs.h>
+#include <errno.h>
+#include <string.h>
+
+
+int main(int argc, char *argv[])
+{
+ char *name = "/dev/xvda";
+ int disk;
+ unsigned long range[2];
+ int rc;
+
+ if (argc >= 1)
+ name = argv[1];
+
+ disk = open(name, O_RDWR | O_EXCL | O_LARGEFILE);
+ if (disk == -1) {
+ fprintf(stderr,"Cannot open %s [%s]\n", name, strerror(errno));
+ return errno;
+ }
+ range[0] = 0;
+ range[1] = (-1ULL);
+ rc = ioctl(disk, BLKDISCARD, &range);
+ close(disk);
+ return rc;
+}