Skip to content

Commit 5c914b8

Browse files
committed
Merge branch 'melt-rebase-ntfs3' into melt-rebase
2 parents 811861b + 8eec6bd commit 5c914b8

File tree

8 files changed

+20
-17
lines changed

8 files changed

+20
-17
lines changed

fs/ntfs3/dir.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ static int ntfs_readdir(struct file *file, struct dir_context *ctx)
475475
vbo = (u64)bit << index_bits;
476476
if (vbo >= i_size) {
477477
ntfs_inode_err(dir, "Looks like your dir is corrupt");
478+
ctx->pos = eod;
478479
err = -EINVAL;
479480
goto out;
480481
}

fs/ntfs3/fslog.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,8 @@ static int read_log_page(struct ntfs_log *log, u32 vbo,
11811181
static int log_read_rst(struct ntfs_log *log, u32 l_size, bool first,
11821182
struct restart_info *info)
11831183
{
1184-
u32 skip, vbo;
1184+
u32 skip;
1185+
u64 vbo;
11851186
struct RESTART_HDR *r_page = NULL;
11861187

11871188
/* Determine which restart area we are looking for. */

fs/ntfs3/index.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,11 @@ static int indx_add_allocate(struct ntfs_index *indx, struct ntfs_inode *ni,
15381538
goto out1;
15391539
}
15401540

1541+
if (data_size <= le64_to_cpu(alloc->nres.data_size)) {
1542+
/* Reuse index. */
1543+
goto out;
1544+
}
1545+
15411546
/* Increase allocation. */
15421547
err = attr_set_size(ni, ATTR_ALLOC, in->name, in->name_len,
15431548
&indx->alloc_run, data_size, &data_size, true,
@@ -1548,6 +1553,7 @@ static int indx_add_allocate(struct ntfs_index *indx, struct ntfs_inode *ni,
15481553
goto out1;
15491554
}
15501555

1556+
out:
15511557
*vbn = bit << indx->idx2vbn_bits;
15521558

15531559
return 0;

fs/ntfs3/inode.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static struct inode *ntfs_read_mft(struct inode *inode,
3737
bool is_dir;
3838
unsigned long ino = inode->i_ino;
3939
u32 rp_fa = 0, asize, t32;
40-
u16 roff, rsize, names = 0;
40+
u16 roff, rsize, names = 0, links = 0;
4141
const struct ATTR_FILE_NAME *fname = NULL;
4242
const struct INDEX_ROOT *root;
4343
struct REPARSE_DATA_BUFFER rp; // 0x18 bytes
@@ -190,11 +190,12 @@ static struct inode *ntfs_read_mft(struct inode *inode,
190190
rsize < SIZEOF_ATTRIBUTE_FILENAME)
191191
goto out;
192192

193+
names += 1;
193194
fname = Add2Ptr(attr, roff);
194195
if (fname->type == FILE_NAME_DOS)
195196
goto next_attr;
196197

197-
names += 1;
198+
links += 1;
198199
if (name && name->len == fname->name_len &&
199200
!ntfs_cmp_names_cpu(name, (struct le_str *)&fname->name_len,
200201
NULL, false))
@@ -421,7 +422,7 @@ static struct inode *ntfs_read_mft(struct inode *inode,
421422
ni->mi.dirty = true;
422423
}
423424

424-
set_nlink(inode, names);
425+
set_nlink(inode, links);
425426

426427
if (S_ISDIR(mode)) {
427428
ni->std_fa |= FILE_ATTRIBUTE_DIRECTORY;

fs/ntfs3/ntfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct GUID {
5959
struct cpu_str {
6060
u8 len;
6161
u8 unused;
62-
u16 name[10];
62+
u16 name[];
6363
};
6464

6565
struct le_str {

fs/ntfs3/record.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -508,16 +508,9 @@ bool mi_remove_attr(struct ntfs_inode *ni, struct mft_inode *mi,
508508
if (aoff + asize > used)
509509
return false;
510510

511-
if (ni && is_attr_indexed(attr)) {
511+
if (ni && is_attr_indexed(attr) && attr->type == ATTR_NAME) {
512512
u16 links = le16_to_cpu(ni->mi.mrec->hard_links);
513-
struct ATTR_FILE_NAME *fname =
514-
attr->type != ATTR_NAME ?
515-
NULL :
516-
resident_data_ex(attr,
517-
SIZEOF_ATTRIBUTE_FILENAME);
518-
if (fname && fname->type == FILE_NAME_DOS) {
519-
/* Do not decrease links count deleting DOS name. */
520-
} else if (!links) {
513+
if (!links) {
521514
/* minor error. Not critical. */
522515
} else {
523516
ni->mi.mrec->hard_links = cpu_to_le16(links - 1);

fs/ntfs3/super.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,8 +1448,6 @@ static int __init init_ntfs_fs(void)
14481448
{
14491449
int err;
14501450

1451-
pr_info("ntfs3: Max link count %u\n", NTFS_LINK_MAX);
1452-
14531451
if (IS_ENABLED(CONFIG_NTFS3_FS_POSIX_ACL))
14541452
pr_info("ntfs3: Enabled Linux POSIX ACLs support\n");
14551453
if (IS_ENABLED(CONFIG_NTFS3_64BIT_CLUSTER))

fs/ntfs3/xattr.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,11 @@ static ssize_t ntfs_list_ea(struct ntfs_inode *ni, char *buffer,
217217
if (!ea->name_len)
218218
break;
219219

220-
if (ea->name_len > ea_size)
220+
if (ea->name_len > ea_size) {
221+
ntfs_set_state(ni->mi.sbi, NTFS_DIRTY_ERROR);
222+
err = -EINVAL; /* corrupted fs */
221223
break;
224+
}
222225

223226
if (buffer) {
224227
/* Check if we can use field ea->name */

0 commit comments

Comments
 (0)