summaryrefslogtreecommitdiffstats
path: root/man4/loop.4
diff options
context:
space:
mode:
Diffstat (limited to 'man4/loop.4')
-rw-r--r--man4/loop.420
1 files changed, 10 insertions, 10 deletions
diff --git a/man4/loop.4 b/man4/loop.4
index 5f923d1ba..72a243192 100644
--- a/man4/loop.4
+++ b/man4/loop.4
@@ -313,44 +313,44 @@ loopname = /dev/loop5
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-
+\&
#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \e
} while (0)
-
+\&
int
main(int argc, char *argv[])
{
int loopctlfd, loopfd, backingfile;
long devnr;
char loopname[4096];
-
+\&
if (argc != 2) {
fprintf(stderr, "Usage: %s backing\-file\en", argv[0]);
exit(EXIT_FAILURE);
}
-
+\&
loopctlfd = open("/dev/loop\-control", O_RDWR);
if (loopctlfd == \-1)
errExit("open: /dev/loop\-control");
-
+\&
devnr = ioctl(loopctlfd, LOOP_CTL_GET_FREE);
if (devnr == \-1)
errExit("ioctl\-LOOP_CTL_GET_FREE");
-
+\&
sprintf(loopname, "/dev/loop%ld", devnr);
printf("loopname = %s\en", loopname);
-
+\&
loopfd = open(loopname, O_RDWR);
if (loopfd == \-1)
errExit("open: loopname");
-
+\&
backingfile = open(argv[1], O_RDWR);
if (backingfile == \-1)
errExit("open: backing\-file");
-
+\&
if (ioctl(loopfd, LOOP_SET_FD, backingfile) == \-1)
errExit("ioctl\-LOOP_SET_FD");
-
+\&
exit(EXIT_SUCCESS);
}
.EE