Lines Matching refs:vi

25  * @vi:		vfs inode which to test
29 * inode @vi for equality with the ntfs attribute @data.
39 int ntfs_test_inode(struct inode *vi, void *data)
42 struct ntfs_inode *ni = NTFS_I(vi);
44 if (vi->i_ino != na->mft_no)
47 /* If !NInoAttr(ni), @vi is a normal file or directory inode. */
71 * @vi: vfs inode to initialize
72 * @data: data which to initialize @vi to
74 * Initialize the vfs inode @vi with the values from the ntfs attribute @data in
87 static int ntfs_init_locked_inode(struct inode *vi, void *data)
90 struct ntfs_inode *ni = NTFS_I(vi);
92 vi->i_ino = (unsigned long)na->mft_no;
131 static int ntfs_read_locked_inode(struct inode *vi);
132 static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi);
134 struct inode *vi);
154 struct inode *vi;
163 vi = iget5_locked(sb, mft_no, ntfs_test_inode,
165 if (unlikely(!vi))
171 if (inode_state_read_once(vi) & I_NEW) {
172 err = ntfs_read_locked_inode(vi);
173 unlock_new_inode(vi);
180 iput(vi);
181 vi = ERR_PTR(err);
183 return vi;
212 struct inode *vi;
224 vi = iget5_locked(base_vi->i_sb, na.mft_no, ntfs_test_inode,
226 if (unlikely(!vi))
231 if (inode_state_read_once(vi) & I_NEW) {
232 err = ntfs_read_locked_attr_inode(base_vi, vi);
233 unlock_new_inode(vi);
241 iput(vi);
242 vi = ERR_PTR(err);
244 return vi;
269 struct inode *vi;
278 vi = iget5_locked(base_vi->i_sb, na.mft_no, ntfs_test_inode,
280 if (unlikely(!vi))
286 if (inode_state_read_once(vi) & I_NEW) {
287 err = ntfs_read_locked_index_inode(base_vi, vi);
288 unlock_new_inode(vi);
296 iput(vi);
297 vi = ERR_PTR(err);
299 return vi;
649 * @vi: inode to read
652 * described by @vi into memory from the device.
654 * The only fields in @vi that we need to/can look at when the function is
659 * for reading and sets up the necessary @vi fields as well as initializing
672 static int ntfs_read_locked_inode(struct inode *vi)
674 struct ntfs_volume *vol = NTFS_SB(vi->i_sb);
675 struct ntfs_inode *ni = NTFS_I(vi);
690 vi->i_uid = vol->uid;
693 vi->i_uid = GLOBAL_ROOT_UID;
696 vi->i_gid = vol->gid;
699 vi->i_gid = GLOBAL_ROOT_GID;
701 vi->i_mode = 0777;
704 * Initialize the ntfs specific part of @vi special casing
707 if (vi->i_ino != FILE_MFT)
708 ntfs_init_big_inode(vi);
729 ntfs_error(vi->i_sb, "Inode is an extent inode!");
734 vi->i_generation = ni->seq_no = le16_to_cpu(m->sequence_number);
737 ntfs_error(vi->i_sb, "Inode link count is 0!");
740 set_nlink(vi, le16_to_cpu(m->link_count));
743 if (IS_RDONLY(vi))
744 vi->i_mode &= ~0222;
757 ntfs_error(vi->i_sb, "$STANDARD_INFORMATION attribute is missing.");
765 /* Transfer information from the standard information into vi. */
777 inode_set_mtime_to_ts(vi, ntfs2utc(si->last_data_change_time));
783 inode_set_ctime_to_ts(vi, ntfs2utc(si->last_mft_change_time));
788 inode_set_atime_to_ts(vi, ntfs2utc(si->last_access_time));
796 ntfs_error(vi->i_sb, "Failed to lookup attribute list attribute.");
800 if (vi->i_ino == FILE_MFT)
806 ntfs_error(vi->i_sb,
813 ntfs_error(vi->i_sb,
817 ntfs_warning(vi->i_sb,
824 ntfs_error(vi->i_sb, "Attr_list_size is zero");
829 ntfs_error(vi->i_sb,
837 ntfs_error(vi->i_sb, "Attribute list has non zero lowest_vcn.");
844 ntfs_error(vi->i_sb, "Failed to load attribute list attribute.");
856 ntfs_error(vi->i_sb, "Corrupt attribute list.");
865 ntfs_ea_get_wsl_inode(vi, &dev, flags);
873 vi->i_mode |= mode;
875 vi->i_mode &= ~S_IFLNK;
877 vi->i_mode |= S_IFDIR;
879 vi->i_mode |= S_IFREG;
882 vi->i_mode |= S_IFDIR;
884 vi->i_mode |= S_IFREG;
887 if (S_ISDIR(vi->i_mode)) {
892 vi->i_mode &= ~vol->dmask;
894 if (vi->i_nlink > 1)
895 set_nlink(vi, 1);
898 vi->i_mode &= ~vol->fmask;
915 ntfs_error(vi->i_sb, "$INDEX_ROOT attribute is missing.");
944 ntfs_error(vi->i_sb, "Found encrypted and compressed attribute.");
959 ntfs_error(vi->i_sb, "Directory index is corrupt.");
965 ntfs_error(vi->i_sb, "Indexed attribute is not zero.");
970 ntfs_error(vi->i_sb, "Indexed attribute is not $FILE_NAME.");
975 ntfs_error(vi->i_sb,
985 ntfs_error(vi->i_sb, "Index block size (%u) is not a power of two.",
990 ntfs_error(vi->i_sb,
998 ntfs_error(vi->i_sb,
1020 vi->i_size = ni->initialized_size = ni->data_size =
1029 ntfs_set_vfs_operations(vi, vi->i_mode, 0);
1044 vi->i_size = ni->initialized_size =
1047 ntfs_error(vi->i_sb, "Failed to lookup $DATA attribute.");
1054 if (vi->i_ino == FILE_Secure)
1082 ntfs_error(vi->i_sb, "$DATA attribute is missing, err : %d", err);
1092 ntfs_error(vi->i_sb,
1099 ntfs_error(vi->i_sb,
1111 ntfs_error(vi->i_sb, "Found encrypted and compressed data.");
1122 ntfs_error(vi->i_sb,
1133 ntfs_error(vi->i_sb,
1161 ntfs_error(vi->i_sb,
1165 vi->i_size = ni->data_size = le64_to_cpu(a->data.non_resident.data_size);
1169 vi->i_size = ni->data_size = ni->initialized_size = le32_to_cpu(
1174 if (vi->i_size > ni->allocated_size) {
1175 ntfs_error(vi->i_sb,
1187 ntfs_set_vfs_operations(vi, vi->i_mode, dev);
1191 !S_ISFIFO(vi->i_mode) && !S_ISSOCK(vi->i_mode) && !S_ISLNK(vi->i_mode))
1192 vi->i_flags |= S_IMMUTABLE;
1205 if (S_ISREG(vi->i_mode) && (NInoCompressed(ni) || NInoSparse(ni)))
1206 vi->i_blocks = ni->itype.compressed.size >> 9;
1208 vi->i_blocks = ni->allocated_size >> 9;
1210 if (S_ISLNK(vi->i_mode) && ni->target)
1211 vi->i_size = strlen(ni->target);
1235 * @vi: attribute inode to read
1238 * attribute inode described by @vi into memory from the base mft record
1242 * reading and looks up the attribute described by @vi before setting up the
1243 * necessary fields in @vi as well as initializing the ntfs inode.
1253 static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
1255 struct ntfs_volume *vol = NTFS_SB(vi->i_sb);
1256 struct ntfs_inode *ni = NTFS_I(vi), *base_ni = NTFS_I(base_vi);
1264 ntfs_init_big_inode(vi);
1267 vi->i_uid = base_vi->i_uid;
1268 vi->i_gid = base_vi->i_gid;
1269 set_nlink(vi, base_vi->i_nlink);
1270 inode_set_mtime_to_ts(vi, inode_get_mtime(base_vi));
1271 inode_set_ctime_to_ts(vi, inode_get_ctime(base_vi));
1272 inode_set_atime_to_ts(vi, inode_get_atime(base_vi));
1273 vi->i_generation = ni->seq_no = base_ni->seq_no;
1276 vi->i_mode = base_vi->i_mode & ~S_IFMT;
1300 ntfs_error(vi->i_sb,
1305 ntfs_error(vi->i_sb,
1312 ntfs_error(vi->i_sb, "Found unknown compression method.");
1321 ntfs_error(vi->i_sb,
1333 ntfs_error(vi->i_sb, "Found encrypted and compressed data.");
1341 ntfs_error(vi->i_sb,
1346 ntfs_error(vi->i_sb,
1362 ntfs_error(vi->i_sb,
1366 vi->i_size = ni->initialized_size = ni->data_size = le32_to_cpu(
1370 if (vi->i_size > ni->allocated_size) {
1371 ntfs_error(vi->i_sb,
1390 ntfs_error(vi->i_sb,
1413 ntfs_error(vi->i_sb, "First extent of attribute has non-zero lowest_vcn.");
1416 vi->i_size = ni->data_size = le64_to_cpu(a->data.non_resident.data_size);
1420 vi->i_mapping->a_ops = &ntfs_aops;
1422 vi->i_blocks = ni->itype.compressed.size >> 9;
1424 vi->i_blocks = ni->allocated_size >> 9;
1462 * @vi: index inode to read
1465 * index inode described by @vi into memory from the base mft record described
1469 * reading and looks up the attributes relating to the index described by @vi
1470 * before setting up the necessary fields in @vi as well as initializing the
1491 static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
1494 struct ntfs_volume *vol = NTFS_SB(vi->i_sb);
1495 struct ntfs_inode *ni = NTFS_I(vi), *base_ni = NTFS_I(base_vi), *bni;
1506 ntfs_init_big_inode(vi);
1508 vi->i_uid = base_vi->i_uid;
1509 vi->i_gid = base_vi->i_gid;
1510 set_nlink(vi, base_vi->i_nlink);
1511 inode_set_mtime_to_ts(vi, inode_get_mtime(base_vi));
1512 inode_set_ctime_to_ts(vi, inode_get_ctime(base_vi));
1513 inode_set_atime_to_ts(vi, inode_get_atime(base_vi));
1514 vi->i_generation = ni->seq_no = base_ni->seq_no;
1516 vi->i_mode = base_vi->i_mode & ~S_IFMT;
1533 ntfs_error(vi->i_sb, "$INDEX_ROOT attribute is missing.");
1554 ntfs_error(vi->i_sb, "Index is corrupt.");
1563 ntfs_error(vi->i_sb, "Index block size (%u) is not a power of two.",
1568 ntfs_error(vi->i_sb, "Index block size (%u) > PAGE_SIZE (%ld) is not supported.",
1574 ntfs_error(vi->i_sb,
1597 vi->i_size = ni->initialized_size = ni->allocated_size = 0;
1605 ntfs_error(vi->i_sb, "Failed to lookup $INDEX_ALLOCATION attribute.");
1614 ntfs_error(vi->i_sb, "$INDEX_ALLOCATION attribute is resident.");
1627 ntfs_error(vi->i_sb, "$INDEX_ALLOCATION attribute is encrypted.");
1631 ntfs_error(vi->i_sb, "$INDEX_ALLOCATION attribute is sparse.");
1635 ntfs_error(vi->i_sb,
1640 ntfs_error(vi->i_sb,
1644 vi->i_size = ni->data_size = le64_to_cpu(a->data.non_resident.data_size);
1658 ntfs_error(vi->i_sb, "Failed to get bitmap attribute.");
1665 ntfs_error(vi->i_sb,
1671 if ((bvi_size << 3) < (vi->i_size >> ni->itype.index.block_size_bits)) {
1672 ntfs_error(vi->i_sb,
1674 bvi_size << 3, vi->i_size);
1680 ntfs_set_vfs_operations(vi, S_IFDIR, 0);
1681 vi->i_blocks = ni->allocated_size >> 9;
1703 ntfs_error(vi->i_sb,
1801 * @vi: inode to read
1825 int ntfs_read_inode_mount(struct inode *vi)
1828 struct super_block *sb = vi->i_sb;
1830 struct ntfs_inode *ni = NTFS_I(vi);
1840 /* Initialize the ntfs specific part of @vi. */
1841 ntfs_init_big_inode(vi);
1859 vol->mft_ino = vi;
1909 vi->i_generation = ni->seq_no = le16_to_cpu(m->sequence_number);
1912 vi->i_mapping->a_ops = &ntfs_mft_aops;
2026 if (MREF_LE(al_entry->mft_reference) != vi->i_ino) {
2095 vi->i_size = le64_to_cpu(a->data.non_resident.data_size);
2102 if ((vi->i_size >> vol->mft_record_size_bits) >=
2126 err = ntfs_read_locked_inode(vi);
2139 vi->i_uid = GLOBAL_ROOT_UID;
2140 vi->i_gid = GLOBAL_ROOT_GID;
2142 vi->i_mode = S_IFREG;
2144 vi->i_op = &ntfs_empty_inode_ops;
2145 vi->i_fop = &ntfs_empty_file_ops;
2264 * @vi: vfs inode pending annihilation
2272 void ntfs_evict_big_inode(struct inode *vi)
2274 struct ntfs_inode *ni = NTFS_I(vi);
2276 truncate_inode_pages_final(&vi->i_data);
2278 if (!vi->i_nlink) {
2289 ntfs_commit_inode(vi);
2312 clear_inode(vi);
2394 int ntfs_extend_initialized_size(struct inode *vi, const loff_t offset,
2397 struct ntfs_inode *ni = NTFS_I(vi);
2416 err = iomap_zero_range(vi, old_init_size,
2423 err = filemap_write_and_wait_range(vi->i_mapping,
2433 truncate_setsize(vi, old_init_size);
2437 int ntfs_truncate_vfs(struct inode *vi, loff_t new_size, loff_t i_size)
2439 struct ntfs_inode *ni = NTFS_I(vi);
2448 inode_set_mtime_to_ts(vi, inode_set_ctime_current(vi));
2454 * @vi: inode to update standard information
2459 static int ntfs_inode_sync_standard_information(struct inode *vi, struct mft_record *m)
2461 struct ntfs_inode *ni = NTFS_I(vi);
2496 nt = utc2ntfs(inode_get_mtime(vi));
2505 nt = utc2ntfs(inode_get_ctime(vi));
2513 nt = utc2ntfs(inode_get_atime(vi));
2710 * @vi: inode to write out
2723 int __ntfs_write_inode(struct inode *vi, int sync)
2725 struct ntfs_inode *ni = NTFS_I(vi);
2748 /* igrab prevents vi from being evicted while mrec_lock is hold. */
2749 if (igrab(vi) != NULL)
2769 err = ntfs_inode_sync_standard_information(vi, m);
2781 if ((vi->i_sb->s_flags & SB_ACTIVE) && NInoTestClearFileNameDirty(ni))
2794 ntfs_error(vi->i_sb, "write_mft_record failed, err : %d\n", err);
2858 iput(vi);
2866 mark_inode_dirty(vi);
2868 ntfs_error(vi->i_sb, "Failed (error %i): Run chkdsk.", -err);
2872 iput(vi);
3457 s64 ntfs_inode_attr_pread(struct inode *vi, s64 pos, s64 count, u8 *buf)
3459 struct address_space *mapping = vi->i_mapping;
3461 struct ntfs_inode *ni = NTFS_I(vi);
3472 isize = i_size_read(vi);
3486 ntfs_error(vi->i_sb, "Failed to get attr search ctx");
3495 ntfs_error(vi->i_sb, "Failed to look up attr %#x", ni->type);
3534 static inline int ntfs_enlarge_attribute(struct inode *vi, s64 pos, s64 count,
3537 struct ntfs_inode *ni = NTFS_I(vi);
3538 struct super_block *sb = vi->i_sb;
3567 if (likely(i_size_read(vi) < ni->data_size))
3568 i_size_write(vi, ni->data_size);
3576 if (i_size_read(vi) < ni->initialized_size)
3577 i_size_write(vi, ni->initialized_size);
3582 static s64 __ntfs_inode_resident_attr_pwrite(struct inode *vi,
3586 struct ntfs_inode *ni = NTFS_I(vi);
3588 struct address_space *mapping = vi->i_mapping;
3594 ntfs_error(vi->i_sb, "Out of write into resident attr %#x", ni->type);
3608 ntfs_error(vi->i_sb, "Failed to read a page 0 for attr %#x: %d",
3624 static s64 __ntfs_inode_non_resident_attr_pwrite(struct inode *vi,
3629 struct ntfs_inode *ni = NTFS_I(vi);
3630 struct address_space *mapping = vi->i_mapping;
3642 folio = __filemap_get_folio(vi->i_mapping, index,
3653 ntfs_error(vi->i_sb, "Failed to read a page %lu for attr %#x: %ld",
3751 s64 ntfs_inode_attr_pwrite(struct inode *vi, s64 pos, s64 count, u8 *buf, bool sync)
3753 struct ntfs_inode *ni = NTFS_I(vi);
3761 ntfs_error(vi->i_sb, "Failed to get attr search ctx");
3769 ntfs_error(vi->i_sb, "Failed to look up attr %#x", ni->type);
3774 ret = ntfs_enlarge_attribute(vi, pos, count, ctx);
3780 ret = __ntfs_inode_non_resident_attr_pwrite(vi, pos, count, buf, ctx, sync);
3782 ret = __ntfs_inode_resident_attr_pwrite(vi, pos, count, buf, ctx);