aio.c (e3ee1e123183ca9847e74b7b8e2694c9e3b817a6) aio.c (002c8976ee537724b20a5e179d9b349309438836)
1/*
2 * An async IO implementation for Linux
3 * Written by Benjamin LaHaise <bcrl@kvack.org>
4 *
5 * Implements an efficient asynchronous io interface.
6 *
7 * Copyright 2000, 2001, 2002 Red Hat, Inc. All Rights Reserved.
8 *

--- 1256 unchanged lines hidden (view full) ---

1265 * handle. May fail with -EINVAL if *ctxp is not initialized,
1266 * if the specified nr_events exceeds internal limits. May fail
1267 * with -EAGAIN if the specified nr_events exceeds the user's limit
1268 * of available events. May fail with -ENOMEM if insufficient kernel
1269 * resources are available. May fail with -EFAULT if an invalid
1270 * pointer is passed for ctxp. Will fail with -ENOSYS if not
1271 * implemented.
1272 */
1/*
2 * An async IO implementation for Linux
3 * Written by Benjamin LaHaise <bcrl@kvack.org>
4 *
5 * Implements an efficient asynchronous io interface.
6 *
7 * Copyright 2000, 2001, 2002 Red Hat, Inc. All Rights Reserved.
8 *

--- 1256 unchanged lines hidden (view full) ---

1265 * handle. May fail with -EINVAL if *ctxp is not initialized,
1266 * if the specified nr_events exceeds internal limits. May fail
1267 * with -EAGAIN if the specified nr_events exceeds the user's limit
1268 * of available events. May fail with -ENOMEM if insufficient kernel
1269 * resources are available. May fail with -EFAULT if an invalid
1270 * pointer is passed for ctxp. Will fail with -ENOSYS if not
1271 * implemented.
1272 */
1273asmlinkage long sys_io_setup(unsigned nr_events, aio_context_t __user *ctxp)
1273SYSCALL_DEFINE2(io_setup, unsigned, nr_events, aio_context_t __user *, ctxp)
1274{
1275 struct kioctx *ioctx = NULL;
1276 unsigned long ctx;
1277 long ret;
1278
1279 ret = get_user(ctx, ctxp);
1280 if (unlikely(ret))
1281 goto out;

--- 21 unchanged lines hidden (view full) ---

1303}
1304
1305/* sys_io_destroy:
1306 * Destroy the aio_context specified. May cancel any outstanding
1307 * AIOs and block on completion. Will fail with -ENOSYS if not
1308 * implemented. May fail with -EFAULT if the context pointed to
1309 * is invalid.
1310 */
1274{
1275 struct kioctx *ioctx = NULL;
1276 unsigned long ctx;
1277 long ret;
1278
1279 ret = get_user(ctx, ctxp);
1280 if (unlikely(ret))
1281 goto out;

--- 21 unchanged lines hidden (view full) ---

1303}
1304
1305/* sys_io_destroy:
1306 * Destroy the aio_context specified. May cancel any outstanding
1307 * AIOs and block on completion. Will fail with -ENOSYS if not
1308 * implemented. May fail with -EFAULT if the context pointed to
1309 * is invalid.
1310 */
1311asmlinkage long sys_io_destroy(aio_context_t ctx)
1311SYSCALL_DEFINE1(io_destroy, aio_context_t, ctx)
1312{
1313 struct kioctx *ioctx = lookup_ioctx(ctx);
1314 if (likely(NULL != ioctx)) {
1315 io_destroy(ioctx);
1316 return 0;
1317 }
1318 pr_debug("EINVAL: io_destroy: invalid context id\n");
1319 return -EINVAL;

--- 337 unchanged lines hidden (view full) ---

1657 * *iocbpp[0] is not properly initialized, if the operation specified
1658 * is invalid for the file descriptor in the iocb. May fail with
1659 * -EFAULT if any of the data structures point to invalid data. May
1660 * fail with -EBADF if the file descriptor specified in the first
1661 * iocb is invalid. May fail with -EAGAIN if insufficient resources
1662 * are available to queue any iocbs. Will return 0 if nr is 0. Will
1663 * fail with -ENOSYS if not implemented.
1664 */
1312{
1313 struct kioctx *ioctx = lookup_ioctx(ctx);
1314 if (likely(NULL != ioctx)) {
1315 io_destroy(ioctx);
1316 return 0;
1317 }
1318 pr_debug("EINVAL: io_destroy: invalid context id\n");
1319 return -EINVAL;

--- 337 unchanged lines hidden (view full) ---

1657 * *iocbpp[0] is not properly initialized, if the operation specified
1658 * is invalid for the file descriptor in the iocb. May fail with
1659 * -EFAULT if any of the data structures point to invalid data. May
1660 * fail with -EBADF if the file descriptor specified in the first
1661 * iocb is invalid. May fail with -EAGAIN if insufficient resources
1662 * are available to queue any iocbs. Will return 0 if nr is 0. Will
1663 * fail with -ENOSYS if not implemented.
1664 */
1665asmlinkage long sys_io_submit(aio_context_t ctx_id, long nr,
1666 struct iocb __user * __user *iocbpp)
1665SYSCALL_DEFINE3(io_submit, aio_context_t, ctx_id, long, nr,
1666 struct iocb __user * __user *, iocbpp)
1667{
1668 struct kioctx *ctx;
1669 long ret = 0;
1670 int i;
1671
1672 if (unlikely(nr < 0))
1673 return -EINVAL;
1674

--- 57 unchanged lines hidden (view full) ---

1732 * the operation is successfully cancelled, the resulting event is
1733 * copied into the memory pointed to by result without being placed
1734 * into the completion queue and 0 is returned. May fail with
1735 * -EFAULT if any of the data structures pointed to are invalid.
1736 * May fail with -EINVAL if aio_context specified by ctx_id is
1737 * invalid. May fail with -EAGAIN if the iocb specified was not
1738 * cancelled. Will fail with -ENOSYS if not implemented.
1739 */
1667{
1668 struct kioctx *ctx;
1669 long ret = 0;
1670 int i;
1671
1672 if (unlikely(nr < 0))
1673 return -EINVAL;
1674

--- 57 unchanged lines hidden (view full) ---

1732 * the operation is successfully cancelled, the resulting event is
1733 * copied into the memory pointed to by result without being placed
1734 * into the completion queue and 0 is returned. May fail with
1735 * -EFAULT if any of the data structures pointed to are invalid.
1736 * May fail with -EINVAL if aio_context specified by ctx_id is
1737 * invalid. May fail with -EAGAIN if the iocb specified was not
1738 * cancelled. Will fail with -ENOSYS if not implemented.
1739 */
1740asmlinkage long sys_io_cancel(aio_context_t ctx_id, struct iocb __user *iocb,
1741 struct io_event __user *result)
1740SYSCALL_DEFINE3(io_cancel, aio_context_t, ctx_id, struct iocb __user *, iocb,
1741 struct io_event __user *, result)
1742{
1743 int (*cancel)(struct kiocb *iocb, struct io_event *res);
1744 struct kioctx *ctx;
1745 struct kiocb *kiocb;
1746 u32 key;
1747 int ret;
1748
1749 ret = get_user(key, &iocb->aio_key);

--- 44 unchanged lines hidden (view full) ---

1794 * if nr is out of range, if when is out of range. May fail with
1795 * -EFAULT if any of the memory specified to is invalid. May return
1796 * 0 or < min_nr if no events are available and the timeout specified
1797 * by when has elapsed, where when == NULL specifies an infinite
1798 * timeout. Note that the timeout pointed to by when is relative and
1799 * will be updated if not NULL and the operation blocks. Will fail
1800 * with -ENOSYS if not implemented.
1801 */
1742{
1743 int (*cancel)(struct kiocb *iocb, struct io_event *res);
1744 struct kioctx *ctx;
1745 struct kiocb *kiocb;
1746 u32 key;
1747 int ret;
1748
1749 ret = get_user(key, &iocb->aio_key);

--- 44 unchanged lines hidden (view full) ---

1794 * if nr is out of range, if when is out of range. May fail with
1795 * -EFAULT if any of the memory specified to is invalid. May return
1796 * 0 or < min_nr if no events are available and the timeout specified
1797 * by when has elapsed, where when == NULL specifies an infinite
1798 * timeout. Note that the timeout pointed to by when is relative and
1799 * will be updated if not NULL and the operation blocks. Will fail
1800 * with -ENOSYS if not implemented.
1801 */
1802asmlinkage long sys_io_getevents(aio_context_t ctx_id,
1803 long min_nr,
1804 long nr,
1805 struct io_event __user *events,
1806 struct timespec __user *timeout)
1802SYSCALL_DEFINE5(io_getevents, aio_context_t, ctx_id,
1803 long, min_nr,
1804 long, nr,
1805 struct io_event __user *, events,
1806 struct timespec __user *, timeout)
1807{
1808 struct kioctx *ioctx = lookup_ioctx(ctx_id);
1809 long ret = -EINVAL;
1810
1811 if (likely(ioctx)) {
1812 if (likely(min_nr <= nr && min_nr >= 0 && nr >= 0))
1813 ret = read_events(ioctx, min_nr, nr, events, timeout);
1814 put_ioctx(ioctx);
1815 }
1816
1817 asmlinkage_protect(5, ret, ctx_id, min_nr, nr, events, timeout);
1818 return ret;
1819}
1820
1821__initcall(aio_setup);
1822
1823EXPORT_SYMBOL(aio_complete);
1824EXPORT_SYMBOL(aio_put_req);
1825EXPORT_SYMBOL(wait_on_sync_kiocb);
1807{
1808 struct kioctx *ioctx = lookup_ioctx(ctx_id);
1809 long ret = -EINVAL;
1810
1811 if (likely(ioctx)) {
1812 if (likely(min_nr <= nr && min_nr >= 0 && nr >= 0))
1813 ret = read_events(ioctx, min_nr, nr, events, timeout);
1814 put_ioctx(ioctx);
1815 }
1816
1817 asmlinkage_protect(5, ret, ctx_id, min_nr, nr, events, timeout);
1818 return ret;
1819}
1820
1821__initcall(aio_setup);
1822
1823EXPORT_SYMBOL(aio_complete);
1824EXPORT_SYMBOL(aio_put_req);
1825EXPORT_SYMBOL(wait_on_sync_kiocb);