diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/lib/brand/lx/lx_brand/common/dir.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/usr/src/lib/brand/lx/lx_brand/common/dir.c b/usr/src/lib/brand/lx/lx_brand/common/dir.c index 72c51d5188..fc0d2c9a0d 100644 --- a/usr/src/lib/brand/lx/lx_brand/common/dir.c +++ b/usr/src/lib/brand/lx/lx_brand/common/dir.c @@ -52,6 +52,14 @@ struct lx_dirent { uchar_t d_type; }; +/* base definition of linux_dirent from readdir.c - sizeof is 12 */ +typedef struct { + ulong_t d_ino; + ulong_t d_off; + ushort_t d_reclen; + char d_name[1]; +} lx_linux_dirent_t; + #define LX_RECLEN(namelen) \ ((offsetof(struct lx_dirent, d_name) + 1 + (namelen) + 7) & ~7) @@ -109,7 +117,7 @@ lx_readdir(uintptr_t p1, uintptr_t p2, uintptr_t p3) int lx_getdents(uintptr_t p1, uintptr_t p2, uintptr_t p3) { - int fd = (uint_t)p1; + int fd = (int)p1; void *buf = (void *)p2; void *sbuf, *lbuf; int lbufsz = (uint_t)p3; @@ -119,6 +127,14 @@ lx_getdents(uintptr_t p1, uintptr_t p2, uintptr_t p3) struct lx_dirent *ld; int bytes, rc; + /* + * readdir will pass in the full size, but some test code calls getdents + * directly and uses the bare struct. For these, just pretend we got + * a single full-size entry so we can obtain the proper errno. + */ + if (lbufsz == sizeof (lx_linux_dirent_t)) + lbufsz = sizeof (struct lx_dirent); + if (lbufsz < sizeof (struct lx_dirent)) return (-EINVAL); |