Skip to content

Commit

Permalink
Update drivers for 6.6, 6.8 and 6.9
Browse files Browse the repository at this point in the history
Signed-off-by: EasyNet <[email protected]>
  • Loading branch information
EasyNetDev committed May 23, 2024
1 parent 66dc2f1 commit 96f2b73
Show file tree
Hide file tree
Showing 24 changed files with 469 additions and 232 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ export DRIVER_NAME := ntfs3

# Define SYMBOLS / MACROS for which modules to build
export CONFIG_NTFS3_FS=m
export CONFIG_NTFS3_LZX_XPRESS=y
export CONFIG_NTFS3_64BIT_CLUSTER=y
export CONFIG_NTFS3_LZX_XPRESS=y
export CONFIG_NTFS3_FS_POSIX_ACL=y
# Kerne 6.9 removed support for old NTFS driver and is replacing with this one.
export CONFIG_NTFS_FS=y

# Add necessary macros to the compiler depending on whan we get on make command
ifeq ($(CONFIG_NTFS3_FS),m)
Expand Down
8 changes: 8 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
ntfs3-dkms (1.0.7) unstable; urgency=medium

* Update NTFS3 for Kernel 6.6.31
* Update NTFS3 for Kernel 6.8.10
* Update NTFS3 for Kernel 6.9.1

-- EasyNetDev <[email protected]> Thu, 23 May 2024 17:03:20 +0200

ntfs3-dkms (1.0.6) unstable; urgency=medium

* Update NTFS3 for Kernel 6.7
Expand Down
45 changes: 28 additions & 17 deletions ntfs3/6.6/attrib.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,
struct runs_tree *run = &ni->file.run;
struct ntfs_sb_info *sbi;
u8 cluster_bits;
struct ATTRIB *attr = NULL, *attr_b;
struct ATTRIB *attr, *attr_b;
struct ATTR_LIST_ENTRY *le, *le_b;
struct mft_inode *mi, *mi_b;
CLST hint, svcn, to_alloc, evcn1, next_svcn, asize, end, vcn0, alen;
Expand All @@ -904,12 +904,8 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,
*len = 0;
up_read(&ni->file.run_lock);

if (*len) {
if (*lcn != SPARSE_LCN || !new)
return 0; /* Fast normal way without allocation. */
else if (clen > *len)
clen = *len;
}
if (*len && (*lcn != SPARSE_LCN || !new))
return 0; /* Fast normal way without allocation. */

/* No cluster in cache or we need to allocate cluster in hole. */
sbi = ni->mi.sbi;
Expand All @@ -918,6 +914,17 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,
ni_lock(ni);
down_write(&ni->file.run_lock);

/* Repeat the code above (under write lock). */
if (!run_lookup_entry(run, vcn, lcn, len, NULL))
*len = 0;

if (*len) {
if (*lcn != SPARSE_LCN || !new)
goto out; /* normal way without allocation. */
if (clen > *len)
clen = *len;
}

le_b = NULL;
attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL, 0, NULL, &mi_b);
if (!attr_b) {
Expand Down Expand Up @@ -1736,8 +1743,10 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size,
le_b = NULL;
attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL,
0, NULL, &mi_b);
if (!attr_b)
return -ENOENT;
if (!attr_b) {
err = -ENOENT;
goto out;
}

attr = attr_b;
le = le_b;
Expand Down Expand Up @@ -1818,13 +1827,15 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size,
ok:
run_truncate_around(run, vcn);
out:
if (new_valid > data_size)
new_valid = data_size;
if (attr_b) {
if (new_valid > data_size)
new_valid = data_size;

valid_size = le64_to_cpu(attr_b->nres.valid_size);
if (new_valid != valid_size) {
attr_b->nres.valid_size = cpu_to_le64(valid_size);
mi_b->dirty = true;
valid_size = le64_to_cpu(attr_b->nres.valid_size);
if (new_valid != valid_size) {
attr_b->nres.valid_size = cpu_to_le64(valid_size);
mi_b->dirty = true;
}
}

return err;
Expand Down Expand Up @@ -2073,7 +2084,7 @@ int attr_collapse_range(struct ntfs_inode *ni, u64 vbo, u64 bytes)

/* Update inode size. */
ni->i_valid = valid_size;
ni->vfs_inode.i_size = data_size;
i_size_write(&ni->vfs_inode, data_size);
inode_set_bytes(&ni->vfs_inode, total_size);
ni->ni_flags |= NI_FLAG_UPDATE_PARENT;
mark_inode_dirty(&ni->vfs_inode);
Expand Down Expand Up @@ -2488,7 +2499,7 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes)
mi_b->dirty = true;

done:
ni->vfs_inode.i_size += bytes;
i_size_write(&ni->vfs_inode, ni->vfs_inode.i_size + bytes);
ni->ni_flags |= NI_FLAG_UPDATE_PARENT;
mark_inode_dirty(&ni->vfs_inode);

