-/*
- * -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
* GPL HEADER START
* in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see [sun.com URL with a
- * copy of GPLv2].
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
#include "console.h"
int
-lst_session_new_ioctl(lstio_session_new_args_t *args)
+lst_session_new_ioctl(lstio_session_new_args_t *args)
{
char *name;
int rc;
args->lstio_ses_nmlen <= 0 ||
args->lstio_ses_nmlen > LST_NAME_SIZE)
return -EINVAL;
-
+
LIBCFS_ALLOC(name, args->lstio_ses_nmlen + 1);
if (name == NULL)
return -ENOMEM;
-
- if (copy_from_user(name,
- args->lstio_ses_namep,
- args->lstio_ses_nmlen)) {
+
+ if (cfs_copy_from_user(name,
+ args->lstio_ses_namep,
+ args->lstio_ses_nmlen)) {
LIBCFS_FREE(name, args->lstio_ses_nmlen + 1);
return -EFAULT;
}
-
+
name[args->lstio_ses_nmlen] = 0;
-
+
rc = lstcon_session_new(name,
args->lstio_ses_key,
args->lstio_ses_timeout,
args->lstio_ses_force,
args->lstio_ses_idp);
-
+
LIBCFS_FREE(name, args->lstio_ses_nmlen + 1);
return rc;
if (name == NULL)
return -ENOMEM;
- if (copy_from_user(name, args->lstio_dbg_namep,
- args->lstio_dbg_nmlen)) {
+ if (cfs_copy_from_user(name, args->lstio_dbg_namep,
+ args->lstio_dbg_nmlen)) {
LIBCFS_FREE(name, args->lstio_dbg_nmlen + 1);
return -EFAULT;
if (name == NULL)
return -ENOMEM;
- if (copy_from_user(name,
- args->lstio_grp_namep,
- args->lstio_grp_nmlen)) {
+ if (cfs_copy_from_user(name,
+ args->lstio_grp_namep,
+ args->lstio_grp_nmlen)) {
LIBCFS_FREE(name, args->lstio_grp_nmlen);
return -EFAULT;
}
if (args->lstio_grp_key != console_session.ses_key)
return -EACCES;
-
+
if (args->lstio_grp_namep == NULL ||
- args->lstio_grp_nmlen <= 0 ||
+ args->lstio_grp_nmlen <= 0 ||
args->lstio_grp_nmlen > LST_NAME_SIZE)
return -EINVAL;
if (name == NULL)
return -ENOMEM;
- if (copy_from_user(name,
- args->lstio_grp_namep,
- args->lstio_grp_nmlen)) {
+ if (cfs_copy_from_user(name,
+ args->lstio_grp_namep,
+ args->lstio_grp_nmlen)) {
LIBCFS_FREE(name, args->lstio_grp_nmlen + 1);
return -EFAULT;
}
if (name == NULL)
return -ENOMEM;
- if (copy_from_user(name,
+ if (cfs_copy_from_user(name,
args->lstio_grp_namep,
args->lstio_grp_nmlen)) {
LIBCFS_FREE(name, args->lstio_grp_nmlen + 1);
}
LIBCFS_FREE(name, args->lstio_grp_nmlen + 1);
-
+
return rc;
}
if (name == NULL)
return -ENOMEM;
- if (copy_from_user(name, args->lstio_grp_namep,
- args->lstio_grp_nmlen)) {
+ if (cfs_copy_from_user(name, args->lstio_grp_namep,
+ args->lstio_grp_nmlen)) {
LIBCFS_FREE(name, args->lstio_grp_nmlen + 1);
return -EFAULT;
if (args->lstio_grp_idxp == NULL || /* node index */
args->lstio_grp_ndentp == NULL) /* # of node entry */
return -EINVAL;
-
- if (copy_from_user(&ndent,
- args->lstio_grp_ndentp, sizeof(ndent)) ||
- copy_from_user(&index, args->lstio_grp_idxp, sizeof(index)))
+
+ if (cfs_copy_from_user(&ndent, args->lstio_grp_ndentp,
+ sizeof(ndent)) ||
+ cfs_copy_from_user(&index, args->lstio_grp_idxp,
+ sizeof(index)))
return -EFAULT;
if (ndent <= 0 || index < 0)
if (name == NULL)
return -ENOMEM;
- if (copy_from_user(name,
- args->lstio_grp_namep,
- args->lstio_grp_nmlen)) {
+ if (cfs_copy_from_user(name,
+ args->lstio_grp_namep,
+ args->lstio_grp_nmlen)) {
LIBCFS_FREE(name, args->lstio_grp_nmlen + 1);
return -EFAULT;
}
return rc;
if (args->lstio_grp_dentsp != NULL &&
- (copy_to_user(args->lstio_grp_idxp, &index, sizeof(index)) ||
- copy_to_user(args->lstio_grp_ndentp, &ndent, sizeof(ndent))))
+ (cfs_copy_to_user(args->lstio_grp_idxp, &index, sizeof(index)) ||
+ cfs_copy_to_user(args->lstio_grp_ndentp, &ndent, sizeof(ndent))))
rc = -EFAULT;
return 0;
if (name == NULL)
return -ENOMEM;
- if (copy_from_user(name,
- args->lstio_bat_namep,
- args->lstio_bat_nmlen)) {
+ if (cfs_copy_from_user(name,
+ args->lstio_bat_namep,
+ args->lstio_bat_nmlen)) {
LIBCFS_FREE(name, args->lstio_bat_nmlen + 1);
return -EFAULT;
}
if (name == NULL)
return -ENOMEM;
- if (copy_from_user(name,
- args->lstio_bat_namep,
- args->lstio_bat_nmlen)) {
+ if (cfs_copy_from_user(name,
+ args->lstio_bat_namep,
+ args->lstio_bat_nmlen)) {
LIBCFS_FREE(name, args->lstio_bat_nmlen + 1);
return -EFAULT;
}
if (name == NULL)
return -ENOMEM;
- if (copy_from_user(name,
- args->lstio_bat_namep,
- args->lstio_bat_nmlen)) {
+ if (cfs_copy_from_user(name,
+ args->lstio_bat_namep,
+ args->lstio_bat_nmlen)) {
LIBCFS_FREE(name, args->lstio_bat_nmlen + 1);
return -EFAULT;
}
if (name == NULL)
return -ENOMEM;
- if (copy_from_user(name,
- args->lstio_bat_namep,
- args->lstio_bat_nmlen)) {
+ if (cfs_copy_from_user(name,
+ args->lstio_bat_namep,
+ args->lstio_bat_nmlen)) {
LIBCFS_FREE(name, args->lstio_bat_nmlen + 1);
return -EFAULT;
}
if (args->lstio_bat_idxp == NULL || /* node index */
args->lstio_bat_ndentp == NULL) /* # of node entry */
return -EINVAL;
-
- if (copy_from_user(&index, args->lstio_bat_idxp, sizeof(index)) ||
- copy_from_user(&ndent, args->lstio_bat_ndentp, sizeof(ndent)))
+
+ if (cfs_copy_from_user(&index, args->lstio_bat_idxp,
+ sizeof(index)) ||
+ cfs_copy_from_user(&ndent, args->lstio_bat_ndentp,
+ sizeof(ndent)))
return -EFAULT;
if (ndent <= 0 || index < 0)
if (name == NULL)
return -ENOMEM;
- if (copy_from_user(name,
- args->lstio_bat_namep, args->lstio_bat_nmlen)) {
+ if (cfs_copy_from_user(name,
+ args->lstio_bat_namep, args->lstio_bat_nmlen)) {
LIBCFS_FREE(name, args->lstio_bat_nmlen + 1);
return -EFAULT;
}
return rc;
if (args->lstio_bat_dentsp != NULL &&
- (copy_to_user(args->lstio_bat_idxp, &index, sizeof(index)) ||
- copy_to_user(args->lstio_bat_ndentp, &ndent, sizeof(ndent))))
+ (cfs_copy_to_user(args->lstio_bat_idxp, &index, sizeof(index)) ||
+ cfs_copy_to_user(args->lstio_bat_ndentp, &ndent, sizeof(ndent))))
rc = -EFAULT;
return rc;
if (name == NULL)
return -ENOMEM;
- if (copy_from_user(name, args->lstio_sta_namep,
- args->lstio_sta_nmlen)) {
+ if (cfs_copy_from_user(name, args->lstio_sta_namep,
+ args->lstio_sta_nmlen)) {
LIBCFS_FREE(name, args->lstio_sta_nmlen + 1);
return -EFAULT;
}
}
rc = -EFAULT;
- if (copy_from_user(name,
- args->lstio_tes_bat_name,
- args->lstio_tes_bat_nmlen) ||
- copy_from_user(srcgrp,
- args->lstio_tes_sgrp_name,
- args->lstio_tes_sgrp_nmlen) ||
- copy_from_user(dstgrp,
- args->lstio_tes_dgrp_name,
- args->lstio_tes_dgrp_nmlen) ||
- copy_from_user(param, args->lstio_tes_param,
- args->lstio_tes_param_len))
+ if (cfs_copy_from_user(name,
+ args->lstio_tes_bat_name,
+ args->lstio_tes_bat_nmlen) ||
+ cfs_copy_from_user(srcgrp,
+ args->lstio_tes_sgrp_name,
+ args->lstio_tes_sgrp_nmlen) ||
+ cfs_copy_from_user(dstgrp,
+ args->lstio_tes_dgrp_name,
+ args->lstio_tes_dgrp_nmlen) ||
+ cfs_copy_from_user(param, args->lstio_tes_param,
+ args->lstio_tes_param_len))
goto out;
rc = lstcon_test_add(name,
&ret, args->lstio_tes_resultp);
if (ret != 0)
- rc = (copy_to_user(args->lstio_tes_retp, &ret, sizeof(ret))) ?
- -EFAULT : 0;
+ rc = (cfs_copy_to_user(args->lstio_tes_retp, &ret,
+ sizeof(ret))) ? -EFAULT : 0;
out:
if (name != NULL)
LIBCFS_FREE(name, args->lstio_tes_bat_nmlen + 1);
return -ENOMEM;
/* copy in parameter */
- if (copy_from_user(buf, data->ioc_pbuf1, data->ioc_plen1)) {
+ if (cfs_copy_from_user(buf, data->ioc_pbuf1, data->ioc_plen1)) {
LIBCFS_FREE(buf, data->ioc_plen1);
return -EFAULT;
}
- mutex_down(&console_session.ses_mutex);
+ cfs_mutex_down(&console_session.ses_mutex);
console_session.ses_laststamp = cfs_time_current_sec();
}
memset(&console_session.ses_trans_stat, 0, sizeof(lstcon_trans_stat_t));
-
+
switch (opc) {
case LSTIO_SESSION_NEW:
rc = lst_session_new_ioctl((lstio_session_new_args_t *)buf);
rc = -EINVAL;
}
- if (copy_to_user(data->ioc_pbuf2, &console_session.ses_trans_stat,
- sizeof(lstcon_trans_stat_t)))
+ if (cfs_copy_to_user(data->ioc_pbuf2, &console_session.ses_trans_stat,
+ sizeof(lstcon_trans_stat_t)))
rc = -EFAULT;
out:
- mutex_up(&console_session.ses_mutex);
+ cfs_mutex_up(&console_session.ses_mutex);
LIBCFS_FREE(buf, data->ioc_plen1);