static int remove_reparse_index(ntfs_attr *na, ntfs_index_context *xr, le32 *preparse_tag) { REPARSE_INDEX_KEY key; u64 file_id_cpu; le64 file_id; s64 size; le16 seqn; int ret; ret = na->data_size; if (ret) { /* read the existing reparse_tag */ size = ntfs_attr_pread(na, 0, 4, preparse_tag); if (size == 4) { seqn = na->ni->mrec->sequence_number; file_id_cpu = MK_MREF(na->ni->mft_no,le16_to_cpu(seqn)); file_id = cpu_to_le64(file_id_cpu); key.reparse_tag = *preparse_tag; /* danger on processors which require proper alignment ! */ memcpy(&key.file_id, &file_id, 8); if (!ntfs_index_lookup(&key, sizeof(REPARSE_INDEX_KEY), xr) && ntfs_index_rm(xr)) ret = -1; } else { ret = -1; errno = ENODATA; } } return (ret); }
int ntfs_index_remove(ntfs_inode *dir_ni, ntfs_inode *ni, const void *key, const int keylen) { int ret = STATUS_ERROR; ntfs_index_context *icx; icx = ntfs_index_ctx_get(dir_ni, NTFS_INDEX_I30, 4); if (!icx) return -1; while (1) { if (ntfs_index_lookup(key, keylen, icx)) goto err_out; if ((((FILE_NAME_ATTR *)icx->data)->file_attributes & FILE_ATTR_REPARSE_POINT) && !ntfs_possible_symlink(ni)) { errno = EOPNOTSUPP; goto err_out; } ret = ntfs_index_rm(icx); if (ret == STATUS_ERROR) goto err_out; else if (ret == STATUS_OK) break; ntfs_inode_mark_dirty(icx->actx->ntfs_ino); ntfs_index_ctx_reinit(icx); } ntfs_inode_mark_dirty(icx->actx->ntfs_ino); out: ntfs_index_ctx_put(icx); return ret; err_out: ret = STATUS_ERROR; ntfs_log_perror("Delete failed"); goto out; }
static int remove_object_id_index(ntfs_attr *na, ntfs_index_context *xo, OBJECT_ID_ATTR *old_attr) { OBJECT_ID_INDEX_KEY key; struct OBJECT_ID_INDEX *entry; s64 size; int ret; ret = na->data_size; if (ret) { /* read the existing object id attribute */ size = ntfs_attr_pread(na, 0, sizeof(GUID), old_attr); if (size >= (s64)sizeof(GUID)) { memcpy(&key.object_id, &old_attr->object_id,sizeof(GUID)); if (!ntfs_index_lookup(&key, sizeof(OBJECT_ID_INDEX_KEY), xo)) { entry = (struct OBJECT_ID_INDEX*)xo->entry; memcpy(&old_attr->birth_volume_id, &entry->data.birth_volume_id, sizeof(GUID)); memcpy(&old_attr->birth_object_id, &entry->data.birth_object_id, sizeof(GUID)); memcpy(&old_attr->domain_id, &entry->data.domain_id, sizeof(GUID)); if (ntfs_index_rm(xo)) ret = -1; } } else { ret = -1; errno = ENODATA; } } return (ret); }