Expand Down
12 changes: 6 additions & 6 deletions ntfs3/6.6/attrlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static inline bool al_is_valid_le(const struct ntfs_inode *ni,
void al_destroy(struct ntfs_inode *ni)
{
run_close(&ni->attr_list.run);
kfree(ni->attr_list.le);
kvfree(ni->attr_list.le);
ni->attr_list.le = NULL;
ni->attr_list.size = 0;
ni->attr_list.dirty = false;
Expand Down Expand Up @@ -127,12 +127,13 @@ struct ATTR_LIST_ENTRY *al_enumerate(struct ntfs_inode *ni,
{
size_t off;
u16 sz;
const unsigned le_min_size = le_size(0);

if (!le) {
le = ni->attr_list.le;
} else {
sz = le16_to_cpu(le->size);
if (sz < sizeof(struct ATTR_LIST_ENTRY)) {
if (sz < le_min_size) {
/* Impossible 'cause we should not return such le. */
return NULL;
}
Expand All @@ -141,16 +142,15 @@ struct ATTR_LIST_ENTRY *al_enumerate(struct ntfs_inode *ni,

/* Check boundary. */
off = PtrOffset(ni->attr_list.le, le);
if (off + sizeof(struct ATTR_LIST_ENTRY) > ni->attr_list.size) {
if (off + le_min_size > ni->attr_list.size) {
/* The regular end of list. */
return NULL;
}

sz = le16_to_cpu(le->size);

/* Check le for errors. */
if (sz < sizeof(struct ATTR_LIST_ENTRY) ||
off + sz > ni->attr_list.size ||
if (sz < le_min_size || off + sz > ni->attr_list.size ||
sz < le->name_off + le->name_len * sizeof(short)) {
return NULL;
}
Expand Down Expand Up @@ -318,7 +318,7 @@ int al_add_le(struct ntfs_inode *ni, enum ATTR_TYPE type, const __le16 *name,
memcpy(ptr, al->le, off);
memcpy(Add2Ptr(ptr, off + sz), le, old_size - off);
le = Add2Ptr(ptr, off);
kfree(al->le);
kvfree(al->le);
al->le = ptr;
} else {
memmove(Add2Ptr(le, sz), le, old_size - off);
Expand Down
4 changes: 2 additions & 2 deletions ntfs3/6.6/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void wnd_close(struct wnd_bitmap *wnd)
{
struct rb_node *node, *next;

kfree(wnd->free_bits);
kvfree(wnd->free_bits);
wnd->free_bits = NULL;
run_close(&wnd->run);

Expand Down Expand Up @@ -1360,7 +1360,7 @@ int wnd_extend(struct wnd_bitmap *wnd, size_t new_bits)
memcpy(new_free, wnd->free_bits, wnd->nwnd * sizeof(short));
memset(new_free + wnd->nwnd, 0,
(new_wnd - wnd->nwnd) * sizeof(short));
kfree(wnd->free_bits);
kvfree(wnd->free_bits);
wnd->free_bits = new_free;
}

Expand Down
40 changes: 28 additions & 12 deletions ntfs3/6.6/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,31 @@ static inline int ntfs_filldir(struct ntfs_sb_info *sbi, struct ntfs_inode *ni,
return 0;
}

/* NTFS: symlinks are "dir + reparse" or "file + reparse" */
if (fname->dup.fa & FILE_ATTRIBUTE_REPARSE_POINT)
dt_type = DT_LNK;
else
dt_type = (fname->dup.fa & FILE_ATTRIBUTE_DIRECTORY) ? DT_DIR : DT_REG;
/*
* NTFS: symlinks are "dir + reparse" or "file + reparse"
* Unfortunately reparse attribute is used for many purposes (several dozens).
* It is not possible here to know is this name symlink or not.
* To get exactly the type of name we should to open inode (read mft).
* getattr for opened file (fstat) correctly returns symlink.
*/
dt_type = (fname->dup.fa & FILE_ATTRIBUTE_DIRECTORY) ? DT_DIR : DT_REG;

/*
* It is not reliable to detect the type of name using duplicated information
* stored in parent directory.
* The only correct way to get the type of name - read MFT record and find ATTR_STD.
* The code below is not good idea.
* It does additional locks/reads just to get the type of name.
* Should we use additional mount option to enable branch below?
*/
if ((fname->dup.fa & FILE_ATTRIBUTE_REPARSE_POINT) &&
ino != ni->mi.rno) {
struct inode *inode = ntfs_iget5(sbi->sb, &e->ref, NULL);
if (!IS_ERR_OR_NULL(inode)) {
dt_type = fs_umode_to_dtype(inode->i_mode);
iput(inode);
}
}

return !dir_emit(ctx, (s8 *)name, name_len, ino, dt_type);
}
Expand Down Expand Up @@ -495,11 +515,9 @@ static int ntfs_dir_count(struct inode *dir, bool *is_empty, size_t *dirs,
struct INDEX_HDR *hdr;
const struct ATTR_FILE_NAME *fname;
u32 e_size, off, end;
u64 vbo = 0;
size_t drs = 0, fles = 0, bit = 0;
loff_t i_size = ni->vfs_inode.i_size;
struct indx_node *node = NULL;
u8 index_bits = ni->dir.index_bits;
size_t max_indx = i_size_read(&ni->vfs_inode) >> ni->dir.index_bits;

if (is_empty)
*is_empty = true;
Expand Down Expand Up @@ -543,7 +561,7 @@ static int ntfs_dir_count(struct inode *dir, bool *is_empty, size_t *dirs,
fles += 1;
}

if (vbo >= i_size)
if (bit >= max_indx)
goto out;

err = indx_used_bit(&ni->dir, ni, &bit);
Expand All @@ -553,8 +571,7 @@ static int ntfs_dir_count(struct inode *dir, bool *is_empty, size_t *dirs,
if (bit == MINUS_ONE_T)
goto out;

vbo = (u64)bit << index_bits;
if (vbo >= i_size)
if (bit >= max_indx)
goto out;

err = indx_read(&ni->dir, ni, bit << ni->dir.idx2vbn_bits,
Expand All @@ -564,7 +581,6 @@ static int ntfs_dir_count(struct inode *dir, bool *is_empty, size_t *dirs,

hdr = &node->index->ihdr;
bit += 1;
vbo = (u64)bit << ni->dir.idx2vbn_bits;
}

out:
Expand Down
Loading

0 comments on commit 96f2b73

Please sign in to comment.