halt='use getaddrinfo, not gethostby*' \
$(_sc_search_regexp)
+# dirname and basename from <libgen.h> are not required to be thread-safe
+sc_prohibit_libgen:
+ @prohibit='( (base|dir)name *\(|include .libgen\.h)' \
+ halt='use functions from gnulib "dirname.h", not <libgen.h>' \
+ $(_sc_search_regexp)
+
# raw xmlGetProp requires some nasty casts
sc_prohibit_xmlGetProp:
@prohibit='\<xmlGetProp *\(' \
/*
* node_device_udev.c: node device enumeration - libudev implementation
*
- * Copyright (C) 2009-2012 Red Hat, Inc.
+ * Copyright (C) 2009-2013 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include <scsi/scsi.h>
#include <c-ctype.h>
+#include "dirname.h"
#include "node_device_udev.h"
#include "virerror.h"
#include "node_device_conf.h"
union _virNodeDevCapData *data = &def->caps->data;
char *filename = NULL;
- filename = basename(def->sysfs_path);
+ filename = last_component(def->sysfs_path);
if (!STRPREFIX(filename, "host")) {
VIR_ERROR(_("SCSI host found, but its udev name '%s' does "
union _virNodeDevCapData *data = &def->caps->data;
char *filename = NULL, *p = NULL;
- filename = basename(def->sysfs_path);
+ filename = last_component(def->sysfs_path);
if (udevStrToLong_ui(filename, &p, 10, &data->scsi.host) == -1) {
goto out;
* parallels_storage.c: core privconn functions for managing
* Parallels Cloud Server hosts
*
+ * Copyright (C) 2013 Red Hat, Inc.
* Copyright (C) 2012 Parallels, Inc.
*
* This library is free software; you can redistribute it and/or
#include <config.h>
#include "datatypes.h"
+#include "dirname.h"
#include "viralloc.h"
#include "virerror.h"
#include "md5.h"
goto cleanup;
}
- if (!(def->bridge = strdup(basename(bridgePath)))) {
+ if (!(def->bridge = strdup(last_component(bridgePath)))) {
virReportOOMError();
goto cleanup;
}
* parallels_storage.c: core driver functions for managing
* Parallels Cloud Server hosts
*
+ * Copyright (C) 2013 Red Hat, Inc.
* Copyright (C) 2012 Parallels, Inc.
*
* This library is free software; you can redistribute it and/or
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-#include <libgen.h>
#include "datatypes.h"
+#include "dirname.h"
#include "viralloc.h"
#include "configmake.h"
#include "virstoragefile.h"
virStoragePoolObjPtr pool = NULL;
int j;
- if (!(poolPath = strdup(pdom->home))) {
+ poolPath = mdir_name(pdom->home);
+ if (!poolPath) {
virReportOOMError();
return NULL;
}
- poolPath = dirname(poolPath);
-
for (j = 0; j < pools->count; j++) {
if (STREQ(poolPath, pools->objs[j]->def->target.path)) {
pool = pools->objs[j];
#include <unistd.h>
#include <stdio.h>
+#include "dirname.h"
#include "virerror.h"
#include "virlog.h"
#include "storage_backend_disk.h"
goto cleanup;
}
- dev_name = basename(devpath);
- srcname = basename(pool->def->source.devices[0].path);
+ dev_name = last_component(devpath);
+ srcname = last_component(pool->def->source.devices[0].path);
VIR_DEBUG("dev_name=%s, srcname=%s", dev_name, srcname);
isDevMapperDevice = virIsDevMapperDevice(devpath);
/*
* vircgroup.c: methods for managing control cgroups
*
- * Copyright (C) 2010-2012 Red Hat, Inc.
+ * Copyright (C) 2010-2013 Red Hat, Inc.
* Copyright IBM Corp. 2008
*
* This library is free software; you can redistribute it and/or
#include <sys/stat.h>
#include <sys/types.h>
#include <signal.h>
-#include <libgen.h>
#include <dirent.h>
#define __VIR_CGROUP_ALLOW_INCLUDE_PRIV_H__
#include <unistd.h>
#include <stdlib.h>
+#include "dirname.h"
#include "virlog.h"
#include "viralloc.h"
#include "vircommand.h"
return ret;
}
- config_address = basename(device_path);
+ config_address = last_component(device_path);
if (VIR_ALLOC(*bdf) != 0) {
virReportOOMError();
goto out;
struct _virStorageFileMetadata {
char *backingStore; /* Canonical name (absolute file, or protocol) */
char *backingStoreRaw; /* If file, original name, possibly relative */
- char *directory; /* The directory containing basename(backingStoreRaw) */
+ char *directory; /* The directory containing basename of backingStoreRaw */
int backingStoreFormat; /* enum virStorageFileFormat */
bool backingStoreIsFile;
virStorageFileMetadataPtr backingMeta;