Skip to content

Commit a846cd0

Browse files
fs/ntfs3: Reformat code and update terminology
Reformatted the driver code according to the current .clang-format rules and updated description of used terminology. No functional changes intended. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
1 parent 5180138 commit a846cd0

7 files changed

Lines changed: 42 additions & 38 deletions

File tree

fs/ntfs3/dir.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,7 @@ static inline bool ntfs_dir_emit(struct ntfs_sb_info *sbi,
332332
* It does additional locks/reads just to get the type of name.
333333
* Should we use additional mount option to enable branch below?
334334
*/
335-
if (fname->dup.extend_data &&
336-
ino != ni->mi.rno) {
335+
if (fname->dup.extend_data && ino != ni->mi.rno) {
337336
struct inode *inode = ntfs_iget5(sbi->sb, &e->ref, NULL);
338337
if (!IS_ERR_OR_NULL(inode)) {
339338
dt_type = fs_umode_to_dtype(inode->i_mode);

fs/ntfs3/file.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,6 @@ static int ntfs_truncate(struct inode *inode, loff_t new_size)
503503
if (dirty)
504504
mark_inode_dirty(inode);
505505

506-
/*ntfs_flush_inodes(inode->i_sb, inode, NULL);*/
507-
508506
return 0;
509507
}
510508

@@ -1114,8 +1112,8 @@ static ssize_t ntfs_compress_write(struct kiocb *iocb, struct iov_iter *from)
11141112
size_t cp, tail = PAGE_SIZE - off;
11151113

11161114
folio = page_folio(pages[ip]);
1117-
cp = copy_folio_from_iter_atomic(folio, off,
1118-
min(tail, bytes), from);
1115+
cp = copy_folio_from_iter_atomic(
1116+
folio, off, min(tail, bytes), from);
11191117
flush_dcache_folio(folio);
11201118

11211119
copied += cp;
@@ -1312,7 +1310,7 @@ static int ntfs_file_release(struct inode *inode, struct file *file)
13121310
if (sbi->options->prealloc &&
13131311
((file->f_mode & FMODE_WRITE) &&
13141312
atomic_read(&inode->i_writecount) == 1)
1315-
/*
1313+
/*
13161314
* The only file when inode->i_fop = &ntfs_file_operations and
13171315
* init_rwsem(&ni->file.run_lock) is not called explicitly is MFT.
13181316
*

fs/ntfs3/frecord.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3026,8 +3026,8 @@ int ni_rename(struct ntfs_inode *dir_ni, struct ntfs_inode *new_dir_ni,
30263026
err = ni_add_name(new_dir_ni, ni, new_de);
30273027
if (!err) {
30283028
err = ni_remove_name(dir_ni, ni, de, &de2, &undo);
3029-
WARN_ON(err && ni_remove_name(new_dir_ni, ni, new_de, &de2,
3030-
&undo));
3029+
WARN_ON(err &&
3030+
ni_remove_name(new_dir_ni, ni, new_de, &de2, &undo));
30313031
}
30323032

30333033
/*
@@ -3127,7 +3127,8 @@ static bool ni_update_parent(struct ntfs_inode *ni, struct NTFS_DUP_INFO *dup,
31273127
if (attr) {
31283128
const struct REPARSE_POINT *rp;
31293129

3130-
rp = resident_data_ex(attr, sizeof(struct REPARSE_POINT));
3130+
rp = resident_data_ex(attr,
3131+
sizeof(struct REPARSE_POINT));
31313132
/* If ATTR_REPARSE exists 'rp' can't be NULL. */
31323133
if (rp)
31333134
dup->extend_data = rp->ReparseTag;

fs/ntfs3/inode.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -975,9 +975,9 @@ int ntfs_write_begin(const struct kiocb *iocb, struct address_space *mapping,
975975
/*
976976
* ntfs_write_end - Address_space_operations::write_end.
977977
*/
978-
int ntfs_write_end(const struct kiocb *iocb,
979-
struct address_space *mapping, loff_t pos,
980-
u32 len, u32 copied, struct folio *folio, void *fsdata)
978+
int ntfs_write_end(const struct kiocb *iocb, struct address_space *mapping,
979+
loff_t pos, u32 len, u32 copied, struct folio *folio,
980+
void *fsdata)
981981
{
982982
struct inode *inode = mapping->host;
983983
struct ntfs_inode *ni = ntfs_i(inode);
@@ -1099,7 +1099,7 @@ ntfs_create_reparse_buffer(struct ntfs_sb_info *sbi, const char *symname,
10991099
typeof(rp->SymbolicLinkReparseBuffer) *rs;
11001100
bool is_absolute;
11011101

1102-
is_absolute = (strlen(symname) > 1 && symname[1] == ':');
1102+
is_absolute = symname[0] && symname[1] == ':';
11031103

11041104
rp = kzalloc(ntfs_reparse_bytes(2 * size + 2, is_absolute), GFP_NOFS);
11051105
if (!rp)
@@ -1136,17 +1136,19 @@ ntfs_create_reparse_buffer(struct ntfs_sb_info *sbi, const char *symname,
11361136

11371137
/* PrintName + SubstituteName. */
11381138
rs->SubstituteNameOffset = cpu_to_le16(sizeof(short) * err);
1139-
rs->SubstituteNameLength = cpu_to_le16(sizeof(short) * err + (is_absolute ? 8 : 0));
1139+
rs->SubstituteNameLength =
1140+
cpu_to_le16(sizeof(short) * err + (is_absolute ? 8 : 0));
11401141
rs->PrintNameLength = rs->SubstituteNameOffset;
11411142

11421143
/*
11431144
* TODO: Use relative path if possible to allow Windows to
11441145
* parse this path.
1145-
* 0-absolute path 1- relative path (SYMLINK_FLAG_RELATIVE).
1146+
* 0-absolute path, 1- relative path (SYMLINK_FLAG_RELATIVE).
11461147
*/
11471148
rs->Flags = cpu_to_le32(is_absolute ? 0 : SYMLINK_FLAG_RELATIVE);
11481149

1149-
memmove(rp_name + err + (is_absolute ? 4 : 0), rp_name, sizeof(short) * err);
1150+
memmove(rp_name + err + (is_absolute ? 4 : 0), rp_name,
1151+
sizeof(short) * err);
11501152

11511153
if (is_absolute) {
11521154
/* Decorate SubstituteName. */
@@ -1635,7 +1637,8 @@ int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,
16351637
* Use ni_find_attr cause layout of MFT record may be changed
16361638
* in ntfs_init_acl and ntfs_save_wsl_perm.
16371639
*/
1638-
attr = ni_find_attr(ni, NULL, NULL, ATTR_NAME, NULL, 0, NULL, NULL);
1640+
attr = ni_find_attr(ni, NULL, NULL, ATTR_NAME, NULL, 0, NULL,
1641+
NULL);
16391642
if (attr) {
16401643
struct ATTR_FILE_NAME *fn;
16411644

fs/ntfs3/namei.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ static int ntfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
207207
}
208208

209209
/*
210-
* ntfs_mkdir- inode_operations::mkdir
210+
* ntfs_mkdir - inode_operations::mkdir
211211
*/
212212
static struct dentry *ntfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
213213
struct dentry *dentry, umode_t mode)
214214
{
215-
return ERR_PTR(ntfs_create_inode(idmap, dir, dentry, NULL, S_IFDIR | mode, 0,
216-
NULL, 0, NULL));
215+
return ERR_PTR(ntfs_create_inode(idmap, dir, dentry, NULL,
216+
S_IFDIR | mode, 0, NULL, 0, NULL));
217217
}
218218

219219
/*

fs/ntfs3/ntfs_fs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,8 @@ int ni_add_name(struct ntfs_inode *dir_ni, struct ntfs_inode *ni,
584584
struct NTFS_DE *de);
585585

586586
int ni_rename(struct ntfs_inode *dir_ni, struct ntfs_inode *new_dir_ni,
587-
struct ntfs_inode *ni, struct NTFS_DE *de, struct NTFS_DE *new_de);
587+
struct ntfs_inode *ni, struct NTFS_DE *de,
588+
struct NTFS_DE *new_de);
588589

589590
bool ni_is_dirty(struct inode *inode);
590591

@@ -709,8 +710,7 @@ int ntfs_set_size(struct inode *inode, u64 new_size);
709710
int ntfs_get_block(struct inode *inode, sector_t vbn,
710711
struct buffer_head *bh_result, int create);
711712
int ntfs_write_begin(const struct kiocb *iocb, struct address_space *mapping,
712-
loff_t pos, u32 len, struct folio **foliop,
713-
void **fsdata);
713+
loff_t pos, u32 len, struct folio **foliop, void **fsdata);
714714
int ntfs_write_end(const struct kiocb *iocb, struct address_space *mapping,
715715
loff_t pos, u32 len, u32 copied, struct folio *folio,
716716
void *fsdata);

fs/ntfs3/super.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
* mi - MFT inode - One MFT record(usually 1024 bytes or 4K), consists of attributes.
1717
* ni - NTFS inode - Extends linux inode. consists of one or more mft inodes.
1818
* index - unit inside directory - 2K, 4K, <=page size, does not depend on cluster size.
19+
* resident attribute - Attribute with content stored directly in the MFT record
20+
* non-resident attribute - Attribute with content stored in clusters
21+
* data_size - Size of attribute content in bytes. Equal to inode->i_size
22+
* valid_size - Number of bytes written to the non-resident attribute
23+
* allocated_size - Total size of clusters allocated for non-resident content
24+
* total_size - Actual size of allocated clusters for sparse or compressed attributes
25+
* - Constraint: valid_size <= data_size <= allocated_size
1926
*
2027
* WSL - Windows Subsystem for Linux
2128
* https://docs.microsoft.com/en-us/windows/wsl/file-permissions
@@ -288,10 +295,8 @@ static const struct fs_parameter_spec ntfs_fs_parameters[] = {
288295
/*
289296
* Load nls table or if @nls is utf8 then return NULL.
290297
*
291-
* It is good idea to use here "const char *nls".
292-
* But load_nls accepts "char*".
293298
*/
294-
static struct nls_table *ntfs_load_nls(char *nls)
299+
static struct nls_table *ntfs_load_nls(const char *nls)
295300
{
296301
struct nls_table *ret;
297302

@@ -566,10 +571,8 @@ static void ntfs_create_procdir(struct super_block *sb)
566571
if (e) {
567572
struct ntfs_sb_info *sbi = sb->s_fs_info;
568573

569-
proc_create_data("volinfo", 0444, e,
570-
&ntfs3_volinfo_fops, sb);
571-
proc_create_data("label", 0644, e,
572-
&ntfs3_label_fops, sb);
574+
proc_create_data("volinfo", 0444, e, &ntfs3_volinfo_fops, sb);
575+
proc_create_data("label", 0644, e, &ntfs3_label_fops, sb);
573576
sbi->procdir = e;
574577
}
575578
}
@@ -600,10 +603,12 @@ static void ntfs_remove_proc_root(void)
600603
}
601604
}
602605
#else
603-
static void ntfs_create_procdir(struct super_block *sb) {}
604-
static void ntfs_remove_procdir(struct super_block *sb) {}
605-
static void ntfs_create_proc_root(void) {}
606-
static void ntfs_remove_proc_root(void) {}
606+
// clang-format off
607+
static void ntfs_create_procdir(struct super_block *sb){}
608+
static void ntfs_remove_procdir(struct super_block *sb){}
609+
static void ntfs_create_proc_root(void){}
610+
static void ntfs_remove_proc_root(void){}
611+
// clang-format on
607612
#endif
608613

609614
static struct kmem_cache *ntfs_inode_cachep;
@@ -1223,8 +1228,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
12231228
sb->s_export_op = &ntfs_export_ops;
12241229
sb->s_time_gran = NTFS_TIME_GRAN; // 100 nsec
12251230
sb->s_xattr = ntfs_xattr_handlers;
1226-
if (options->nocase)
1227-
set_default_d_op(sb, &ntfs_dentry_ops);
1231+
set_default_d_op(sb, options->nocase ? &ntfs_dentry_ops : NULL);
12281232

12291233
options->nls = ntfs_load_nls(options->nls_name);
12301234
if (IS_ERR(options->nls)) {
@@ -1643,7 +1647,6 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
16431647
out:
16441648
ntfs3_put_sbi(sbi);
16451649
kfree(boot2);
1646-
ntfs3_put_sbi(sbi);
16471650
return err;
16481651
}
16491652

0 commit comments

Comments
 (0)