Skip to content

Commit fc81c03

Browse files
committed
Merge branch 'for-linus' of git://git.samba.org/sfrench/cifs-2.6
Pull CIFS fixes from Steve French. * 'for-linus' of git://git.samba.org/sfrench/cifs-2.6: cifs: reinstate the forcegid option Convert properly UTF-8 to UTF-16 [CIFS] WARN_ON_ONCE if kernel_sendmsg() returns -ENOSPC
2 parents 547b1e8 + 72bd481 commit fc81c03

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

fs/cifs/cifs_unicode.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,27 @@ cifs_strtoUTF16(__le16 *to, const char *from, int len,
203203
int i;
204204
wchar_t wchar_to; /* needed to quiet sparse */
205205

206+
/* special case for utf8 to handle no plane0 chars */
207+
if (!strcmp(codepage->charset, "utf8")) {
208+
/*
209+
* convert utf8 -> utf16, we assume we have enough space
210+
* as caller should have assumed conversion does not overflow
211+
* in destination len is length in wchar_t units (16bits)
212+
*/
213+
i = utf8s_to_utf16s(from, len, UTF16_LITTLE_ENDIAN,
214+
(wchar_t *) to, len);
215+
216+
/* if success terminate and exit */
217+
if (i >= 0)
218+
goto success;
219+
/*
220+
* if fails fall back to UCS encoding as this
221+
* function should not return negative values
222+
* currently can fail only if source contains
223+
* invalid encoded characters
224+
*/
225+
}
226+
206227
for (i = 0; len && *from; i++, from += charlen, len -= charlen) {
207228
charlen = codepage->char2uni(from, len, &wchar_to);
208229
if (charlen < 1) {
@@ -215,6 +236,7 @@ cifs_strtoUTF16(__le16 *to, const char *from, int len,
215236
put_unaligned_le16(wchar_to, &to[i]);
216237
}
217238

239+
success:
218240
put_unaligned_le16(0, &to[i]);
219241
return i;
220242
}

fs/cifs/connect.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ enum {
6767
/* Mount options that take no arguments */
6868
Opt_user_xattr, Opt_nouser_xattr,
6969
Opt_forceuid, Opt_noforceuid,
70+
Opt_forcegid, Opt_noforcegid,
7071
Opt_noblocksend, Opt_noautotune,
7172
Opt_hard, Opt_soft, Opt_perm, Opt_noperm,
7273
Opt_mapchars, Opt_nomapchars, Opt_sfu,
@@ -117,6 +118,8 @@ static const match_table_t cifs_mount_option_tokens = {
117118
{ Opt_nouser_xattr, "nouser_xattr" },
118119
{ Opt_forceuid, "forceuid" },
119120
{ Opt_noforceuid, "noforceuid" },
121+
{ Opt_forcegid, "forcegid" },
122+
{ Opt_noforcegid, "noforcegid" },
120123
{ Opt_noblocksend, "noblocksend" },
121124
{ Opt_noautotune, "noautotune" },
122125
{ Opt_hard, "hard" },
@@ -1195,6 +1198,12 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
11951198
case Opt_noforceuid:
11961199
override_uid = 0;
11971200
break;
1201+
case Opt_forcegid:
1202+
override_gid = 1;
1203+
break;
1204+
case Opt_noforcegid:
1205+
override_gid = 0;
1206+
break;
11981207
case Opt_noblocksend:
11991208
vol->noblocksnd = 1;
12001209
break;

fs/cifs/transport.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ smb_send_kvec(struct TCP_Server_Info *server, struct kvec *iov, size_t n_vec,
183183
rc = kernel_sendmsg(ssocket, &smb_msg, &iov[first_vec],
184184
n_vec - first_vec, remaining);
185185
if (rc == -ENOSPC || rc == -EAGAIN) {
186+
/*
187+
* Catch if a low level driver returns -ENOSPC. This
188+
* WARN_ON will be removed by 3.10 if no one reports
189+
* seeing this.
190+
*/
191+
WARN_ON_ONCE(rc == -ENOSPC);
186192
i++;
187193
if (i >= 14 || (!server->noblocksnd && (i > 2))) {
188194
cERROR(1, "sends on sock %p stuck for 15 "

0 commit comments

Comments
 (0)