lib/loopdev: differentiate between setter()s and ioctl calls
Now the internal API uses loopcxt_set_...() to set context variables as well as to call ioctls. This patch introduces loopcxt_ioctl_...() to makes things more obvious to readers. Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
56c2d2904f
commit
9fcc893624
|
@ -164,16 +164,17 @@ extern int loopcxt_deinit_iterator(struct loopdev_cxt *lc);
|
|||
extern int loopcxt_next(struct loopdev_cxt *lc);
|
||||
|
||||
extern int loopcxt_setup_device(struct loopdev_cxt *lc);
|
||||
extern int loopcxt_set_status(struct loopdev_cxt *lc);
|
||||
extern int loopcxt_delete_device(struct loopdev_cxt *lc);
|
||||
extern int loopcxt_set_capacity(struct loopdev_cxt *lc);
|
||||
extern int loopcxt_set_dio(struct loopdev_cxt *lc, unsigned long use_dio);
|
||||
|
||||
extern int loopcxt_ioctl_status(struct loopdev_cxt *lc);
|
||||
extern int loopcxt_ioctl_capacity(struct loopdev_cxt *lc);
|
||||
extern int loopcxt_ioctl_dio(struct loopdev_cxt *lc, unsigned long use_dio);
|
||||
extern int loopcxt_ioctl_blocksize(struct loopdev_cxt *lc, uint64_t blocksize);
|
||||
|
||||
int loopcxt_set_offset(struct loopdev_cxt *lc, uint64_t offset);
|
||||
int loopcxt_set_sizelimit(struct loopdev_cxt *lc, uint64_t sizelimit);
|
||||
int loopcxt_set_flags(struct loopdev_cxt *lc, uint32_t flags);
|
||||
int loopcxt_set_backing_file(struct loopdev_cxt *lc, const char *filename);
|
||||
int loopcxt_set_blocksize(struct loopdev_cxt *lc, uint64_t blocksize);
|
||||
|
||||
extern char *loopcxt_get_backing_file(struct loopdev_cxt *lc);
|
||||
extern int loopcxt_get_backing_devno(struct loopdev_cxt *lc, dev_t *devno);
|
||||
|
|
|
@ -1216,7 +1216,7 @@ static int loopcxt_check_size(struct loopdev_cxt *lc, int file_fd)
|
|||
"size mismatch (%ju/%ju)",
|
||||
size, expected_size));
|
||||
|
||||
if (loopcxt_set_capacity(lc)) {
|
||||
if (loopcxt_ioctl_capacity(lc)) {
|
||||
/* ioctl not available */
|
||||
if (errno == ENOTTY || errno == EINVAL)
|
||||
errno = ERANGE;
|
||||
|
@ -1374,7 +1374,7 @@ err:
|
|||
*
|
||||
* Returns: <0 on error, 0 on success.
|
||||
*/
|
||||
int loopcxt_set_status(struct loopdev_cxt *lc)
|
||||
int loopcxt_ioctl_status(struct loopdev_cxt *lc)
|
||||
{
|
||||
int dev_fd, rc = -1;
|
||||
|
||||
|
@ -1397,7 +1397,7 @@ int loopcxt_set_status(struct loopdev_cxt *lc)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int loopcxt_set_capacity(struct loopdev_cxt *lc)
|
||||
int loopcxt_ioctl_capacity(struct loopdev_cxt *lc)
|
||||
{
|
||||
int fd = loopcxt_get_fd(lc);
|
||||
|
||||
|
@ -1415,7 +1415,7 @@ int loopcxt_set_capacity(struct loopdev_cxt *lc)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int loopcxt_set_dio(struct loopdev_cxt *lc, unsigned long use_dio)
|
||||
int loopcxt_ioctl_dio(struct loopdev_cxt *lc, unsigned long use_dio)
|
||||
{
|
||||
int fd = loopcxt_get_fd(lc);
|
||||
|
||||
|
@ -1437,7 +1437,7 @@ int loopcxt_set_dio(struct loopdev_cxt *lc, unsigned long use_dio)
|
|||
* Kernel uses "unsigned long" as ioctl arg, but we use u64 for all sizes to
|
||||
* keep loopdev internal API simple.
|
||||
*/
|
||||
int loopcxt_set_blocksize(struct loopdev_cxt *lc, uint64_t blocksize)
|
||||
int loopcxt_ioctl_blocksize(struct loopdev_cxt *lc, uint64_t blocksize)
|
||||
{
|
||||
int fd = loopcxt_get_fd(lc);
|
||||
|
||||
|
|
|
@ -508,7 +508,7 @@ static int create_loop(struct loopdev_cxt *lc,
|
|||
}
|
||||
|
||||
lc->info.lo_flags &= ~LO_FLAGS_AUTOCLEAR;
|
||||
if (loopcxt_set_status(lc)) {
|
||||
if (loopcxt_ioctl_status(lc)) {
|
||||
loopcxt_deinit(lc);
|
||||
errx(EXIT_FAILURE, _("%s: failed to re-use loop device"), file);
|
||||
}
|
||||
|
@ -887,7 +887,7 @@ int main(int argc, char **argv)
|
|||
warn("%s", loopcxt_get_device(&lc));
|
||||
break;
|
||||
case A_SET_CAPACITY:
|
||||
res = loopcxt_set_capacity(&lc);
|
||||
res = loopcxt_ioctl_capacity(&lc);
|
||||
if (res)
|
||||
warn(_("%s: set capacity failed"),
|
||||
loopcxt_get_device(&lc));
|
||||
|
@ -896,13 +896,13 @@ int main(int argc, char **argv)
|
|||
case A_SET_BLOCKSIZE:
|
||||
lo_set_post:
|
||||
if (set_dio) {
|
||||
res = loopcxt_set_dio(&lc, use_dio);
|
||||
res = loopcxt_ioctl_dio(&lc, use_dio);
|
||||
if (res)
|
||||
warn(_("%s: set direct io failed"),
|
||||
loopcxt_get_device(&lc));
|
||||
}
|
||||
if (set_blocksize) {
|
||||
res = loopcxt_set_blocksize(&lc, blocksize);
|
||||
res = loopcxt_ioctl_blocksize(&lc, blocksize);
|
||||
if (res)
|
||||
warn(_("%s: set logical block size failed"),
|
||||
loopcxt_get_device(&lc));
|
||||
|
|
Loading…
Reference in New Issue