#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 */
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;
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",
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);
}
main(int argc, char **argv)
{
const char *path;
- unsigned long long length;
int oflags = -1;
int fd = -1;
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);
usage(EXIT_FAILURE);
}
- if (fd < 0 || runIO(path, fd, oflags, length) < 0)
+ if (fd < 0 || runIO(path, fd, oflags) < 0)
goto error;
return 0;