2019-09-09 17:52:25

by Valentin Vidić

[permalink] [raw]
Subject: [PATCH v3 1/4] staging: exfat: drop unused function parameter

sbi parameter not used inside the function so remove it.
Also cleanup unused variables generated by this change.

Signed-off-by: Valentin Vidic <[email protected]>
---
v2: split up into multiple patches
v3: split up some more
fix if statement braces
add utc offset fields

drivers/staging/exfat/exfat_super.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
index 60dfea73a7a4..3a58907caf7c 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -56,8 +56,7 @@ static void exfat_write_super(struct super_block *sb);
#define UNIX_SECS_2108 4354819200L

/* Convert a FAT time/date pair to a UNIX date (seconds since 1 1 70). */
-static void exfat_time_fat2unix(struct exfat_sb_info *sbi,
- struct timespec64 *ts, struct date_time_t *tp)
+static void exfat_time_fat2unix(struct timespec64 *ts, struct date_time_t *tp)
{
ts->tv_sec = mktime64(tp->Year + 1980, tp->Month + 1, tp->Day,
tp->Hour, tp->Minute, tp->Second);
@@ -66,8 +65,7 @@ static void exfat_time_fat2unix(struct exfat_sb_info *sbi,
}

/* Convert linear UNIX date to a FAT time/date pair. */
-static void exfat_time_unix2fat(struct exfat_sb_info *sbi,
- struct timespec64 *ts, struct date_time_t *tp)
+static void exfat_time_unix2fat(struct timespec64 *ts, struct date_time_t *tp)
{
time64_t second = ts->tv_sec;
struct tm tm;
@@ -3349,9 +3347,9 @@ static int exfat_fill_inode(struct inode *inode, struct file_id_t *fid)
inode->i_blocks = ((i_size_read(inode) + (p_fs->cluster_size - 1))
& ~((loff_t)p_fs->cluster_size - 1)) >> 9;

- exfat_time_fat2unix(sbi, &inode->i_mtime, &info.ModifyTimestamp);
- exfat_time_fat2unix(sbi, &inode->i_ctime, &info.CreateTimestamp);
- exfat_time_fat2unix(sbi, &inode->i_atime, &info.AccessTimestamp);
+ exfat_time_fat2unix(&inode->i_mtime, &info.ModifyTimestamp);
+ exfat_time_fat2unix(&inode->i_ctime, &info.CreateTimestamp);
+ exfat_time_fat2unix(&inode->i_atime, &info.AccessTimestamp);

return 0;
}
@@ -3412,8 +3410,6 @@ static void exfat_destroy_inode(struct inode *inode)

static int exfat_write_inode(struct inode *inode, struct writeback_control *wbc)
{
- struct super_block *sb = inode->i_sb;
- struct exfat_sb_info *sbi = EXFAT_SB(sb);
struct dir_entry_t info;

if (inode->i_ino == EXFAT_ROOT_INO)
@@ -3422,9 +3418,9 @@ static int exfat_write_inode(struct inode *inode, struct writeback_control *wbc)
info.Attr = exfat_make_attr(inode);
info.Size = i_size_read(inode);

- exfat_time_unix2fat(sbi, &inode->i_mtime, &info.ModifyTimestamp);
- exfat_time_unix2fat(sbi, &inode->i_ctime, &info.CreateTimestamp);
- exfat_time_unix2fat(sbi, &inode->i_atime, &info.AccessTimestamp);
+ exfat_time_unix2fat(&inode->i_mtime, &info.ModifyTimestamp);
+ exfat_time_unix2fat(&inode->i_ctime, &info.CreateTimestamp);
+ exfat_time_unix2fat(&inode->i_atime, &info.AccessTimestamp);

ffsWriteStat(inode, &info);

--
2.20.1


2019-09-09 18:06:43

by Valentin Vidić

[permalink] [raw]
Subject: [PATCH v3 4/4] staging: exfat: add millisecond support

Use create_time_ms and modify_time_ms fields to store the millisecond
part of the file timestamp with the precision of 10 ms.

Signed-off-by: Valentin Vidic <[email protected]>
---
drivers/staging/exfat/exfat_core.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)

diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c
index d21f68d786b8..d6e33a485d5f 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -1139,6 +1139,7 @@ void exfat_set_entry_size(struct dentry_t *p_entry, u64 size)
void fat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
u8 mode)
{
+ u8 ms = 0;
u16 t = 0x00, d = 0x21;
struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry;

@@ -1146,6 +1147,7 @@ void fat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
case TM_CREATE:
t = GET16_A(ep->create_time);
d = GET16_A(ep->create_date);
+ ms = ep->create_time_ms * 10;
break;
case TM_MODIFY:
t = GET16_A(ep->modify_time);
@@ -1159,11 +1161,17 @@ void fat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
tp->day = (d & 0x001F);
tp->mon = (d >> 5) & 0x000F;
tp->year = (d >> 9);
+
+ if (ms >= 1000) {
+ ms -= 1000;
+ tp->sec++;
+ }
}

