PK œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
| Dir : /usr/src/file_protector-1.1-1584/ |
| Server: Linux ituca148.hostpapavps.net 4.18.0-553.141.2.el8_10.x86_64 #1 SMP Wed Jul 8 10:28:18 EDT 2026 x86_64 IP: 216.7.89.187 |
| Dir : //usr/src/file_protector-1.1-1584/safe_kobject.h |
/**
@file safe_kobject.h
@brief Safe kobject interop with sysfs
@details Copyright (c) 2025 Acronis International GmbH
@author Denis Kopyrin (denis.kopyrin@acronis.com)
@since $Id: $
*/
#pragma once
#include <linux/completion.h>
#include <linux/kobject.h>
#ifdef KERNEL_MOCK
#include <mock/mock_types.h>
#endif
// The problem with kobject is that it is embedded in sysfs system.
// For regular monolith design it is not an issue but for unload code we do not want our callback to triggered.
// The common solution for this is to use waitable 'completion' that is invoked from 'release' instead of 'kfree'.
typedef struct safe_kobject_s {
struct kobject kobj;
struct completion complete;
} safe_kobject_t;
#define to_safe_kobject(_at) container_of(_at, safe_kobject_t, kobj)
static inline void safe_kobject_sysfs_release(struct kobject* obj)
{
// TODO: Figure out why container_of does not work here
safe_kobject_t* skobj = (safe_kobject_t*) obj;
complete(&skobj->complete);
}
static inline void safe_kobject_init(safe_kobject_t* skobj)
{
skobj->kobj = (struct kobject){};
init_completion(&skobj->complete);
}
static inline void safe_kobject_del(safe_kobject_t* skobj)
{
kobject_del(&skobj->kobj);
kobject_put(&skobj->kobj);
wait_for_completion(&skobj->complete);
}