Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cifs: cleanup misc.c

misc.c was getting a little large, move two of the UNC parsing relating
functions to a new C file unc.c which makes the coding of the
upcoming witness protocol patch series a little cleaner as well.

Suggested-by: Rafal Szczesniak <rafal@elbingbrewery.org>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>

+68 -57
+1 -1
fs/cifs/Makefile
··· 8 8 cifs-y := trace.o cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o \ 9 9 inode.o link.o misc.o netmisc.o smbencrypt.o transport.o asn1.o \ 10 10 cifs_unicode.o nterr.o cifsencrypt.o \ 11 - readdir.o ioctl.o sess.o export.o smb1ops.o winucase.o \ 11 + readdir.o ioctl.o sess.o export.o smb1ops.o unc.o winucase.o \ 12 12 smb2ops.o smb2maperror.o smb2transport.o \ 13 13 smb2misc.o smb2pdu.o smb2inode.o smb2file.o cifsacl.o fs_context.o 14 14
-56
fs/cifs/misc.c
··· 1195 1195 cifs_put_tcon_super(sb); 1196 1196 return rc; 1197 1197 } 1198 - 1199 - /* extract the host portion of the UNC string */ 1200 - char *extract_hostname(const char *unc) 1201 - { 1202 - const char *src; 1203 - char *dst, *delim; 1204 - unsigned int len; 1205 - 1206 - /* skip double chars at beginning of string */ 1207 - /* BB: check validity of these bytes? */ 1208 - if (strlen(unc) < 3) 1209 - return ERR_PTR(-EINVAL); 1210 - for (src = unc; *src && *src == '\\'; src++) 1211 - ; 1212 - if (!*src) 1213 - return ERR_PTR(-EINVAL); 1214 - 1215 - /* delimiter between hostname and sharename is always '\\' now */ 1216 - delim = strchr(src, '\\'); 1217 - if (!delim) 1218 - return ERR_PTR(-EINVAL); 1219 - 1220 - len = delim - src; 1221 - dst = kmalloc((len + 1), GFP_KERNEL); 1222 - if (dst == NULL) 1223 - return ERR_PTR(-ENOMEM); 1224 - 1225 - memcpy(dst, src, len); 1226 - dst[len] = '\0'; 1227 - 1228 - return dst; 1229 - } 1230 - 1231 - char *extract_sharename(const char *unc) 1232 - { 1233 - const char *src; 1234 - char *delim, *dst; 1235 - int len; 1236 - 1237 - /* skip double chars at the beginning */ 1238 - src = unc + 2; 1239 - 1240 - /* share name is always preceded by '\\' now */ 1241 - delim = strchr(src, '\\'); 1242 - if (!delim) 1243 - return ERR_PTR(-EINVAL); 1244 - delim++; 1245 - len = strlen(delim); 1246 - 1247 - /* caller has to free the memory */ 1248 - dst = kstrndup(delim, len, GFP_KERNEL); 1249 - if (!dst) 1250 - return ERR_PTR(-ENOMEM); 1251 - 1252 - return dst; 1253 - }
+67
fs/cifs/unc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * Copyright (C) 2020, Microsoft Corporation. 4 + * 5 + * Author(s): Steve French <stfrench@microsoft.com> 6 + * Suresh Jayaraman <sjayaraman@suse.de> 7 + * Jeff Layton <jlayton@kernel.org> 8 + */ 9 + 10 + #include <linux/slab.h> 11 + #include "cifsproto.h" 12 + 13 + /* extract the host portion of the UNC string */ 14 + char *extract_hostname(const char *unc) 15 + { 16 + const char *src; 17 + char *dst, *delim; 18 + unsigned int len; 19 + 20 + /* skip double chars at beginning of string */ 21 + /* BB: check validity of these bytes? */ 22 + if (strlen(unc) < 3) 23 + return ERR_PTR(-EINVAL); 24 + for (src = unc; *src && *src == '\\'; src++) 25 + ; 26 + if (!*src) 27 + return ERR_PTR(-EINVAL); 28 + 29 + /* delimiter between hostname and sharename is always '\\' now */ 30 + delim = strchr(src, '\\'); 31 + if (!delim) 32 + return ERR_PTR(-EINVAL); 33 + 34 + len = delim - src; 35 + dst = kmalloc((len + 1), GFP_KERNEL); 36 + if (dst == NULL) 37 + return ERR_PTR(-ENOMEM); 38 + 39 + memcpy(dst, src, len); 40 + dst[len] = '\0'; 41 + 42 + return dst; 43 + } 44 + 45 + char *extract_sharename(const char *unc) 46 + { 47 + const char *src; 48 + char *delim, *dst; 49 + int len; 50 + 51 + /* skip double chars at the beginning */ 52 + src = unc + 2; 53 + 54 + /* share name is always preceded by '\\' now */ 55 + delim = strchr(src, '\\'); 56 + if (!delim) 57 + return ERR_PTR(-EINVAL); 58 + delim++; 59 + len = strlen(delim); 60 + 61 + /* caller has to free the memory */ 62 + dst = kstrndup(delim, len, GFP_KERNEL); 63 + if (!dst) 64 + return ERR_PTR(-ENOMEM); 65 + 66 + return dst; 67 + }