summaryrefslogtreecommitdiff
path: root/usr.bin/aucat/pipe.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/aucat/pipe.c')
-rw-r--r--usr.bin/aucat/pipe.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/usr.bin/aucat/pipe.c b/usr.bin/aucat/pipe.c
index 76f98baa832..065f6f0ad7a 100644
--- a/usr.bin/aucat/pipe.c
+++ b/usr.bin/aucat/pipe.c
@@ -139,3 +139,54 @@ pipe_close(struct file *file)
close(f->fd);
}
+
+off_t
+pipe_endpos(struct file *file)
+{
+ struct pipe *f = (struct pipe *)file;
+ off_t pos;
+
+ pos = lseek(f->fd, 0, SEEK_END);
+ if (pos < 0) {
+#ifdef DEBUG
+ file_dbg(&f->file);
+ dbg_puts(": couldn't get file size\n");
+#endif
+ return 0;
+ }
+ return pos;
+}
+
+int
+pipe_seek(struct file *file, off_t pos)
+{
+ struct pipe *f = (struct pipe *)file;
+ off_t newpos;
+
+ newpos = lseek(f->fd, pos, SEEK_SET);
+ if (newpos < 0) {
+#ifdef DEBUG
+ file_dbg(&f->file);
+ dbg_puts(": couldn't seek\n");
+#endif
+ /* XXX: call eof() */
+ return 0;
+ }
+ return 1;
+}
+
+int
+pipe_trunc(struct file *file, off_t pos)
+{
+ struct pipe *f = (struct pipe *)file;
+
+ if (ftruncate(f->fd, pos) < 0) {
+#ifdef DEBUG
+ file_dbg(&f->file);
+ dbg_puts(": couldn't truncate file\n");
+#endif
+ /* XXX: call hup() */
+ return 0;
+ }
+ return 1;
+}