Commit 5e79e84e authored by Mike Gerdts's avatar Mike Gerdts Committed by Jim Harris
Browse files

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: default avatarMike Gerdts <mgerdts@nvidia.com>
Change-Id: Ib4ded2097881668aabdfd9f1683f933ce418db2e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17557


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent d453aaa3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
/*   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>
+7 −1
Original line number Diff line number Diff line
@@ -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;
	}