opt
/
kaspersky
/
kav4fs
/
src
/
kernel
/
redirfs
➕ New
📤 Upload
✎ Editing:
rfs_ops.c
← Back
/* * RedirFS: Redirecting File System * Written by Frantisek Hrbata <frantisek.hrbata@redirfs.org> * * Copyright 2008 - 2010 Frantisek Hrbata * All rights reserved. * * This file is part of RedirFS. * * RedirFS is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * RedirFS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RedirFS. If not, see <http://www.gnu.org/licenses/>. */ #include "rfs.h" struct rfs_ops* rfs_ops_alloc(void) { struct rfs_ops* rops; char* arr; rops = kzalloc(sizeof(struct rfs_ops), GFP_KERNEL); arr = kzalloc(sizeof(char) * REDIRFS_OP_END, GFP_KERNEL); if (!rops || !arr) { kfree(rops); kfree(arr); return ERR_PTR(-ENOMEM); } rops->arr = arr; atomic_set(&rops->count, 1); spin_lock_init(&rops->lock); return rops; } struct rfs_ops* rfs_ops_get(struct rfs_ops* rops) { if (!rops || IS_ERR(rops)) return NULL; spin_lock(&rops->lock); BUG_ON(!atomic_read(&rops->count)); atomic_inc(&rops->count); spin_unlock(&rops->lock); return rops; } void rfs_ops_put(struct rfs_ops* rops) { if (!rops || IS_ERR(rops)) return; spin_lock(&rops->lock); BUG_ON(!atomic_read(&rops->count)); if (!atomic_dec_and_test(&rops->count)) { spin_unlock(&rops->lock); return; } kfree(rops->arr); spin_unlock(&rops->lock); kfree(rops); }
💾 Save Changes
Cancel
📤 Upload File
×
Select File
Upload
Cancel
➕ Create New
×
Type
📄 File
📁 Folder
Name
Create
Cancel
✎ Rename Item
×
Current Name
New Name
Rename
Cancel
🔐 Change Permissions
×
Target File
Permission (e.g., 0755, 0644)
0755
0644
0777
Apply
Cancel