Skip to content

Commit c4a2c08

Browse files
jtlaytonSteve French
authored andcommitted
cifs: make cnvrtDosUnixTm take a little-endian args and an offset
The callers primarily end up converting the args from le anyway. Also, most of the callers end up needing to add an offset to the result. The exception to these rules is cnvrtDosCifsTm, but there are no callers of that function, so we might as well remove it. Signed-off-by: Jeff Layton <jlayton@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Steve French <sfrench@us.ibm.com>
1 parent 07119a4 commit c4a2c08

4 files changed

Lines changed: 18 additions & 34 deletions

File tree

‎fs/cifs/cifsproto.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ extern void DeleteOplockQEntry(struct oplock_q_entry *);
9292
extern void DeleteTconOplockQEntries(struct cifsTconInfo *);
9393
extern struct timespec cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601);
9494
extern u64 cifs_UnixTimeToNT(struct timespec);
95-
extern __le64 cnvrtDosCifsTm(__u16 date, __u16 time);
96-
extern struct timespec cnvrtDosUnixTm(__u16 date, __u16 time);
95+
extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
96+
int offset);
9797

9898
extern int cifs_posix_open(char *full_path, struct inode **pinode,
9999
struct super_block *sb, int mode, int oflags,

‎fs/cifs/cifssmb.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,8 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
524524
int val, seconds, remain, result;
525525
struct timespec ts, utc;
526526
utc = CURRENT_TIME;
527-
ts = cnvrtDosUnixTm(le16_to_cpu(rsp->SrvTime.Date),
528-
le16_to_cpu(rsp->SrvTime.Time));
527+
ts = cnvrtDosUnixTm(rsp->SrvTime.Date,
528+
rsp->SrvTime.Time, 0);
529529
cFYI(1, ("SrvTime %d sec since 1970 (utc: %d) diff: %d",
530530
(int)ts.tv_sec, (int)utc.tv_sec,
531531
(int)(utc.tv_sec - ts.tv_sec)));

‎fs/cifs/netmisc.c‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -883,16 +883,12 @@ cifs_UnixTimeToNT(struct timespec t)
883883
static int total_days_of_prev_months[] =
884884
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
885885

886-
887-
__le64 cnvrtDosCifsTm(__u16 date, __u16 time)
888-
{
889-
return cpu_to_le64(cifs_UnixTimeToNT(cnvrtDosUnixTm(date, time)));
890-
}
891-
892-
struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
886+
struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset)
893887
{
894888
struct timespec ts;
895889
int sec, min, days, month, year;
890+
u16 date = le16_to_cpu(le_date);
891+
u16 time = le16_to_cpu(le_time);
896892
SMB_TIME *st = (SMB_TIME *)&time;
897893
SMB_DATE *sd = (SMB_DATE *)&date;
898894

@@ -933,7 +929,7 @@ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
933929
days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0);
934930
sec += 24 * 60 * 60 * days;
935931

936-
ts.tv_sec = sec;
932+
ts.tv_sec = sec + offset;
937933

938934
/* cFYI(1,("sec after cnvrt dos to unix time %d",sec)); */
939935

‎fs/cifs/readdir.c‎

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,6 @@ construct_dentry(struct qstr *qstring, struct file *file,
115115
return rc;
116116
}
117117

118-
static void AdjustForTZ(struct cifsTconInfo *tcon, struct inode *inode)
119-
{
120-
if ((tcon) && (tcon->ses) && (tcon->ses->server)) {
121-
inode->i_ctime.tv_sec += tcon->ses->server->timeAdj;
122-
inode->i_mtime.tv_sec += tcon->ses->server->timeAdj;
123-
inode->i_atime.tv_sec += tcon->ses->server->timeAdj;
124-
}
125-
return;
126-
}
127-
128-
129118
static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
130119
char *buf, unsigned int *pobject_type, int isNewInode)
131120
{
@@ -156,20 +145,19 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
156145
tmp_inode->i_ctime =
157146
cifs_NTtimeToUnix(pfindData->ChangeTime);
158147
} else { /* legacy, OS2 and DOS style */
159-
/* struct timespec ts;*/
148+
int offset = cifs_sb->tcon->ses->server->timeAdj;
160149
FIND_FILE_STANDARD_INFO *pfindData =
161150
(FIND_FILE_STANDARD_INFO *)buf;
162151

163-
tmp_inode->i_mtime = cnvrtDosUnixTm(
164-
le16_to_cpu(pfindData->LastWriteDate),
165-
le16_to_cpu(pfindData->LastWriteTime));
166-
tmp_inode->i_atime = cnvrtDosUnixTm(
167-
le16_to_cpu(pfindData->LastAccessDate),
168-
le16_to_cpu(pfindData->LastAccessTime));
169-
tmp_inode->i_ctime = cnvrtDosUnixTm(
170-
le16_to_cpu(pfindData->LastWriteDate),
171-
le16_to_cpu(pfindData->LastWriteTime));
172-
AdjustForTZ(cifs_sb->tcon, tmp_inode);
152+
tmp_inode->i_mtime = cnvrtDosUnixTm(pfindData->LastWriteDate,
153+
pfindData->LastWriteTime,
154+
offset);
155+
tmp_inode->i_atime = cnvrtDosUnixTm(pfindData->LastAccessDate,
156+
pfindData->LastAccessTime,
157+
offset);
158+
tmp_inode->i_ctime = cnvrtDosUnixTm(pfindData->LastWriteDate,
159+
pfindData->LastWriteTime,
160+
offset);
173161
attr = le16_to_cpu(pfindData->Attributes);
174162
allocation_size = le32_to_cpu(pfindData->AllocationSize);
175163
end_of_file = le32_to_cpu(pfindData->DataSize);

0 commit comments

Comments
 (0)