void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
u8 mode)
{
+ u8 ms = 0;
u16 t = 0x00, d = 0x21;
struct file_dentry_t *ep = (struct file_dentry_t *)p_entry;

@@ -1171,10 +1179,12 @@ void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
case TM_CREATE:
t = GET16_A(ep->create_time);
d = GET16_A(ep->create_date);
+ ms = ep->create_time_ms * 10;
break;
case TM_MODIFY:
t = GET16_A(ep->modify_time);
d = GET16_A(ep->modify_date);
+ ms = ep->modify_time_ms * 10;
break;
case TM_ACCESS:
t = GET16_A(ep->access_time);
@@ -1188,21 +1198,32 @@ void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
tp->day = (d & 0x001F);
tp->mon = (d >> 5) & 0x000F;
tp->year = (d >> 9);
+
+ if (ms >= 1000) {
+ ms -= 1000;
+ tp->sec++;
+ }
}

void fat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
u8 mode)
{
+ u8 ms;
u16 t, d;
struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry;

t = (tp->hour << 11) | (tp->min << 5) | (tp->sec >> 1);
d = (tp->year << 9) | (tp->mon << 5) | tp->day;

+ ms = tp->millisec;
+ if (tp->sec & 1)
+ ms += 1000;
+
switch (mode) {
case TM_CREATE:
SET16_A(ep->create_time, t);
SET16_A(ep->create_date, d);
+ ep->create_time_ms = ms / 10;
break;
case TM_MODIFY:
SET16_A(ep->modify_time, t);
@@ -1214,20 +1235,27 @@ void fat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
u8 mode)
{
+ u8 ms;
u16 t, d;
struct file_dentry_t *ep = (struct file_dentry_t *)p_entry;

t = (tp->hour << 11) | (tp->min << 5) | (tp->sec >> 1);
d = (tp->year << 9) | (tp->mon << 5) | tp->day;

+ ms = tp->millisec;
+ if (tp->sec & 1)
+ ms += 1000;
+
switch (mode) {
case TM_CREATE:
SET16_A(ep->create_time, t);
SET16_A(ep->create_date, d);
+ ep->create_time_ms = ms / 10;
break;
case TM_MODIFY:
SET16_A(ep->modify_time, t);
SET16_A(ep->modify_date, d);
+ ep->modify_time_ms = ms / 10;
break;
case TM_ACCESS:
SET16_A(ep->access_time, t);
--
2.20.1

2019-09-09 18:16:06

by Valdis Klētnieks

[permalink] [raw]
Subject: Re: [PATCH v3 1/4] staging: exfat: drop unused function parameter

On Sun, 08 Sep 2019 17:35:36 -0000, Valentin Vidic said:
> sbi parameter not used inside the function so remove it.
> Also cleanup unused variables generated by this change.

Tread carefully with this sort of patch - there's still a lot of places in the code
where we have matching pairs of exfat_foo() and fat_foo() functions which need
to have the same signatures because they're called through a function pointer.

This particular one looks OK, but there's other functions that come in pairs that
you need to watch out for...



Attachments:
(No filename) (849.00 B)