]> git.draconx.ca Git - liblbx.git/commitdiff
liblbx: Don't ignore whence parameter in pipe_seek.
authorNick Bowler <nbowler@draconx.ca>
Thu, 4 Feb 2010 16:47:18 +0000 (11:47 -0500)
committerNick Bowler <nbowler@draconx.ca>
Mon, 8 Feb 2010 17:00:54 +0000 (12:00 -0500)
The code from which this derived only supported SEEK_SET-like
operations, so SEEK_CUR was forgotten when converting it.
SEEK_END obviously cannot be supported on pipes.

src/fops.c

index 2ae6c61fc3658117b47485ce8a92981837d116d7..834c8b2e776ef0f7c22bdd0ff3b3cc080ced3e04 100644 (file)
@@ -66,7 +66,18 @@ static int pipe_seek(void *handle, long offset, int whence)
        struct lbx_pipe_state *state = handle;
        long distance;
 
-       distance = offset - state->offset;
+       switch (whence) {
+       case SEEK_SET:
+               distance = offset - state->offset;
+               break;
+       case SEEK_CUR:
+               distance = offset;
+               break;
+       case SEEK_END:
+               distance = -1;
+               break;
+       }
+
        if (distance < 0)
                return -1;