[PATCH 1/4] iohelper: drop unused operation length limit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/util/iohelper.c | 28 +++++++---------------------
 src/util/virfile.c  |  2 +-
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/src/util/iohelper.c b/src/util/iohelper.c
index d7bf5c7..5fc311b 100644
--- a/src/util/iohelper.c
+++ b/src/util/iohelper.c
@@ -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;
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 2f28e83..e746d87 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -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);
 
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux