-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
/*
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2012, Whamcloud, Inc.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
EXPORT_SYMBOL(ptlrpc_lprocfs_unregister_obd);
+#define BUFLEN (UUID_MAX + 5)
+
int lprocfs_wr_evict_client(struct file *file, const char *buffer,
unsigned long count, void *data)
{
struct obd_device *obd = data;
- char tmpbuf[sizeof(struct obd_uuid)];
+ char *kbuf;
+ char *tmpbuf;
+ OBD_ALLOC(kbuf, BUFLEN);
+ if (kbuf == NULL)
+ return -ENOMEM;
+
+ /*
+ * OBD_ALLOC() will zero kbuf, but we only copy BUFLEN - 1
+ * bytes into kbuf, to ensure that the string is NUL-terminated.
+ * UUID_MAX should include a trailing NUL already.
+ */
+ if (cfs_copy_from_user(kbuf, buffer,
+ min_t(unsigned long, BUFLEN - 1, count))) {
+ count = -EFAULT;
+ goto out;
+ }
+ tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, BUFLEN - 1, count));
/* Kludge code(deadlock situation): the lprocfs lock has been held
* since the client is evicted by writting client's
* uuid/nid to procfs "evict_client" entry. However,
class_incref(obd, __FUNCTION__, cfs_current());
LPROCFS_EXIT();
- sscanf(buffer, "%40s", tmpbuf);
if (strncmp(tmpbuf, "nid:", 4) == 0)
obd_export_evict_by_nid(obd, tmpbuf + 4);
else if (strncmp(tmpbuf, "uuid:", 5) == 0)
LPROCFS_ENTRY();
class_decref(obd, __FUNCTION__, cfs_current());
+out:
+ OBD_FREE(kbuf, BUFLEN);
return count;
}
EXPORT_SYMBOL(lprocfs_wr_evict_client);
+#undef BUFLEN
+
int lprocfs_wr_ping(struct file *file, const char *buffer,
unsigned long count, void *data)
{