diff --git a/fs/vfs/fs_ioctl.c b/fs/vfs/fs_ioctl.c index dfd2b038011af..97e098132f292 100644 --- a/fs/vfs/fs_ioctl.c +++ b/fs/vfs/fs_ioctl.c @@ -139,6 +139,22 @@ static int file_vioctl(FAR struct file *filep, int req, va_list ap) *(FAR blksize_t *)(uintptr_t)arg = geo.geo_sectorsize; } } + break; + + case BIOC_BLKGETSIZE: + if (ret == -ENOTTY && inode->u.i_ops != NULL && + inode->u.i_ops->ioctl != NULL) + { + struct geometry geo; + ret = inode->u.i_ops->ioctl(filep, BIOC_GEOMETRY, + (unsigned long)(uintptr_t)&geo); + if (ret >= 0) + { + *(FAR blksize_t *)(uintptr_t)arg = geo.geo_nsectors; + } + } + break; + #endif } diff --git a/include/nuttx/fs/ioctl.h b/include/nuttx/fs/ioctl.h index 1ccf37cf232bf..dd70cc634bf43 100644 --- a/include/nuttx/fs/ioctl.h +++ b/include/nuttx/fs/ioctl.h @@ -305,6 +305,12 @@ * to return sector size. * OUT: Data return in user-provided * buffer. */ +#define BIOC_BLKGETSIZE _BIOC(0x0010) /* Get block device sector numbers. + * IN: Pointer to writable instance + * of sector numbers in which + * to return sector numbers. + * OUT: Data return in user-provided + * buffer. */ /* NuttX MTD driver ioctl definitions ***************************************/ diff --git a/include/sys/mount.h b/include/sys/mount.h index c23e9246f6e53..7796dc3e7ac0e 100644 --- a/include/sys/mount.h +++ b/include/sys/mount.h @@ -32,7 +32,8 @@ * Pre-processor Definitions ****************************************************************************/ -#define BLKSSZGET BIOC_BLKSSZGET +#define BLKSSZGET BIOC_BLKSSZGET +#define BLKGETSIZE BIOC_BLKGETSIZE /* Mount flags */