static void __exit exit_procfs(void) { proc_remove(myproc);//删除创建在proc下的目录文件 proc_remove(student); proc_remove(date); printk("GoodBye kernel\n"); }
// initialize module (executed when using insmod) static int __init fifo_mod_init(void) { int err; // create the procfs entry procfs_config = proc_create( "fifo_config", 0666, 0, &config_fops); // check for null-pointer if (0 == procfs_config) { printk(KERN_INFO "--- %s: creation of proc/fifo_config failed!\n", mod_name); return -1; } err = fifo_init(&dev, 1024); if (err) { printk(KERN_INFO "--- %s: fifo_init failed!\n", mod_name); proc_remove(procfs_config); return err; } err = create_dev_nodes(); if (err) { printk(KERN_INFO "--- %s: cdev_node creation failed!\n", mod_name); proc_remove(procfs_config); fifo_destroy(&dev); return err; } printk(KERN_INFO "--- %s: is being loaded.\n", mod_name); return 0; }
/** Function Name : gen_module_cleanup Function Type : Module EXIT Description : Cleanup method of the Kernel module. The method gets invoked when the kernel module is being removed using the command rmmod. */ static void __exit gen_module_cleanup(void) { printk(KERN_INFO "Task1.2 module is being unloaded.\n"); /** Proc FS object related to /deeds_clock removed.*/ proc_remove(proc_file_entry); /** Proc FS object related to /deeds_clock_config removed.*/ proc_remove(proc_config_file_entry); }
static void __exit procfs_test2_exit(void) { if (mm_proc_dir != 0) { if (mm_proc_mem != 0) { proc_remove(mm_proc_mem); mm_proc_mem = 0; } proc_remove(mm_proc_dir); mm_proc_dir = 0; } }
/* * Delete directory entry for VLAN device. */ int vlan_proc_rem_dev(struct net_device *vlandev) { /** NOTE: This will consume the memory pointed to by dent, it seems. */ proc_remove(vlan_dev_priv(vlandev)->dent); vlan_dev_priv(vlandev)->dent = NULL; return 0; }
/* * initializes the LKM * calls functions to create/init the following: * the stats file in /proc * the device node in /dev * the fifo_queue is initialized */ static int __init fifo_mod_init(void) { int err; err = fifo_init(&fifo, size); if (err) { printk(KERN_INFO "--- %s: fifo_init failed!\n", mod_name); return err; } proc_stats = proc_create( "deeds_fifo_stats", 0444, 0, &stat_fops); if (0 == proc_stats) { printk(KERN_INFO "--- %s: creation of /proc/deeds_fifo_stats failed!\n", mod_name); fifo_destroy(&fifo); return -1; } err = create_dev_node(); if (err) { printk(KERN_INFO "--- %s: cdev (and node) creation failed!\n", mod_name); proc_remove(proc_stats); fifo_destroy(&fifo); return err; } printk(KERN_INFO "--- %s: is being loaded.\n", mod_name); return err; }
static void __exit exit_driver(void) { proc_remove(device_config_proc); unregister_chrdev(MAJOR_NUMBER,DEVICE_NAME); kfree(fifo_buffer); return; }
/* * Module housekeeping. */ static int irqcatch_init(void) { int ret; my_entry = proc_create(proc_filename, S_IRUGO, NULL, &my_file_ops); if (IS_ERR(my_entry)) { pr_err("error in create_proc_entry"); ret = PTR_ERR(my_entry); goto error_start; } ret = request_irq(irq_num, irqcatch_int_handler, IRQF_SHARED, THIS_MODULE->name, &counter); if (ret) goto error_after_proc; pr_info("irqcatch loaded sucessfuly\n"); return 0; /* error_after_irq: free_irq(irq_num, &counter); */ error_after_proc: proc_remove(my_entry); error_start: return ret; }
/* * Removes '/proc/systemtap/{module_name}'. Notice we're leaving * '/proc/systemtap' behind. There is no way on newer kernels to know * if a procfs directory is empty. * * NB: this is suitable to call late in the module cleanup function, * and does not rely on any other facilities in the runtime. PR19833. * See also PR15408. */ static void _stp_rmdir_proc_module(void) { if (_stp_proc_root) { proc_remove(_stp_proc_root); _stp_proc_root = NULL; } }
/** Function Name : process_sched_add_module_cleanup Function Type : Module EXIT Description : Cleanup method of the Kernel module. The method gets invoked when the kernel module is being removed using the command rmmod. */ static void __exit process_sched_add_module_cleanup(void) { printk(KERN_INFO "Process Add to Scheduler module is being unloaded.\n"); /** Proc FS object removed.*/ proc_remove(proc_sched_add_file_entry); }
static void __exit helloworld_exit(void) { PDEBUG("exit\n"); kfree(memory); cdev_del(hello_cdev); unregister_chrdev_region(hello_devt, 1); proc_remove(hello_proc); }
void simple_exit(void) { /* Unregister the device and /proc entry */ unregister_chrdev(simple_major, "simple"); if (proc_entry) { proc_remove(proc_entry); } printk(KERN_INFO "The SIMPLE module has been removed\n"); }
// cleanup module (executed when using rmmod) static void __exit fifo_cleanup(void) { proc_remove(procfs_config); fifo_destroy(&dev); destroy_dev_nodes(2,2); printk(KERN_INFO "--- %s: is being unloaded.\n", mod_name); }
static void _stp_close_procfs(void) { int i; for (i = _stp_num_pde-1; i >= 0; i--) { struct proc_dir_entry *pde = _stp_pde[i]; proc_remove(pde); } _stp_num_pde = 0; }
static int seqfile_example_init(void) { pde_dir = proc_mkdir("seqfile_dir", NULL); if (!pde_dir) goto out_dir; pde_symlink = proc_symlink("seqfile_link", NULL, "seqfile_dir/counter"); if (!pde_symlink) goto out_symlink; pde_file = proc_create("counter", 0444, pde_dir, &ct_file_ops); if (!pde_file) goto out_file; return 0; out_file: proc_remove(pde_symlink); out_symlink: proc_remove(pde_dir); out_dir: return -ENOMEM; }
void cleanup_module(void) { proc_remove(entry); fm_alert("%s\n", "Farewell the World!"); return; }
static void __exit fifo_mod_cleanup(void) { destroy_dev_node(3); proc_remove(proc_stats); fifo_destroy(&fifo); printk(KERN_INFO "--- %s: is being unloaded.\n", mod_name); }
/************************************************************************ * Name: fts_release_apk_debug_channel * Brief: release apk debug channel * Input: no * Output: no * Return: no ***********************************************************************/ void fts_release_apk_debug_channel(void) { if (fts_proc_entry) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)) proc_remove(fts_proc_entry); #else remove_proc_entry(NULL, fts_proc_entry); #endif }
int snmp6_unregister_dev(struct inet6_dev *idev) { struct net *net = dev_net(idev->dev); if (!net->mib.proc_net_devsnmp6) return -ENOENT; if (!idev->stats.proc_dir_entry) return -EINVAL; proc_remove(idev->stats.proc_dir_entry); idev->stats.proc_dir_entry = NULL; return 0; }
/* * Clean up all resource created by fork(). */ void proc_cleanup(struct proc *p) { struct proc *pp; pp = p->p_parent; list_remove(&p->p_sibling); list_remove(&p->p_pgrp_link); proc_remove(p); list_remove(&p->p_link); free(p); }
void simple_exit(void) { /* Unregister the device and /proc entry */ unregister_chrdev(simple_major, "simple"); if (proc_entry) { proc_remove(proc_entry); } /* Free the buffer */ if (mybuf) { kfree(mybuf); } printk(KERN_INFO "The simple module has been removed\n"); }
INT32 wmt_dev_proc_for_aee_remove(VOID) { #if USE_NEW_PROC_FS_FLAG if (NULL != gWmtAeeEntry) { proc_remove(gWmtAeeEntry); } #else if (NULL != gWmtAeeEntry) { remove_proc_entry(WMT_AEE_PROCNAME, NULL); } #endif return 0; }
void release_tx_isp_vic_device(struct v4l2_subdev *sd) { struct tx_isp_vic_driver *vsd = v4l2_get_subdevdata(sd); struct resource *res = vsd->res; isp_vic_release_clk(vsd); media_entity_cleanup(&sd->entity); v4l2_device_unregister_subdev(sd); iounmap(vsd->base); release_mem_region(res->start,res->end - res->start + 1); if (vsd->proc_vic) { proc_remove(vsd->proc_vic); } kfree(vsd); }
int __init simple_init(void) { int result; /* Register an entry in /proc */ proc_entry = proc_create("simple", 0, NULL, &proc_fops); /* Register a device with the given major number */ result = register_chrdev(simple_major, "simple", &simple_fops); if (result < 0) { printk(KERN_WARNING "Cannot register the /dev/simple device with major number: %d\n", simple_major); proc_remove(proc_entry); return result; } printk(KERN_INFO "The SIMPLE module has been inserted.\n"); return 0; }
INT32 wmt_dev_dbg_remove(VOID) { #if USE_NEW_PROC_FS_FLAG if (NULL != gWmtDbgEntry) { proc_remove(gWmtDbgEntry); } #else if (NULL != gWmtDbgEntry) { remove_proc_entry(WMT_DBG_PROCNAME, NULL); } #endif #if CFG_WMT_PS_SUPPORT wmt_lib_ps_deinit(); #endif return 0; }
/** Function Name : fifo_module_cleanup Function Type : Module EXIT Description : Cleanup method of the Kernel module. The method gets invoked when the kernel module is being removed using the command rmmod. */ static void __exit fifo_module_cleanup(void) { printk(KERN_INFO "FIFO:FIFO module is being unloaded.\n"); /** Removing the Proc FS entry. */ proc_remove(fifo_config_file_entry); /** Removing the device with minor number 0 => FIFO0 */ device_destroy(fifoClass, MKDEV(MAJOR_NUM, MINOR_NUM_FIFO)); /** Deregistering the class FIFO*/ class_unregister(fifoClass); /** Deallocating the class FIFO*/ class_destroy(fifoClass); /** Deregistering the character Device FIFO*/ unregister_chrdev(MAJOR_NUM, FIFO_DEVICE); /** Deallocating the Queue */ kfree(queue); }
static void __exit fifo_exit(void) { int i =0; printk(KERN_CRIT "De-loading fifo module\n"); printk(KERN_CRIT "Destroying workqueue\n"); destroy_workqueue(wq); printk(KERN_CRIT "Freeing memory of the buffer\n"); for(i = 0; i<size; i++) { if(buffer[i].msg != NULL) kfree(buffer[i].msg); } kfree(buffer); printk(KERN_CRIT "Unregistering the driver\n"); unregister_chrdev(major, FIFO_DEV_NAME); printk(KERN_CRIT "Removing proc entry\n"); proc_remove(procdir); printk(KERN_CRIT "Module fifo exited successfully\n"); return; }
static int __init procfs_test2_init(void) { mm_proc_dir = 0; mm_proc_mem = 0; //create a directory under /proc mm_proc_dir = proc_mkdir("gdl", 0); if (mm_proc_dir == 0) { printk(KERN_ERR "/proc/gdl/ creation failed\n"); return -1; } //create /proc/gdl/memory file mm_proc_mem = proc_create("memory", S_IFREG|S_IRWXU|S_IRWXG|S_IRWXO, mm_proc_dir, &procfs_test2_fops); if (mm_proc_mem == 0) { printk(KERN_ERR "/proc/gdl/memory creation failed\n"); proc_remove(mm_proc_dir); mm_proc_dir = 0; return -1; } return 0; }
void my_cleanup_module() { proc_remove(proc_entry); }
static void __exit mod_exit(void) { proc_remove(my_entry); pr_info(KBUILD_MODNAME " unloaded successfully\n"); }