]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
iohelper: drop unused operation length limit
authorNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Thu, 7 Sep 2017 07:44:13 +0000 (10:44 +0300)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 19 Sep 2017 09:37:15 +0000 (11:37 +0200)
src/util/iohelper.c
src/util/virfile.c

index d7bf5c7843de39271ec460ef75945bb4e75829a5..5fc311be62d91c3e3f552d747c3d4cbc23142378 100644 (file)
@@ -44,7 +44,7 @@
 #define VIR_FROM_THIS VIR_FROM_STORAGE
 
 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 */
     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";
         /* To make the implementation simpler, we give up on any
          * 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",
                                  _("O_DIRECT read needs entire seekable file"));
             goto cleanup;
@@ -110,20 +110,13 @@ runIO(const char *path, int fd, int oflags, unsigned long long length)
     while (1) {
         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) {
             virReportSystemError(errno, _("Unable to read %s"), fdinname);
             goto cleanup;
         }
         if (got == 0)
             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 */
             if (direct && shortRead) {
                 virReportSystemError(EINVAL, "%s",
@@ -178,7 +171,7 @@ usage(int status)
     if (status) {
         fprintf(stderr, _("%s: try --help for more details"), program_name);
     } else {
-        printf(_("Usage: %s FILENAME LENGTH FD\n"), program_name);
+        printf(_("Usage: %s FILENAME FD\n"), program_name);
     }
     exit(status);
 }
@@ -187,7 +180,6 @@ int
 main(int argc, char **argv)
 {
     const char *path;
-    unsigned long long length;
     int oflags = -1;
     int fd = -1;
 
@@ -204,14 +196,8 @@ main(int argc, char **argv)
 
     if (argc > 1 && STREQ(argv[1], "--help"))
         usage(EXIT_SUCCESS);
-    if (argc == 4) { /* FILENAME LENGTH FD */
-        if (virStrToLong_ull(argv[2], NULL, 10, &length) < 0) {
-            fprintf(stderr, _("%s: malformed file length %s"),
-                    program_name, argv[2]);
-            exit(EXIT_FAILURE);
-        }
-
-        if (virStrToLong_i(argv[3], NULL, 10, &fd) < 0) {
+    if (argc == 3) { /* FILENAME FD */
+        if (virStrToLong_i(argv[2], NULL, 10, &fd) < 0) {
             fprintf(stderr, _("%s: malformed fd %s"),
                     program_name, argv[3]);
             exit(EXIT_FAILURE);
@@ -234,7 +220,7 @@ main(int argc, char **argv)
         usage(EXIT_FAILURE);
     }
 
-    if (fd < 0 || runIO(path, fd, oflags, length) < 0)
+    if (fd < 0 || runIO(path, fd, oflags) < 0)
         goto error;
 
     return 0;
index 2f28e83f442f49c4251e40ae1175fd3df0764972..e746d871b331bd84c705b1df91f8f7c70e9aff6e 100644 (file)
@@ -260,7 +260,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags)
                                               LIBEXECDIR)))
         goto error;
 
-    ret->cmd = virCommandNewArgList(iohelper_path, name, "0", NULL);
+    ret->cmd = virCommandNewArgList(iohelper_path, name, NULL);
 
     VIR_FREE(iohelper_path);