Skip to content

Instantly share code, notes, and snippets.

@tai
Created August 29, 2018 13:17
Show Gist options
  • Select an option

  • Save tai/bdfa27f6bdad49c9efafdf66b8be80e3 to your computer and use it in GitHub Desktop.

Select an option

Save tai/bdfa27f6bdad49c9efafdf66b8be80e3 to your computer and use it in GitHub Desktop.
/*BINFMTC: -Wall
*/
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/loop.h>
int main(int argc, char **argv) {
if (argc != 2) {
fprintf(stderr, "Usage: %s <loop-index>\n", argv[0]);
return 0;
}
int li = atoi(argv[1]);
int fd = open("/dev/loop-control", O_RDWR);
ioctl(fd, LOOP_CTL_REMOVE, li);
close(fd);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment