version 1.9, 2010/04/03 17:40:33 |
version 1.10, 2010/04/03 17:59:17 |
|
|
|
|
close(f->fd); |
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; |
|
} |
|