mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-08 20:51:26 +00:00
iohelper: drop unused operation length limit
This commit is contained in:
parent
3faf3ca60a
commit
3b8a0f6ac2
@ -44,7 +44,7 @@
|
|||||||
#define VIR_FROM_THIS VIR_FROM_STORAGE
|
#define VIR_FROM_THIS VIR_FROM_STORAGE
|
||||||
|
|
||||||
static int
|
static int
|
||||||
runIO(const char *path, int fd, int oflags, unsigned long long length)
|
runIO(const char *path, int fd, int oflags)
|
||||||
{
|
{
|
||||||
void *base = NULL; /* Location to be freed */
|
void *base = NULL; /* Location to be freed */
|
||||||
char *buf = NULL; /* Aligned location within base */
|
char *buf = NULL; /* Aligned location within base */
|
||||||
@ -79,7 +79,7 @@ runIO(const char *path, int fd, int oflags, unsigned long long length)
|
|||||||
fdoutname = "stdout";
|
fdoutname = "stdout";
|
||||||
/* To make the implementation simpler, we give up on any
|
/* To make the implementation simpler, we give up on any
|
||||||
* attempt to use O_DIRECT in a non-trivial manner. */
|
* attempt to use O_DIRECT in a non-trivial manner. */
|
||||||
if (direct && ((end = lseek(fd, 0, SEEK_CUR)) != 0 || length)) {
|
if (direct && ((end = lseek(fd, 0, SEEK_CUR)) != 0)) {
|
||||||
virReportSystemError(end < 0 ? errno : EINVAL, "%s",
|
virReportSystemError(end < 0 ? errno : EINVAL, "%s",
|
||||||
_("O_DIRECT read needs entire seekable file"));
|
_("O_DIRECT read needs entire seekable file"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -110,20 +110,13 @@ runIO(const char *path, int fd, int oflags, unsigned long long length)
|
|||||||
while (1) {
|
while (1) {
|
||||||
ssize_t got;
|
ssize_t got;
|
||||||
|
|
||||||
if (length &&
|
|
||||||
(length - total) < buflen)
|
|
||||||
buflen = length - total;
|
|
||||||
|
|
||||||
if (buflen == 0)
|
|
||||||
break; /* End of requested data from client */
|
|
||||||
|
|
||||||
if ((got = saferead(fdin, buf, buflen)) < 0) {
|
if ((got = saferead(fdin, buf, buflen)) < 0) {
|
||||||
virReportSystemError(errno, _("Unable to read %s"), fdinname);
|
virReportSystemError(errno, _("Unable to read %s"), fdinname);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (got == 0)
|
if (got == 0)
|
||||||
break; /* End of file before end of requested data */
|
break; /* End of file before end of requested data */
|
||||||
if (got < buflen || (buflen & alignMask)) {
|
if (got < buflen) {
|
||||||
/* O_DIRECT can handle at most one short read, at end of file */
|
/* O_DIRECT can handle at most one short read, at end of file */
|
||||||
if (direct && shortRead) {
|
if (direct && shortRead) {
|
||||||
virReportSystemError(EINVAL, "%s",
|
virReportSystemError(EINVAL, "%s",
|
||||||
@ -178,7 +171,7 @@ usage(int status)
|
|||||||
if (status) {
|
if (status) {
|
||||||
fprintf(stderr, _("%s: try --help for more details"), program_name);
|
fprintf(stderr, _("%s: try --help for more details"), program_name);
|
||||||
} else {
|
} else {
|
||||||
printf(_("Usage: %s FILENAME LENGTH FD\n"), program_name);
|
printf(_("Usage: %s FILENAME FD\n"), program_name);
|
||||||
}
|
}
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
@ -187,7 +180,6 @@ int
|
|||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
const char *path;
|
const char *path;
|
||||||
unsigned long long length;
|
|
||||||
int oflags = -1;
|
int oflags = -1;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
||||||
@ -204,14 +196,8 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
if (argc > 1 && STREQ(argv[1], "--help"))
|
if (argc > 1 && STREQ(argv[1], "--help"))
|
||||||
usage(EXIT_SUCCESS);
|
usage(EXIT_SUCCESS);
|
||||||
if (argc == 4) { /* FILENAME LENGTH FD */
|
if (argc == 3) { /* FILENAME FD */
|
||||||
if (virStrToLong_ull(argv[2], NULL, 10, &length) < 0) {
|
if (virStrToLong_i(argv[2], NULL, 10, &fd) < 0) {
|
||||||
fprintf(stderr, _("%s: malformed file length %s"),
|
|
||||||
program_name, argv[2]);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virStrToLong_i(argv[3], NULL, 10, &fd) < 0) {
|
|
||||||
fprintf(stderr, _("%s: malformed fd %s"),
|
fprintf(stderr, _("%s: malformed fd %s"),
|
||||||
program_name, argv[3]);
|
program_name, argv[3]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -234,7 +220,7 @@ main(int argc, char **argv)
|
|||||||
usage(EXIT_FAILURE);
|
usage(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fd < 0 || runIO(path, fd, oflags, length) < 0)
|
if (fd < 0 || runIO(path, fd, oflags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -260,7 +260,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags)
|
|||||||
LIBEXECDIR)))
|
LIBEXECDIR)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
ret->cmd = virCommandNewArgList(iohelper_path, name, "0", NULL);
|
ret->cmd = virCommandNewArgList(iohelper_path, name, NULL);
|
||||||
|
|
||||||
VIR_FREE(iohelper_path);
|
VIR_FREE(iohelper_path);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user