#include "test.h" #include "safe_macros.h" char *TCID = "loop_test"; int TST_TOTAL = 1; void attach_device(void (*cleanup_fn)(void), const char *dev, const char *file); void detach_device(void (*cleanup_fn)(void), const char *dev); int main(void) { int i, fd; tst_tmpdir(); fd = SAFE_OPEN(NULL, "file.img", O_RDWR | O_CREAT, 0644); SAFE_FTRUNCATE(NULL, fd, 1024 * 1024UL); SAFE_CLOSE(NULL, fd); for (i = 0; i < 1000; i++) { attach_device(NULL, "/dev/loop0", "file.img"); detach_device(NULL, "/dev/loop0"); } tst_rmdir(); tst_resm(TPASS, "Finished"); tst_exit(); }