int init_module() { int rv = 0; // Our_Proc_File = create_proc(PROC_ENTRY_FILENAME, 0644, NULL, &File_Ops_4_Our_Proc_File); Our_Proc_File = proc_create(PROC_ENTRY_FILENAME, 0644, NULL, &File_Ops_4_Our_Proc_File); // proc_set_user(Our_Proc_File, 0, 0); proc_set_size(Our_Proc_File, 80); /* After 3.10, definition of struct proc_dir_entry moved to fs/proc/internal.h to ensure the modules using the official procfs API.*/ // Our_Proc_File->owner = THIS_MODULE; // Our_Proc_File->proc_iops = &Inode_Ops_4_Our_Proc_File; // Our_Proc_File->proc_fops = &File_Ops_4_Our_Proc_File; // Our_Proc_File->mode = S_IFREG | S_IRUGO | S_IWUSR; // Our_Proc_File->uid = 0; // Our_Proc_File->gid = 0; // Our_Proc_File->size = 80; printk(KERN_DEBUG"Init module: procfs\n"); if (Our_Proc_File == NULL) { rv = -ENOMEM; remove_proc_entry(PROC_ENTRY_FILENAME, NULL); printk(KERN_INFO"Error: Could not initialize /proc/rw_test\n"); } return rv; }
void msm_init_last_radio_log(struct module *owner) { struct proc_dir_entry *entry; if (last_radio_log_fops.owner) { pr_err("%s: already claimed\n", __func__); return; } radio_log_base = smem_item(SMEM_CLKREGIM_BSP, &radio_log_size); if (!radio_log_base) { pr_err("%s: could not retrieve SMEM_CLKREGIM_BSP\n", __func__); return; } entry = proc_create("last_radio_log", S_IRUGO, NULL, &last_radio_log_fops); if (!entry) { pr_err("%s: could not create proc entry for radio log\n", __func__); return; } pr_err("%s: last radio log is %d bytes long\n", __func__, radio_log_size); last_radio_log_fops.owner = owner; proc_set_size(entry, radio_log_size); }
int pci_proc_attach_device(struct pci_dev *dev) { struct pci_bus *bus = dev->bus; struct proc_dir_entry *e; char name[16]; if (!proc_initialized) return -EACCES; if (!bus->procdir) { if (pci_proc_domain(bus)) { sprintf(name, "%04x:%02x", pci_domain_nr(bus), bus->number); } else { sprintf(name, "%02x", bus->number); } bus->procdir = proc_mkdir(name, proc_bus_pci_dir); if (!bus->procdir) return -ENOMEM; } sprintf(name, "%02x.%x", PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); e = proc_create_data(name, S_IFREG | S_IRUGO | S_IWUSR, bus->procdir, &proc_bus_pci_operations, dev); if (!e) return -ENOMEM; proc_set_size(e, dev->cfg_size); dev->procent = e; return 0; }
static int __init bofh_init(void) { static struct file_operations ops = { .owner = THIS_MODULE, .open = &bofh_open, .read = &seq_read, .llseek = &seq_lseek, .release = &single_release, }; bofh_proc_file = proc_create(BOFH_FILENAME, 0644, NULL, &ops); if (unlikely(bofh_proc_file == NULL)) { pr_alert("Error: kmod_bofh could not initialize /proc/%s\n", BOFH_FILENAME); return -ENOMEM; } #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0) bofh_proc_file->uid = 0; bofh_proc_file->gid = 0; bofh_proc_file->size = 0; #else proc_set_user(bofh_proc_file, GLOBAL_ROOT_UID, GLOBAL_ROOT_GID); proc_set_size(bofh_proc_file, 0); #endif pr_debug("BOFH module inititialized!\n"); return 0; }
int __ref create_proc_profile(void) /* false positive from hotcpu_notifier */ { struct proc_dir_entry *entry; int err = 0; if (!prof_on) return 0; cpu_notifier_register_begin(); if (create_hash_tables()) { err = -ENOMEM; goto out; } entry = proc_create("profile", S_IWUSR | S_IRUGO, NULL, &proc_profile_operations); if (!entry) goto out; proc_set_size(entry, (1 + prof_len) * sizeof(atomic_t)); __hotcpu_notifier(profile_cpu_callback, 0); out: cpu_notifier_register_done(); return err; }
static int __init proc_ppc64_init(void) { struct proc_dir_entry *pde; pde = proc_create_data("powerpc/systemcfg", S_IFREG|S_IRUGO, NULL, &page_map_fops, vdso_data); if (!pde) return 1; proc_set_size(pde, PAGE_SIZE); return 0; }
static int __init ikconfig_init(void) { struct proc_dir_entry *entry; /* create the current config file */ entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL, &ikconfig_file_ops); if (!entry) return -ENOMEM; proc_set_size(entry, &kernel_config_data_end - &kernel_config_data); return 0; }
static int __init zorro_proc_attach_device(unsigned int slot) { struct proc_dir_entry *entry; char name[4]; sprintf(name, "%02x", slot); entry = proc_create_data(name, 0, proc_bus_zorro_dir, &proc_bus_zorro_operations, &zorro_autocon[slot]); if (!entry) return -ENOMEM; proc_set_size(entry, sizeof(struct zorro_dev)); return 0; }
static int __init ikheaders_init(void) { struct proc_dir_entry *entry; /* create the current headers file */ entry = proc_create("kheaders.tar.xz", S_IRUGO, NULL, &ikheaders_file_ops); if (!entry) return -ENOMEM; proc_set_size(entry, &kernel_headers_data_end - &kernel_headers_data); return 0; }
int __ref create_proc_profile(void) /* false positive from hotcpu_notifier */ { struct proc_dir_entry *entry; if (!prof_on) return 0; if (create_hash_tables()) return -ENOMEM; entry = proc_create("profile", S_IWUSR | S_IRUGO, NULL, &proc_profile_operations); if (!entry) return 0; proc_set_size(entry, (1 + prof_len) * sizeof(atomic_t)); hotcpu_notifier(profile_cpu_callback, 0); return 0; }
static int __init rk_last_log_init(void) { size_t early_log_size; char *buf; struct proc_dir_entry *entry; if (!cpu_is_rockchip()) return 0; buf = (char *)__get_free_pages(GFP_KERNEL, LOG_BUF_PAGE_ORDER); if (!buf) { pr_err("failed to __get_free_pages(%d)\n", LOG_BUF_PAGE_ORDER); return 0; } log_buf = last_log_vmap(virt_to_phys(buf), 1 << LOG_BUF_PAGE_ORDER); if (!log_buf) { pr_err("failed to map %d pages at 0x%08x\n", 1 << LOG_BUF_PAGE_ORDER, virt_to_phys(buf)); return 0; } last_log_buf = (char *)vmalloc(LOG_BUF_LEN); if (!last_log_buf) { pr_err("failed to vmalloc(%d)\n", LOG_BUF_LEN); return 0; } memcpy(last_log_buf, buf, LOG_BUF_LEN); early_log_size = log_pos > sizeof(early_log_buf) ? sizeof(early_log_buf) : log_pos; memcpy(log_buf, early_log_buf, early_log_size); memset(log_buf + early_log_size, 0, LOG_BUF_LEN - early_log_size); pr_info("0x%08x map to 0x%p and copy to 0x%p, size 0x%x early 0x%x (version 3.0)\n", virt_to_phys(buf), log_buf, last_log_buf, LOG_BUF_LEN, early_log_size); entry = proc_create("last_kmsg", S_IRUSR, NULL, &last_log_fops); if (!entry) { pr_err("failed to create proc entry\n"); return 0; } proc_set_size(entry, LOG_BUF_LEN); proc_symlink("last_log", NULL, "last_kmsg"); return 0; }
static int __init sec_avc_log_late_init(void) { struct proc_dir_entry *entry; if (sec_avc_log_buf == NULL) { pr_err("%s: sec_avc_log_buf not initialized.\n", __func__); return 0; } entry = proc_create_data("avc_msg", S_IFREG | S_IRUGO, NULL, &avc_msg_file_ops, NULL); if (!entry) { pr_err("%s: failed to create proc entry\n", __func__); return 0; } proc_set_size(entry, sec_avc_log_size); return 0; }
static int __init sec_log_late_init(void) { struct proc_dir_entry *entry; if (last_kmsg_buffer == NULL) return 0; entry = proc_create("last_kmsg", S_IFREG | S_IRUGO, NULL, &last_kmsg_file_ops); if (!entry) { pr_err("%s: failed to create proc entry\n", __func__); return 0; } //entry->size = last_kmsg_size; proc_set_size(entry, last_kmsg_size); return 0; }
static int __init init_cris_profile(void) { struct proc_dir_entry *entry; sample_buffer = kmalloc(SAMPLE_BUFFER_SIZE, GFP_KERNEL); if (!sample_buffer) { return -ENOMEM; } sample_buffer_pos = sample_buffer; entry = proc_create("system_profile", S_IWUSR | S_IRUGO, NULL, &cris_proc_profile_operations); if (entry) { proc_set_size(entry, SAMPLE_BUFFER_SIZE); } prof_running = 1; return 0; }
static void __init mmi_msm_acpu_bin_export(void) { struct proc_dir_entry *proc; unsigned long flags; char acpu[64]; spin_lock_irqsave(&mmi_msm_bin_lock, flags); if (!(mmi_msm_bin_info.set & ACPU_BIN_SET)) { spin_unlock_irqrestore(&mmi_msm_bin_lock, flags); pr_err("ACPU Bin is not available.\n"); return; } spin_unlock_irqrestore(&mmi_msm_bin_lock, flags); mmi_panic_annotate("ACPU: "); if (mmi_msm_bin_info.speed != MMI_MSM_BIN_INVAL) { snprintf(acpu, sizeof(acpu), "Speed bin %d ", mmi_msm_bin_info.speed); mmi_panic_annotate(acpu); } if (mmi_msm_bin_info.pvs != MMI_MSM_BIN_INVAL) { proc = proc_create_data("cpu/msm_acpu_pvs", (S_IFREG | S_IRUGO), NULL, &mmi_acpu_proc_fops, (void *)mmi_msm_bin_info.pvs); if (!proc) pr_err("Failed to create /proc/cpu/msm_acpu_pvs.\n"); else proc_set_size(proc, 1); snprintf(acpu, sizeof(acpu), "PVS bin %d ", mmi_msm_bin_info.pvs); mmi_panic_annotate(acpu); } if (mmi_msm_bin_info.ver != MMI_MSM_BIN_INVAL) { snprintf(acpu, sizeof(acpu), "PVS version %d ", mmi_msm_bin_info.ver); mmi_panic_annotate(acpu); } mmi_panic_annotate("\n"); }