summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-02-22 22:32:20 -0800
committerH. Peter Anvin <hpa@zytor.com>2008-02-22 22:32:20 -0800
commitd830eea389349bebee7834911e3e2f58fca9a0ee (patch)
treeee62f8ca057c8729854edb7ee917022df36995b9
parent0fa6cb3b1e1e5916b5b715679377de53b5d78e6e (diff)
downloadsyslinux-d830eea389349bebee7834911e3e2f58fca9a0ee.tar.gz
fstat(): report files of unknown length as sockets
-rw-r--r--com32/lib/sys/fstat.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/com32/lib/sys/fstat.c b/com32/lib/sys/fstat.c
index 3a42ab85..ef5e20dc 100644
--- a/com32/lib/sys/fstat.c
+++ b/com32/lib/sys/fstat.c
@@ -45,8 +45,15 @@ int fstat(int fd, struct stat *buf)
}
if ( fp->iop->flags & __DEV_FILE ) {
- buf->st_mode = S_IFREG | 0444;
- buf->st_size = fp->i.length;
+ if ( fp->i.length == (uint32_t)-1 ) {
+ /* File of unknown length, report it as a socket
+ (it probably really is, anyway!) */
+ buf->st_mode = S_IFSOCK | 0444;
+ buf->st_size = 0;
+ } else {
+ buf->st_mode = S_IFREG | 0444;
+ buf->st_size = fp->i.length;
+ }
} else {
buf->st_mode = S_IFCHR | 0666;
buf->st_size = 0;