aboutsummaryrefslogtreecommitdiffstats
path: root/man/man4
diff options
context:
space:
mode:
Diffstat (limited to 'man/man4')
-rw-r--r--man/man4/loop.414
1 files changed, 6 insertions, 8 deletions
diff --git a/man/man4/loop.4 b/man/man4/loop.4
index 8997a9aca0..a497ab0399 100644
--- a/man/man4/loop.4
+++ b/man/man4/loop.4
@@ -308,6 +308,7 @@ loopname = /dev/loop5
.SS Program source
\&
.EX
+#include <err.h>
#include <fcntl.h>
#include <linux/loop.h>
#include <sys/ioctl.h>
@@ -315,9 +316,6 @@ loopname = /dev/loop5
#include <stdlib.h>
#include <unistd.h>
\&
-#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \[rs]
- } while (0)
-\&
int
main(int argc, char *argv[])
{
@@ -332,25 +330,25 @@ main(int argc, char *argv[])
\&
loopctlfd = open("/dev/loop\-control", O_RDWR);
if (loopctlfd == \-1)
- errExit("open: /dev/loop\-control");
+ err(EXIT_FAILURE, "open: /dev/loop\-control");
\&
devnr = ioctl(loopctlfd, LOOP_CTL_GET_FREE);
if (devnr == \-1)
- errExit("ioctl\-LOOP_CTL_GET_FREE");
+ err(EXIT_FAILURE, "ioctl\-LOOP_CTL_GET_FREE");
\&
sprintf(loopname, "/dev/loop%ld", devnr);
printf("loopname = %s\[rs]n", loopname);
\&
loopfd = open(loopname, O_RDWR);
if (loopfd == \-1)
- errExit("open: loopname");
+ err(EXIT_FAILURE, "open: loopname");
\&
backingfile = open(argv[1], O_RDWR);
if (backingfile == \-1)
- errExit("open: backing\-file");
+ err(EXIT_FAILURE, "open: backing\-file");
\&
if (ioctl(loopfd, LOOP_SET_FD, backingfile) == \-1)
- errExit("ioctl\-LOOP_SET_FD");
+ err(EXIT_FAILURE, "ioctl\-LOOP_SET_FD");
\&
exit(EXIT_SUCCESS);
}