/*
* Utility routines.
*
- * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
+ * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
int fd;
if ((fd = open(device, O_RDONLY)) < 0) {
- perror_msg("%s", device);
+ bb_perror_msg("%s", device);
return (FALSE);
}
if (ioctl(fd, LOOP_CLR_FD, 0) < 0) {
- perror_msg("ioctl: LOOP_CLR_FD");
+ close(fd);
+ bb_perror_msg("ioctl: LOOP_CLR_FD");
return (FALSE);
}
close(fd);
mode = *loopro ? O_RDONLY : O_RDWR;
if ((ffd = open(file, mode)) < 0 && !*loopro
&& (errno != EROFS || (ffd = open(file, mode = O_RDONLY)) < 0)) {
- perror_msg("%s", file);
+ bb_perror_msg("%s", file);
return 1;
}
if ((fd = open(device, mode)) < 0) {
close(ffd);
- perror_msg("%s", device);
+ bb_perror_msg("%s", device);
return 1;
}
*loopro = (mode == O_RDONLY);
loopinfo.lo_encrypt_key_size = 0;
if (ioctl(fd, LOOP_SET_FD, ffd) < 0) {
- perror_msg("ioctl: LOOP_SET_FD");
+ bb_perror_msg("ioctl: LOOP_SET_FD");
close(fd);
close(ffd);
return 1;
}
if (ioctl(fd, LOOP_SET_STATUS, &loopinfo) < 0) {
(void) ioctl(fd, LOOP_CLR_FD, 0);
- perror_msg("ioctl: LOOP_SET_STATUS");
+ bb_perror_msg("ioctl: LOOP_SET_STATUS");
close(fd);
close(ffd);
return 1;
struct loop_info loopinfo;
for (i = 0; i <= 7; i++) {
- sprintf(dev, "/dev/loop%d", i);
+ sprintf(dev, LOOP_FORMAT, i);
if (stat(dev, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)) {
if ((fd = open(dev, O_RDONLY)) >= 0) {
if (ioctl(fd, LOOP_GET_STATUS, &loopinfo) != 0) {