int impl_fuse_context::cleanup(LPCWSTR file_name, PDOKAN_FILE_INFO dokan_file_info) { // TODO: // There's a subtle race condition possible here. 'Cleanup' is called when the // system closes the last handle from user space. However, there might still // be outstanding handles from kernel-space. So when userspace tries to // make CreateFile call - it might get error because the file is still locked // by the kernel space. // The one way to solve this is to keep a table of files 'still in flight' // and block until the file is closed. We're not doing this yet. // No context for directories when ops_.opendir is not set if (dokan_file_info->Context || (dokan_file_info->IsDirectory && !ops_.opendir)) { if (dokan_file_info->DeleteOnClose) { close_file(file_name, dokan_file_info); if (dokan_file_info->IsDirectory) { do_delete_directory(file_name, dokan_file_info); } else { do_delete_file(file_name, dokan_file_info); } } } return 0; }
int delete_file(uint32_t userid, uint16_t cmd, int fd, void* pkg, int pkglen) { CHECK_BODY_LEN(pkglen, 68); char lloccode[64] = {0}; uint32_t key_album; int j = 0; UNPKG_H_UINT32(pkg, key_album, j); UNPKG_STR(pkg, lloccode, j, LLOCCODE_LEN); if (do_delete_file(userid, key_album, lloccode) == -1) { ERROR_RETURN(("cannot delete file\t[%u %u %u]", userid, key_album, lloccode), -1); } send_ok_to_php(fd, cmd, userid); return 0; }