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:
Mike Gerdts 2023-04-12 12:35:31 -05:00 committed by Jim Harris
parent d453aaa360
commit 5e79e84e78
2 changed files with 9 additions and 1 deletions

View File

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (C) 2017 Intel Corporation.
* All rights reserved.
* Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
/** \file
@ -39,6 +40,7 @@ extern "C" {
#include <fcntl.h>
#include <glob.h>
#include <ifaddrs.h>
#include <libgen.h>
#include <netdb.h>
#include <poll.h>
#include <pthread.h>

View File

@ -307,11 +307,17 @@ bdev_uring_read_sysfs_attr(const char *devname, const char *attr, char *str, int
{
char *path = NULL;
char *device = NULL;
char *name;
FILE *file;
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);
free(name);
if (!path) {
return -EINVAL;
}