1

次のような特定のファイルの inode を削除しようとしました。

    ext2_filsys filsys;
    errcode_t error = ext2fs_open("/dev/sdb1",EXT2_FLAG_RW, 0, 0, unix_io_manager, &filsys);  // I know my file is located on /dev/sdb1
    ext2_ino_t ino = 13; // I found this number using ls -i command in terminal

    // first I read the inode to check that I am reading the correct one correctly
    struct ext2_inode inode;    
    errcode_t err_iread = ext2fs_read_inode(filsys, ino, &inode);

    // I change the data blocks pointers array and zero them all, then I change file size to zero
    unsigned int blocks_array[15] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    inode.i_size = 0;
    memcpy(&inode.i_block, &blocks_array, sizeof inode.i_block);  // I use this to remove data block indexes of the file.

    // I write the changed inode on to my desired file's inode
    errcode_t err_iwrite = ext2fs_write_inode(filsys, ino, &inode);
    errcode_t err_flush = ext2fs_flush(filsys);

    // Again I check that I have written the inode correctly
    err_iread = ext2fs_read_inode(filsys, ino, &inode);
    errcode_t err_close = ext2fs_close(filsys);

問題は、ファイル ブラウザ アプリケーションからファイルを開くことができることです。
だから私の質問は、ここで何が起こっているのですか? ファイル ブラウザ アプリケーションはどのようにしてファイルのデータ ブロックを見つけて開くことができますか?
このコードをubuntu 14.0.4で実行しました

4

0 に答える 0