Lines Matching defs:out

85 extern IO		in, out;
107 IO in, out; /* input/output state */
182 if (out.name == NULL) {
184 out.fd = STDOUT_FILENO;
185 out.name = "stdout";
189 out.fd = open(out.name, O_RDWR | OFLAGS, DEFFILEMODE);
195 if (out.fd < 0) {
196 out.fd = open(out.name, O_WRONLY | OFLAGS, DEFFILEMODE);
197 out.flags |= NOREAD;
199 if (out.fd < 0) {
201 out.name, strerror(errno));
206 /* Ensure out.fd is outside the stdio descriptor range */
207 out.fd = redup_clean_fd(out.fd);
210 getfdtype(&out);
217 if ((in.db = malloc(out.dbsz + in.dbsz - 1)) == NULL) {
221 out.db = in.db;
224 (out.db = malloc((u_int)(out.dbsz + cbsz))) == NULL) {
229 out.dbp = out.db;
234 if (out.offset)
242 (void)ftruncate(out.fd, (off_t)out.offset * out.dbsz);
382 out.dbcnt = in.dbcnt;
415 if (ddflags & C_OSYNC && out.dbcnt < out.dbsz) {
416 (void)memset(out.dbp, 0, out.dbsz - out.dbcnt);
417 out.dbcnt = out.dbsz;
420 * to write out the final block un-sparse
422 if ((out.dbcnt == 0) && pending) {
423 memset(out.db, 0, out.dbsz);
424 out.dbcnt = out.dbsz;
425 out.dbp = out.db + out.dbcnt;
426 pending -= out.dbsz;
428 if (out.dbcnt)
438 if (out.fd == STDOUT_FILENO && fsync(out.fd) == -1 && errno != EINVAL) {
443 if (close(out.fd) == -1) {
458 * Write one or more blocks out. The common case is writing a full
473 outp = out.db;
474 for (n = force ? out.dbcnt : out.dbsz;; n = out.dbsz) {
493 if (lseek(out.fd, pending, SEEK_CUR) ==
498 out.name, strerror(errno));
502 nw = bwrite(out.fd, outp, cnt);
506 out.name);
512 out.name, strerror(errno));
520 st.sparse += pending/out.dbsz;
521 st.out_full += pending/out.dbsz;
527 if (n != out.dbsz)
536 if (out.flags & ISCHR && !warned) {
539 "device\n", out.name);
541 if (out.flags & ISTAPE) {
544 out.name);
549 if ((out.dbcnt -= n) < out.dbsz)
554 if (out.dbcnt)
555 (void)memmove(out.db, out.dbp - out.dbcnt, out.dbcnt);
556 out.dbp = out.db + out.dbcnt;
663 if (!(out.flags & ISTAPE)) {
664 if (lseek(out.fd,
665 (off_t)out.offset * (off_t)out.dbsz, SEEK_SET) == -1) {
667 out.name, strerror(errno));
675 if (out.flags & NOREAD) {
677 t_op.mt_count = out.offset;
679 if (ioctl(out.fd, MTIOCTOP, &t_op) < 0)*/
680 fprintf(stderr, "%s: cannot read", out.name);
687 for (cnt = 0; cnt < out.offset; ++cnt) {
688 if ((n = read(out.fd, out.db, out.dbsz)) > 0)
693 out.name, strerror(errno));
705 if (ioctl(out.fd, MTIOCTOP, &t_op) == -1) */ {
706 fprintf(stderr, "%s: cannot position\n", out.name);
711 while (cnt++ < out.offset)
712 if ((n = bwrite(out.fd, out.db, out.dbsz)) != out.dbsz) {
715 out.name, strerror(errno));
741 out.dbp = in.dbp;
742 out.dbcnt = in.dbcnt;
744 if (in.dbcnt >= out.dbsz) {
753 in.dbp = out.dbp;
754 in.dbcnt = out.dbcnt;
762 fdatasync(out.fd);
767 out.dbcnt = in.dbcnt;
785 * max out buffer: obs + cbsz
820 for (inp = in.dbp - in.dbcnt, outp = out.dbp; in.dbcnt;) {
864 out.dbp += cbsz;
865 if ((out.dbcnt += cbsz) >= out.dbsz)
867 outp = out.dbp;
886 (void)memmove(out.dbp, in.dbp - in.dbcnt, in.dbcnt);
887 (void)memset(out.dbp + in.dbcnt,
889 out.dbcnt += cbsz;
898 * max out buffer: obs + cbsz
920 (void)memmove(out.dbp, inp, cnt);
921 out.dbp += cnt;
922 out.dbcnt += cnt;
924 ++out.dbcnt;
925 *out.dbp++ = '\n';
926 if (out.dbcnt >= out.dbsz)
945 (void)memmove(out.dbp, in.db, cnt);
946 out.dbp += cnt;
947 out.dbcnt += cnt;
949 ++out.dbcnt;
950 *out.dbp++ = '\n';
974 "%llu+%llu records in\n%llu+%llu records out\n",
1060 in.dbsz = out.dbsz = 512;
1146 * if (in.offset > INT_MAX/in.dbsz || out.offset > INT_MAX/out.dbsz)
1172 in.dbsz = out.dbsz = strsuftoll("block size", arg, 1, UINT_MAX);
1220 out.dbsz = strsuftoll("output block size", arg, 1, UINT_MAX);
1227 out.name = arg;
1234 out.offset = strsuftoll("seek blocks", arg, 0, LLONG_MAX);