include: add libgen.h to stdinc.h
A subsequent patch will need to use dirname(3), declared in libgen.h. Because libgen.h is a POSIX header, the SPDK build requires that it is defined in spdk/stdinc.h, not in the file that needs it. libgen.h also declares basename() which has a conflicting declaration in string.h. A small change is required in bdev_uring_read_sysfs_attr() to accommodate this. Signed-off-by: Mike Gerdts <mgerdts@nvidia.com> Change-Id: Ib4ded2097881668aabdfd9f1683f933ce418db2e Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17557 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
d453aaa360
commit
5e79e84e78
@ -1,6 +1,7 @@
|
|||||||
/* SPDX-License-Identifier: BSD-3-Clause
|
/* SPDX-License-Identifier: BSD-3-Clause
|
||||||
* Copyright (C) 2017 Intel Corporation.
|
* Copyright (C) 2017 Intel Corporation.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
* Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
@ -39,6 +40,7 @@ extern "C" {
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
#include <ifaddrs.h>
|
#include <ifaddrs.h>
|
||||||
|
#include <libgen.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
@ -307,11 +307,17 @@ bdev_uring_read_sysfs_attr(const char *devname, const char *attr, char *str, int
|
|||||||
{
|
{
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
char *device = NULL;
|
char *device = NULL;
|
||||||
|
char *name;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
device = basename(devname);
|
name = strdup(devname);
|
||||||
|
if (name == NULL) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
device = basename(name);
|
||||||
path = spdk_sprintf_alloc("/sys/block/%s/%s", device, attr);
|
path = spdk_sprintf_alloc("/sys/block/%s/%s", device, attr);
|
||||||
|
free(name);
|
||||||
if (!path) {
|
if (!path) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user