allow secure remove to be able to write multiple times... in theory...

but for now it's once. :)



SVN revision: 77147
This commit is contained in:
Carsten Haitzler 2012-09-27 10:10:20 +00:00
parent 17ce568685
commit dfb8541aad
1 changed files with 20 additions and 12 deletions

View File

@ -1680,6 +1680,9 @@ _e_fm_op_destroy_atom(E_Fm_Op_Task *task)
static int fd = -1;
static char *buf = NULL;
off_t pos, sz;
// if we do this 7 times! we're
// int cnt, overwrite_count = 7;
int cnt, overwrite_count = 1;
if (fd == -1)
{
@ -1709,22 +1712,27 @@ _e_fm_op_destroy_atom(E_Fm_Op_Task *task)
task->src.st.st_size = st2.st_size;
}
if (lseek(fd, SEEK_SET, 0) == -1)
goto finish;
for (pos = 0; pos < task->src.st.st_size; pos += 65536)
for (cnt = 0; cnt < overwrite_count; cnt++)
{
sz = 65536;
if ((task->src.st.st_size - pos) < sz) sz = task->src.st.st_size - pos;
if (_e_fm_op_random_buf(buf, sz) == -1) memset(buf, 0xff, sz);
if (write(fd, buf, sz) != sz)
if (lseek(fd, SEEK_SET, 0) == -1)
goto finish;
for (pos = 0; pos < task->src.st.st_size; pos += 65536)
{
fsync(fd);
goto finish;
sz = 65536;
if ((task->src.st.st_size - pos) < sz) sz = task->src.st.st_size - pos;
if (_e_fm_op_random_buf(buf, sz) == -1)
// alternate patterb between 0x00 and 0xff each round starting with 0xff
memset(buf, 0xff * ((cnt + 1) & 0x1), sz);
if (write(fd, buf, sz) != sz)
{
fsync(fd);
goto finish;
}
}
if (fsync(fd) == -1)
goto finish;
}
if (fsync(fd) == -1)
goto finish;
task->dst.done++;
_e_fm_op_update_progress_report_simple((double)task->dst.done/NB_PASS*100, "/dev/urandom", task->src.name);