Skip to content

Commit d7933ab

Browse files
committed
Merge branch 'for-next' of git://git.samba.org/sfrench/cifs-2.6
Pull CIFS fixes from Steve French: "Small set of misc cifs/smb3 fixes" * 'for-next' of git://git.samba.org/sfrench/cifs-2.6: [CIFS] fix mount failure with broken pathnames when smb3 mount with mapchars option cifs: revalidate mapping prior to satisfying read_iter request with cache=loose fs/cifs: fix regression in cifs_create_mf_symlink()
2 parents 2a80ff8 + ce36d9a commit d7933ab

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

fs/cifs/cifs_unicode.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,20 +290,20 @@ int
290290
cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
291291
const struct nls_table *cp, int mapChars)
292292
{
293-
int i, j, charlen;
293+
int i, charlen;
294+
int j = 0;
294295
char src_char;
295296
__le16 dst_char;
296297
wchar_t tmp;
297298

298299
if (!mapChars)
299300
return cifs_strtoUTF16(target, source, PATH_MAX, cp);
300301

301-
for (i = 0, j = 0; i < srclen; j++) {
302+
for (i = 0; i < srclen; j++) {
302303
src_char = source[i];
303304
charlen = 1;
304305
switch (src_char) {
305306
case 0:
306-
put_unaligned(0, &target[j]);
307307
goto ctoUTF16_out;
308308
case ':':
309309
dst_char = cpu_to_le16(UNI_COLON);
@@ -350,6 +350,7 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
350350
}
351351

352352
ctoUTF16_out:
353+
put_unaligned(0, &target[j]); /* Null terminate target unicode string */
353354
return j;
354355
}
355356

fs/cifs/cifsfs.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,19 @@ cifs_do_mount(struct file_system_type *fs_type,
725725
goto out;
726726
}
727727

728+
static ssize_t
729+
cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter)
730+
{
731+
ssize_t rc;
732+
struct inode *inode = file_inode(iocb->ki_filp);
733+
734+
rc = cifs_revalidate_mapping(inode);
735+
if (rc)
736+
return rc;
737+
738+
return generic_file_read_iter(iocb, iter);
739+
}
740+
728741
static ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
729742
{
730743
struct inode *inode = file_inode(iocb->ki_filp);
@@ -881,7 +894,7 @@ const struct inode_operations cifs_symlink_inode_ops = {
881894
const struct file_operations cifs_file_ops = {
882895
.read = new_sync_read,
883896
.write = new_sync_write,
884-
.read_iter = generic_file_read_iter,
897+
.read_iter = cifs_loose_read_iter,
885898
.write_iter = cifs_file_write_iter,
886899
.open = cifs_open,
887900
.release = cifs_close,
@@ -939,7 +952,7 @@ const struct file_operations cifs_file_direct_ops = {
939952
const struct file_operations cifs_file_nobrl_ops = {
940953
.read = new_sync_read,
941954
.write = new_sync_write,
942-
.read_iter = generic_file_read_iter,
955+
.read_iter = cifs_loose_read_iter,
943956
.write_iter = cifs_file_write_iter,
944957
.open = cifs_open,
945958
.release = cifs_close,

fs/cifs/link.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ cifs_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
374374
oparms.cifs_sb = cifs_sb;
375375
oparms.desired_access = GENERIC_WRITE;
376376
oparms.create_options = create_options;
377-
oparms.disposition = FILE_OPEN;
377+
oparms.disposition = FILE_CREATE;
378378
oparms.path = path;
379379
oparms.fid = &fid;
380380
oparms.reconnect = false;

0 commit comments

Comments
 (0)