fs/ioctl: add BIOC_BLKGETSIZE cmd to get block sector numbers
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
This commit is contained in:
parent
29ddfd44a0
commit
d8f316b998
@ -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;
|
*(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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,6 +305,12 @@
|
|||||||
* to return sector size.
|
* to return sector size.
|
||||||
* OUT: Data return in user-provided
|
* OUT: Data return in user-provided
|
||||||
* buffer. */
|
* 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 ***************************************/
|
/* NuttX MTD driver ioctl definitions ***************************************/
|
||||||
|
|
||||||
|
@ -32,7 +32,8 @@
|
|||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define BLKSSZGET BIOC_BLKSSZGET
|
#define BLKSSZGET BIOC_BLKSSZGET
|
||||||
|
#define BLKGETSIZE BIOC_BLKGETSIZE
|
||||||
|
|
||||||
/* Mount flags */
|
/* Mount flags */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user