int device_open( rtems_libio_t *iop, const char *pathname, uint32_t flag, uint32_t mode ) { rtems_libio_open_close_args_t args; rtems_status_code status; IMFS_jnode_t *the_jnode; the_jnode = iop->file_info; args.iop = iop; args.flags = iop->flags; args.mode = mode; status = rtems_io_open( the_jnode->info.device.major, the_jnode->info.device.minor, (void *) &args ); if ( status ) return rtems_deviceio_errno(status); return 0; }
static ssize_t rtems_rfs_rtems_device_write (rtems_libio_t* iop, const void* buffer, size_t count) { rtems_libio_rw_args_t args; rtems_status_code status; int major; int minor; major = (int) iop->data0; minor = (intptr_t) iop->data1; args.iop = iop; args.offset = iop->offset; args.buffer = (void *) buffer; args.count = count; args.flags = iop->flags; args.bytes_moved = 0; status = rtems_io_write (major, minor, (void *) &args); if (status) return rtems_deviceio_errno (status); return (ssize_t) args.bytes_moved; }
int device_ioctl( rtems_libio_t *iop, uint32_t command, void *buffer ) { rtems_libio_ioctl_args_t args; rtems_status_code status; IMFS_jnode_t *the_jnode; args.iop = iop; args.command = command; args.buffer = buffer; the_jnode = iop->file_info; status = rtems_io_control( the_jnode->info.device.major, the_jnode->info.device.minor, (void *) &args ); if ( status ) return rtems_deviceio_errno(status); return args.ioctl_return; }
ssize_t device_write( rtems_libio_t *iop, const void *buffer, size_t count ) { rtems_libio_rw_args_t args; rtems_status_code status; IMFS_jnode_t *the_jnode; the_jnode = iop->file_info; args.iop = iop; args.offset = iop->offset; args.buffer = (void *) buffer; args.count = count; args.flags = iop->flags; args.bytes_moved = 0; status = rtems_io_write( the_jnode->info.device.major, the_jnode->info.device.minor, (void *) &args ); if ( status ) return rtems_deviceio_errno(status); return (ssize_t) args.bytes_moved; }
int devFS_ioctl( rtems_libio_t *iop, uint32_t command, void *buffer ) { rtems_libio_ioctl_args_t args; rtems_status_code status; rtems_device_name_t *np; np = (rtems_device_name_t *)iop->file_info; args.iop = iop; args.command = command; args.buffer = buffer; status = rtems_io_control( np->major, np->minor, (void *) &args ); if ( status ) return rtems_deviceio_errno(status); return args.ioctl_return; }
/** * This handler maps an open() operation onto rtems_io_open(). * * @param iop * @param pathname * @param flag * @param mode * @return int */ static int rtems_rfs_rtems_device_open ( rtems_libio_t *iop, const char *pathname, uint32_t flag, uint32_t mode) { rtems_libio_open_close_args_t args; rtems_rfs_file_system* fs = rtems_rfs_rtems_pathloc_dev (&iop->pathinfo); rtems_rfs_ino ino = rtems_rfs_rtems_get_iop_ino (iop); rtems_rfs_inode_handle inode; int major; int minor; rtems_status_code status; int rc; rtems_rfs_rtems_lock (fs); rc = rtems_rfs_inode_open (fs, ino, &inode, true); if (rc > 0) { rtems_rfs_rtems_unlock (fs); return rtems_rfs_rtems_error ("device_open: opening inode", rc); } major = rtems_rfs_inode_get_block (&inode, 0); minor = rtems_rfs_inode_get_block (&inode, 1); rc = rtems_rfs_inode_close (fs, &inode); if (rc > 0) { rtems_rfs_rtems_unlock (fs); return rtems_rfs_rtems_error ("device_open: closing inode", rc); } rtems_rfs_rtems_unlock (fs); iop->data0 = major; iop->data1 = (void*)((intptr_t) minor); args.iop = iop; args.flags = iop->flags; args.mode = mode; status = rtems_io_open (major, minor, (void *) &args); if (status) return rtems_deviceio_errno(status); return 0; }
static int rtems_rfs_rtems_device_close (rtems_libio_t* iop) { rtems_libio_open_close_args_t args; rtems_status_code status; int major; int minor; major = (int) iop->data0; minor = (intptr_t) iop->data1; args.iop = iop; args.flags = 0; args.mode = 0; status = rtems_io_close (major, minor, (void *) &args); if (status) return rtems_deviceio_errno (status); return 0; }
static int rtems_rfs_rtems_device_ioctl (rtems_libio_t* iop, uint32_t command, void* buffer) { rtems_libio_ioctl_args_t args; rtems_status_code status; int major; int minor; major = (int) iop->data0; minor = (intptr_t) iop->data1; args.iop = iop; args.command = command; args.buffer = buffer; status = rtems_io_control (major, minor, (void *) &args); if (status) return rtems_deviceio_errno (status); return args.ioctl_return; }
int devFS_close( rtems_libio_t *iop ) { rtems_libio_open_close_args_t args; rtems_status_code status; rtems_device_name_t *np; np = (rtems_device_name_t *)iop->file_info; args.iop = iop; args.flags = 0; args.mode = 0; status = rtems_io_close( np->major, np->minor, (void *) &args ); if ( status ) { return rtems_deviceio_errno(status); } return 0; }
int device_close( rtems_libio_t *iop ) { rtems_libio_open_close_args_t args; rtems_status_code status; IMFS_jnode_t *the_jnode; the_jnode = iop->file_info; args.iop = iop; args.flags = 0; args.mode = 0; status = rtems_io_close( the_jnode->info.device.major, the_jnode->info.device.minor, (void *) &args ); if ( status ) { return rtems_deviceio_errno(status); } return 0; }