mirror of
https://github.com/sheumann/hush.git
synced 2025-01-04 22:34:37 +00:00
libbb/loop.c: style and readability fixes, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
917693b5b3
commit
44fbfa78ca
27
libbb/loop.c
27
libbb/loop.c
@ -56,14 +56,16 @@ char* FAST_FUNC query_loop(const char *device)
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
bb_loop_info loopinfo;
|
bb_loop_info loopinfo;
|
||||||
char *dev = 0;
|
char *dev = NULL;
|
||||||
|
|
||||||
fd = open(device, O_RDONLY);
|
fd = open(device, O_RDONLY);
|
||||||
if (fd < 0) return 0;
|
if (fd >= 0) {
|
||||||
if (!ioctl(fd, BB_LOOP_GET_STATUS, &loopinfo))
|
if (ioctl(fd, BB_LOOP_GET_STATUS, &loopinfo) == 0) {
|
||||||
dev = xasprintf("%ld %s", (long) loopinfo.lo_offset,
|
dev = xasprintf("%lu %s", (long) loopinfo.lo_offset,
|
||||||
(char *)loopinfo.lo_file_name);
|
(char *)loopinfo.lo_file_name);
|
||||||
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
@ -73,7 +75,8 @@ int FAST_FUNC del_loop(const char *device)
|
|||||||
int fd, rc;
|
int fd, rc;
|
||||||
|
|
||||||
fd = open(device, O_RDONLY);
|
fd = open(device, O_RDONLY);
|
||||||
if (fd < 0) return 1;
|
if (fd < 0)
|
||||||
|
return 1;
|
||||||
rc = ioctl(fd, LOOP_CLR_FD, 0);
|
rc = ioctl(fd, LOOP_CLR_FD, 0);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
@ -110,7 +113,7 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse
|
|||||||
sprintf(dev, LOOP_FORMAT, i);
|
sprintf(dev, LOOP_FORMAT, i);
|
||||||
|
|
||||||
/* Ran out of block devices, return failure. */
|
/* Ran out of block devices, return failure. */
|
||||||
if (stat(try, &statbuf) || !S_ISBLK(statbuf.st_mode)) {
|
if (stat(try, &statbuf) != 0 || !S_ISBLK(statbuf.st_mode)) {
|
||||||
rc = -ENOENT;
|
rc = -ENOENT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -131,8 +134,8 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse
|
|||||||
safe_strncpy((char *)loopinfo.lo_file_name, file, LO_NAME_SIZE);
|
safe_strncpy((char *)loopinfo.lo_file_name, file, LO_NAME_SIZE);
|
||||||
loopinfo.lo_offset = offset;
|
loopinfo.lo_offset = offset;
|
||||||
/* Associate free loop device with file. */
|
/* Associate free loop device with file. */
|
||||||
if (!ioctl(dfd, LOOP_SET_FD, ffd)) {
|
if (ioctl(dfd, LOOP_SET_FD, ffd) == 0) {
|
||||||
if (!ioctl(dfd, BB_LOOP_SET_STATUS, &loopinfo))
|
if (ioctl(dfd, BB_LOOP_SET_STATUS, &loopinfo) == 0)
|
||||||
rc = 0;
|
rc = 0;
|
||||||
else
|
else
|
||||||
ioctl(dfd, LOOP_CLR_FD, 0);
|
ioctl(dfd, LOOP_CLR_FD, 0);
|
||||||
@ -143,8 +146,10 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse
|
|||||||
file isn't pretty either. In general, mounting the same file twice
|
file isn't pretty either. In general, mounting the same file twice
|
||||||
without using losetup manually is problematic.)
|
without using losetup manually is problematic.)
|
||||||
*/
|
*/
|
||||||
} else if (strcmp(file, (char *)loopinfo.lo_file_name) != 0
|
} else
|
||||||
|| offset != loopinfo.lo_offset) {
|
if (strcmp(file, (char *)loopinfo.lo_file_name) != 0
|
||||||
|
|| offset != loopinfo.lo_offset
|
||||||
|
) {
|
||||||
rc = -1;
|
rc = -1;
|
||||||
}
|
}
|
||||||
close(dfd);
|
close(dfd);
|
||||||
@ -152,7 +157,7 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse
|
|||||||
if (*device) break;
|
if (*device) break;
|
||||||
}
|
}
|
||||||
close(ffd);
|
close(ffd);
|
||||||
if (!rc) {
|
if (rc == 0) {
|
||||||
if (!*device)
|
if (!*device)
|
||||||
*device = xstrdup(dev);
|
*device = xstrdup(dev);
|
||||||
return (mode == O_RDONLY); /* 1:ro, 0:rw */
|
return (mode == O_RDONLY); /* 1:ro, 0:rw */
|
||||||
|
Loading…
Reference in New Issue
Block a user