static ssize_t rfs_flt_unregister_store(redirfs_filter filter, struct redirfs_filter_attribute *attr, const char *buf, size_t count) { struct rfs_flt *rflt = filter; int unreg; int rv; if (sscanf(buf, "%d", &unreg) != 1) return -EINVAL; if (unreg != 1) return -EINVAL; if (rflt->ops && rflt->ops->unregister) rv = rflt->ops->unregister(); else rv = redirfs_unregister_filter(filter); if (rv) return rv; return count; }
static int __init dummyflt_init(void) { struct redirfs_path_info dummyflt_path_info; struct nameidata nd; redirfs_path path; int err; int rv; dummyflt = redirfs_register_filter(&dummyflt_info); if (IS_ERR(dummyflt)) { rv = PTR_ERR(dummyflt); printk(KERN_ERR "dummyflt: register filter failed(%d)\n", rv); return rv; } nl_sk=netlink_kernel_create(&init_net, NETLINK_USER, 0, initializer, NULL, THIS_MODULE); if(!nl_sk) { printk(KERN_ALERT "Error creating socket.\n"); return 0; } rv = redirfs_set_operations(dummyflt, dummyflt_op_info); if (rv) { printk(KERN_ERR "dummyflt: set operations failed(%d)\n", rv); goto error; } rv = path_lookup("/home/ozgen/Desktop/test2", LOOKUP_FOLLOW, &nd);/*simdilik sadec denemek icin ileride module yuklenirken parametre olarak verilecek*/ if (rv) { printk(KERN_ERR "dummyflt: path lookup failed(%d)\n", rv); goto error; } dummyflt_path_info.dentry = nd.path.dentry; dummyflt_path_info.mnt = nd.path.mnt; dummyflt_path_info.flags = REDIRFS_PATH_INCLUDE; path = redirfs_add_path(dummyflt, &dummyflt_path_info); if (IS_ERR(path)) { rv = PTR_ERR(path); printk(KERN_ERR "dummyflt: redirfs_set_path failed(%d)\n", rv); path_put(&nd.path); goto error; } path_put(&nd.path); redirfs_put_path(path); printk(KERN_INFO "Dummy Filter Version " DUMMYFLT_VERSION " <www.redirfs.org>\n"); return 0; error: err = redirfs_unregister_filter(dummyflt); if (err) { printk(KERN_ERR "dummyflt: unregister filter " "failed(%d)\n", err); return 0; } redirfs_delete_filter(dummyflt); return rv; }