return 0;
}
+ /* H1: reject aio_read on O_WRONLY fd (except char devices) */
+ if (!is_write && (f->flags & 3U) == 1U && f->node->flags != FS_CHARDEVICE) {
+ cb.aio_error = EBADF;
+ cb.aio_return = -EBADF;
+ (void)copy_to_user(user_cb, &cb, sizeof(cb));
+ return 0;
+ }
+
+ /* H1: reject aio_write on O_RDONLY fd (except char devices) */
+ if (is_write && (f->flags & 3U) == 0U && f->node->flags != FS_CHARDEVICE) {
+ cb.aio_error = EBADF;
+ cb.aio_return = -EBADF;
+ (void)copy_to_user(user_cb, &cb, sizeof(cb));
+ return 0;
+ }
+
+ /* H1: reject aio_write on MS_RDONLY mount */
+ if (is_write && f->mount_root && (vfs_node_mount_flags(f->mount_root) & MS_RDONLY)) {
+ cb.aio_error = EROFS;
+ cb.aio_return = -EROFS;
+ (void)copy_to_user(user_cb, &cb, sizeof(cb));
+ return 0;
+ }
+
if (!cb.aio_buf || cb.aio_nbytes == 0) {
cb.aio_error = 0;
cb.aio_return = 0;
// C24: aio_read/aio_write smoke
{
- int fd = sys_open("/tmp/aiotest", O_CREAT | O_TRUNC | 1);
+ int fd = sys_open("/tmp/aiotest", O_CREAT | O_TRUNC | 2);
if (fd < 0) {
sys_write(1, "[test] aio open failed\n", (uint32_t)(sizeof("[test] aio open failed\n") - 1));
sys_exit(1);