From bd2c91d4a3c37b8cee018dd600459d58228ddd0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Fri, 17 Apr 2015 11:22:49 +0200 Subject: [PATCH] Packed/unpacked st_rdev transported as 32-bits on OpenIndiana 64-bits On OpenIndiana 64-bits, st_rdev has major and minor as 32-bits wide each, but the fuse protocol (common to 32-bit and 64-bit) has an st_rdev field limited to 32-bit. For now, pack major and minor the same way as in the 32-bit variant (14 and 18 bits). --- libfuse-lite/fuse_lowlevel.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/libfuse-lite/fuse_lowlevel.c b/libfuse-lite/fuse_lowlevel.c index ee01c7c1..496800e7 100644 --- a/libfuse-lite/fuse_lowlevel.c +++ b/libfuse-lite/fuse_lowlevel.c @@ -69,7 +69,13 @@ static void convert_stat(const struct stat *stbuf, struct fuse_attr *attr) attr->nlink = stbuf->st_nlink; attr->uid = stbuf->st_uid; attr->gid = stbuf->st_gid; +#if defined(__SOLARIS__) && defined(_LP64) + /* Must pack the device the old way (attr->rdev limited to 32 bits) */ + attr->rdev = ((major(stbuf->st_rdev) & 0x3fff) << 18) + | (minor(stbuf->st_rdev) & 0x3ffff); +#else attr->rdev = stbuf->st_rdev; +#endif attr->size = stbuf->st_size; attr->blocks = stbuf->st_blocks; attr->atime = stbuf->st_atime; @@ -553,9 +559,16 @@ static void do_mknod(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) else name = (const char *) inarg + FUSE_COMPAT_MKNOD_IN_SIZE; - if (req->f->op.mknod) + if (req->f->op.mknod) { +#if defined(__SOLARIS__) && defined(_LP64) + /* Must unpack the device, as arg->rdev is limited to 32 bits */ + req->f->op.mknod(req, nodeid, name, arg->mode, + makedev((arg->rdev >> 18) & 0x3ffff, + arg->rdev & 0x3fff)); +#else req->f->op.mknod(req, nodeid, name, arg->mode, arg->rdev); - else +#endif + } else fuse_reply_err(req, ENOSYS); }