using namespace ode;
-int ode_secure_erase(const char* name)
-{
- RET_ON_FAILURE(name, ODE_ERROR_INVALID_PARAMETER);
-
- ODEContext client;
- RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- SecureErase secure = client.createInterface<SecureErase>();
-
- return secure.erase(name);
-}
-
int ode_secure_clean(const char* name)
{
RET_ON_FAILURE(name, ODE_ERROR_INVALID_PARAMETER);
extern "C" {
#endif
-/**
- * @brief Erase the file or device with given name securely.
- * @details Administrator can use this API to secure-erase the files.
- * @since_tizen 4.0
- * @param[in] name The file/directory or device name
- * @return #ODE_ERROR_NONE on success, otherwise a negative value
- * @retval #ODE_ERROR_NONE Successful
- * @retval #ODE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #ODE_ERROR_TIMED_OUT Time out
- * @retval #ODE_ERROR_NO_SUCH_FILE No such file or directory
- * @retval #ODE_ERROR_NOT_PERMITTED Operation not permitted
- * @retval #ODE_ERROR_PERMISSION_DENIED The application does not have
- * the privilege to call this API
- * @pre The file or device to the given name must be exists.
- * @pre If the device is specified, it must be a block device.
- */
-ODE_API int ode_secure_erase(const char* name);
-
/**
* @brief Clean garbage in the device with given name securely.
* @details Administrator can use this API to collect garbage in the device.
{
}
-int SecureErase::erase(const std::string& name)
-{
- try {
- return context->methodCall<int>("SecureErase::erase", name);
- } catch (runtime::Exception& e) {
- return -1;
- }
-}
-
int SecureErase::clean(const std::string& name)
{
try {
SecureErase(ODEControlContext& ctxt);
~SecureErase();
- int erase(const std::string& name);
int clean(const std::string& name);
private:
SecureErase::SecureErase(ODEControlContext &ctx) :
context(ctx)
{
- context.expose(this, PRIVILEGE_PLATFORM, (int)(SecureErase::erase)(std::string));
context.expose(this, PRIVILEGE_PLATFORM, (int)(SecureErase::clean)(std::string));
engine.reset(new ERASE_ENGINE(ProgressBar([](int v) {
{
}
-
-
-int SecureErase::erase(const std::string &name)
-{
- auto eraseWorker = [name, this]() {
- try {
- } catch (runtime::Exception &e) {}
- };
-
- std::thread asyncWork(eraseWorker);
- asyncWork.detach();
-
- return 0;
-}
-
int SecureErase::clean(const std::string &name)
{
auto cleanWorker = [name, this]() {
<< " -p, --changepw=internal|external|extension change password" << std::endl
<< " -s, --state=internal|external|extension get state" << std::endl
<< " -w, --waitmnt=internal|external|extension wait for mount"<< std::endl
- << " -r, --erase=FILE|DIRECTORY secure-erase" << std::endl
<< " -c, --clean=DIRECTORY secure-clean" << std::endl
<< " -h, --help show this" << std::endl
<< std::endl;
return ret;
}
-static inline int erase(const std::string name)
-{
- int ret;
-
- ret = ode_secure_erase(name.c_str());
- if (ret != 0) {
- std::cerr << "Error : " << ret <<std::endl;
- }
-
- return ret;
-}
-
static inline int clean(const std::string name)
{
int ret;
{"format", required_argument, 0, 'f'},
{"state", required_argument, 0, 's'},
{"waitmnt", required_argument, 0, 'w'},
- {"erase", required_argument, 0, 'r'},
{"clean", required_argument, 0, 'c'},
{0, 0, 0, 0}
};
return EXIT_SUCCESS;
}
- while ((opt = getopt_long(argc, argv, "m:u:e:d:f:p:s:w:r:c:h", options, &index)) != -1) {
+ while ((opt = getopt_long(argc, argv, "m:u:e:d:f:p:s:w:c:h", options, &index)) != -1) {
switch (opt) {
case 'm':
ret = mount(optarg);
case 's':
ret = get_state(optarg);
break;
- case 'r':
- ret = erase(optarg);
- break;
case 'c':
ret = clean(optarg);
break;