static int procfs_bind(FAR struct inode *blkdriver, const void *data, void **handle) { /* Make sure that we are properly initialized */ procfs_initialize(); return OK; }
int procfs_register(FAR const struct procfs_entry_s *entry) { FAR struct procfs_entry_s *newtable; unsigned int newcount; size_t newsize; int ret; /* Make sure that we are properly initialized */ procfs_initialize(); /* realloc the table of procfs entries. * * REVISIT: This reallocation may free memory previously used for the * procfs entry table. If that table were actively in use, then that * could cause procfs logic to use a stale memory pointer! We avoid that * problem by requiring that the procfs file be unmounted when the new * entry is added. That requirment, however, is not enforced explicitly. * * Locking the scheduler as done below is insufficient. As would be just * marking the entries as volatile. */ newcount = g_procfs_entrycount + 1; newsize = newcount * sizeof(struct procfs_entry_s); sched_lock(); newtable = (FAR struct procfs_entry_s *)kmm_realloc(g_procfs_entries, newsize); if (newtable == NULL) { /* Reallocation failed! */ ret = -ENOMEM; } else { /* Copy the new entry at the end of the reallocated table */ memcpy(&newtable[g_procfs_entrycount], entry, sizeof(struct procfs_entry_s)); /* Instantiate the reallocated table */ g_procfs_entries = newtable; g_procfs_entrycount = newcount; ret = OK; } sched_unlock(); return ret; }
static int __init fullnat_initialize(void) { int ret; ret = procfs_initialize(); if (ret) { return ret; } ret = sysfs_initialize(); if (ret) { procfs_shutdown(); return ret; } ret = rip_initialize(); if (ret) { sysfs_shutdown(); procfs_shutdown(); return ret; } return 0; }