* GPL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*/
/*
/* The global lock to protect all the access */
#if LIBCFS_PROCFS_SPINLOCK
-spinlock_t proc_fs_lock;
+cfs_spinlock_t proc_fs_lock;
-#define INIT_PROCFS_LOCK() spin_lock_init(&proc_fs_lock)
-#define LOCK_PROCFS() spin_lock(&proc_fs_lock)
-#define UNLOCK_PROCFS() spin_unlock(&proc_fs_lock)
+#define INIT_PROCFS_LOCK() cfs_spin_lock_init(&proc_fs_lock)
+#define LOCK_PROCFS() cfs_spin_lock(&proc_fs_lock)
+#define UNLOCK_PROCFS() cfs_spin_unlock(&proc_fs_lock)
#else
-mutex_t proc_fs_lock;
+cfs_mutex_t proc_fs_lock;
-#define INIT_PROCFS_LOCK() init_mutex(&proc_fs_lock)
-#define LOCK_PROCFS() mutex_down(&proc_fs_lock)
-#define UNLOCK_PROCFS() mutex_up(&proc_fs_lock)
+#define INIT_PROCFS_LOCK() cfs_init_mutex(&proc_fs_lock)
+#define LOCK_PROCFS() cfs_mutex_down(&proc_fs_lock)
+#define UNLOCK_PROCFS() cfs_mutex_up(&proc_fs_lock)
#endif
break;
}
- n -= copy_to_user((void *)buf, start, n);
+ n -= cfs_copy_to_user((void *)buf, start, n);
if (n == 0) {
if (retval == 0)
retval = -EFAULT;
continue;
/* Maybe we can't do anything with it... */
if (!table->proc_handler && !table->child) {
- printk(KERN_WARNING "SYSCTL: Can't register %s\n",
+ printk(CFS_KERN_WARNING "SYSCTL: Can't register %s\n",
table->procname);
continue;
}
continue;
if (de->mode & S_IFDIR) {
if (!table->child) {
- printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
+ printk (CFS_KERN_ALERT "Help- malformed sysctl tree on free\n");
continue;
}
unregister_proc_table(table->child, de);
if (len > l) len = l;
if (len >= table->maxlen)
len = table->maxlen;
- if(copy_to_user(oldval, table->data, len))
+ if(cfs_copy_to_user(oldval, table->data, len))
return -EFAULT;
if(put_user(0, ((char *) oldval) + len))
return -EFAULT;
len = newlen;
if (len > table->maxlen)
len = table->maxlen;
- if(copy_from_user(table->data, newval, len))
+ if(cfs_copy_from_user(table->data, newval, len))
return -EFAULT;
if (len == table->maxlen)
len--;
len = left;
if (len > TMPBUFLEN-1)
len = TMPBUFLEN-1;
- if(copy_from_user(buf, buffer, len))
+ if(cfs_copy_from_user(buf, buffer, len))
return -EFAULT;
buf[len] = 0;
p = buf;
len = strlen(buf);
if (len > left)
len = left;
- if(copy_to_user(buffer, buf, len))
+ if(cfs_copy_to_user(buffer, buf, len))
return -EFAULT;
left -= len;
(char *)buffer += len;
}
if (len >= (size_t)table->maxlen)
len = (size_t)table->maxlen-1;
- if(copy_from_user(table->data, buffer, len))
+ if(cfs_copy_from_user(table->data, buffer, len))
return -EFAULT;
((char *) table->data)[len] = 0;
filp->f_pos += *lenp;
if (len > *lenp)
len = *lenp;
if (len)
- if(copy_to_user(buffer, table->data, len))
+ if(cfs_copy_to_user(buffer, table->data, len))
return -EFAULT;
if (len < *lenp) {
if(put_user('\n', ((char *) buffer) + len))
if (len) {
if (len > (size_t)table->maxlen)
len = (size_t)table->maxlen;
- if(copy_to_user(oldval, table->data, len))
+ if(cfs_copy_to_user(oldval, table->data, len))
return -EFAULT;
if(put_user(len, oldlenp))
return -EFAULT;
len = newlen;
if (len > (size_t)table->maxlen)
len = (size_t)table->maxlen;
- if(copy_from_user(table->data, newval, len))
+ if(cfs_copy_from_user(table->data, newval, len))
return -EFAULT;
}
}
int do_sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
void *newval, size_t newlen)
{
- struct list_head *tmp;
+ cfs_list_t *tmp;
if (nlen <= 0 || nlen >= CTL_MAXNAME)
return -ENOTDIR;
tmp = &root_table_header.ctl_entry;
do {
struct ctl_table_header *head =
- list_entry(tmp, struct ctl_table_header, ctl_entry);
+ cfs_list_entry(tmp, struct ctl_table_header, ctl_entry);
void *context = NULL;
int error = parse_table(name, nlen, oldval, oldlenp,
newval, newlen, head->ctl_table,
CFS_INIT_LIST_HEAD(&tmp->ctl_entry);
if (insert_at_head)
- list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
+ cfs_list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
else
- list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
+ cfs_list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
#ifdef CONFIG_PROC_FS
register_proc_table(table, cfs_proc_sys);
#endif
*/
void unregister_sysctl_table(struct ctl_table_header * header)
{
- list_del(&header->ctl_entry);
+ cfs_list_del(&header->ctl_entry);
#ifdef CONFIG_PROC_FS
unregister_proc_table(header->ctl_table, cfs_proc_sys);
#endif
int trace_write_dump_kernel(struct file *file, const char *buffer,
unsigned long count, void *data)
{
- int rc = trace_dump_debug_buffer_usrstr((void *)buffer, count);
+ int rc = cfs_trace_dump_debug_buffer_usrstr((void *)buffer, count);
return (rc < 0) ? rc : count;
}
int trace_write_daemon_file(struct file *file, const char *buffer,
unsigned long count, void *data)
{
- int rc = trace_daemon_command_usrstr((void *)buffer, count);
+ int rc = cfs_trace_daemon_command_usrstr((void *)buffer, count);
return (rc < 0) ? rc : count;
}
int *eof, void *data)
{
int rc;
- tracefile_read_lock();
- rc = trace_copyout_string(page, count, tracefile, "\n");
- tracefile_read_unlock();
+ cfs_tracefile_read_lock();
+ rc = cfs_trace_copyout_string(page, count, cfs_tracefile, "\n");
+ cfs_tracefile_read_unlock();
return rc;
}
{
char str[32];
- snprintf(str, sizeof(str), "%d\n", trace_get_debug_mb());
+ snprintf(str, sizeof(str), "%d\n", cfs_trace_get_debug_mb());
- return trace_copyout_string(page, count, str, NULL);
+ return cfs_trace_copyout_string(page, count, str, NULL);
}
int insert_proc(void)
if (obd->ioc_plen1) {
obd->ioc_pbuf1 = (char *)(data + off);
- off += size_round(obd->ioc_plen1);
+ off += cfs_size_round(obd->ioc_plen1);
} else {
obd->ioc_pbuf1 = NULL;
}
if (obd->ioc_plen2) {
obd->ioc_pbuf2 = (char *)(data + off);
- off += size_round(obd->ioc_plen2);
+ off += cfs_size_round(obd->ioc_plen2);
} else {
obd->ioc_pbuf2 = NULL;
}
file->private_data = p;
}
memset(p, 0, sizeof(*p));
- mutex_init(&p->lock);
+ cfs_mutex_init(&p->lock);
p->op = op;
/*
void *p;
int err = 0;
- mutex_lock(&m->lock);
+ cfs_mutex_lock(&m->lock);
/*
* seq_file->op->..m_start/m_stop/m_next may do special actions
* or optimisations based on the file->f_version, so we want to
/* if not empty - flush it first */
if (m->count) {
n = min(m->count, size);
- err = copy_to_user(buf, m->buf + m->from, n);
+ err = cfs_copy_to_user(buf, m->buf + m->from, n);
if (err)
goto Efault;
m->count -= n;
}
m->op->stop(m, p);
n = min(m->count, size);
- err = copy_to_user(buf, m->buf, n);
+ err = cfs_copy_to_user(buf, m->buf, n);
if (err)
goto Efault;
copied += n;
else
*ppos += copied;
file->f_version = m->version;
- mutex_unlock(&m->lock);
+ cfs_mutex_unlock(&m->lock);
return copied;
Enomem:
err = -ENOMEM;
struct seq_file *m = (struct seq_file *)file->private_data;
long long retval = -EINVAL;
- mutex_lock(&m->lock);
+ cfs_mutex_lock(&m->lock);
m->version = file->f_version;
switch (origin) {
case 1:
}
}
file->f_version = m->version;
- mutex_unlock(&m->lock);
+ cfs_mutex_unlock(&m->lock);
return retval;
}
EXPORT_SYMBOL(seq_lseek);
}
EXPORT_SYMBOL(seq_puts);
-struct list_head *seq_list_start(struct list_head *head, loff_t pos)
+cfs_list_t *seq_list_start(cfs_list_t *head, loff_t pos)
{
- struct list_head *lh;
+ cfs_list_t *lh;
- list_for_each(lh, head)
+ cfs_list_for_each(lh, head)
if (pos-- == 0)
return lh;
EXPORT_SYMBOL(seq_list_start);
-struct list_head *seq_list_start_head(struct list_head *head, loff_t pos)
+cfs_list_t *seq_list_start_head(cfs_list_t *head,
+ loff_t pos)
{
if (!pos)
return head;
EXPORT_SYMBOL(seq_list_start_head);
-struct list_head *seq_list_next(void *v, struct list_head *head, loff_t *ppos)
+cfs_list_t *seq_list_next(void *v, cfs_list_t *head,
+ loff_t *ppos)
{
- struct list_head *lh;
+ cfs_list_t *lh;
- lh = ((struct list_head *)v)->next;
+ lh = ((cfs_list_t *)v)->next;
++*ppos;
return lh == head ? NULL : lh;
}