| // SPDX-License-Identifier: GPL-2.0-or-later |
| * Copyright (C) 2020, Microsoft Corporation. |
| * Author(s): Steve French <stfrench@microsoft.com> |
| * Suresh Jayaraman <sjayaraman@suse.de> |
| * Jeff Layton <jlayton@kernel.org> |
| /* extract the host portion of the UNC string */ |
| char *extract_hostname(const char *unc) |
| /* skip double chars at beginning of string */ |
| /* BB: check validity of these bytes? */ |
| for (src = unc; *src && *src == '\\'; src++) |
| /* delimiter between hostname and sharename is always '\\' now */ |
| delim = strchr(src, '\\'); |
| dst = kmalloc((len + 1), GFP_KERNEL); |
| char *extract_sharename(const char *unc) |
| /* skip double chars at the beginning */ |
| /* share name is always preceded by '\\' now */ |
| delim = strchr(src, '\\'); |
| /* caller has to free the memory */ |
| dst = kstrndup(delim, len, GFP_KERNEL); |