src: use g_lstat() instead of lstat()

The GLib g_lstat() function provides a portable impl for
Win32.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2019-12-24 15:19:17 +00:00
parent ea7b20a263
commit d0312c584f
5 changed files with 14 additions and 14 deletions

View File

@ -14232,7 +14232,7 @@ qemuDomainCreateDeviceRecursive(const char *device,
{
char *devicePath = NULL;
char *target = NULL;
struct stat sb;
GStatBuf sb;
int ret = -1;
bool isLink = false;
bool isDev = false;
@ -14250,7 +14250,7 @@ qemuDomainCreateDeviceRecursive(const char *device,
return ret;
}
if (lstat(device, &sb) < 0) {
if (g_lstat(device, &sb) < 0) {
if (errno == ENOENT && allow_noent) {
/* Ignore non-existent device. */
return 0;
@ -15106,7 +15106,7 @@ struct qemuDomainAttachDeviceMknodData {
virDomainObjPtr vm;
const char *file;
const char *target;
struct stat sb;
GStatBuf sb;
void *acl;
#ifdef WITH_SELINUX
char *tcon;
@ -15284,7 +15284,7 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
data.vm = vm;
data.file = file;
if (lstat(file, &data.sb) < 0) {
if (g_lstat(file, &data.sb) < 0) {
virReportSystemError(errno,
_("Unable to access %s"), file);
return ret;

View File

@ -2365,7 +2365,7 @@ virSecurityDACGetProcessLabelInternal(pid_t pid,
path = g_strdup_printf("/proc/%d", (int)pid);
if (lstat(path, &sb) < 0) {
if (g_lstat(path, &sb) < 0) {
virReportSystemError(errno,
_("unable to get uid and gid for PID %d via procfs"),
pid);

View File

@ -1522,7 +1522,7 @@ virStorageBackendVolOpen(const char *path, struct stat *sb,
char *base = last_component(path);
bool noerror = (flags & VIR_STORAGE_VOL_OPEN_NOERROR);
if (lstat(path, sb) < 0) {
if (g_lstat(path, sb) < 0) {
if (errno == ENOENT) {
if (noerror) {
VIR_WARN("ignoring missing file '%s'", path);

View File

@ -223,7 +223,7 @@ virCgroupV1ResolveMountLink(const char *mntDir,
g_autofree char *linkSrc = NULL;
g_autofree char *tmp = NULL;
char *dirName;
struct stat sb;
GStatBuf sb;
tmp = g_strdup(mntDir);
@ -241,7 +241,7 @@ virCgroupV1ResolveMountLink(const char *mntDir,
linkSrc = g_strdup_printf("%s/%s", tmp, typeStr);
*dirName = '/';
if (lstat(linkSrc, &sb) < 0) {
if (g_lstat(linkSrc, &sb) < 0) {
if (errno == ENOENT) {
VIR_WARN("Controller %s co-mounted at %s is missing symlink at %s",
typeStr, tmp, linkSrc);

View File

@ -1002,11 +1002,11 @@ int virFileDeleteTree(const char *dir)
while ((direrr = virDirRead(dh, &de, dir)) > 0) {
g_autofree char *filepath = NULL;
struct stat sb;
GStatBuf sb;
filepath = g_strdup_printf("%s/%s", dir, de->d_name);
if (lstat(filepath, &sb) < 0) {
if (g_lstat(filepath, &sb) < 0) {
virReportSystemError(errno, _("Cannot access '%s'"),
filepath);
goto cleanup;
@ -1555,7 +1555,7 @@ virFileResolveLinkHelper(const char *linkpath,
bool intermediatePaths,
char **resultpath)
{
struct stat st;
GStatBuf st;
*resultpath = NULL;
@ -1563,7 +1563,7 @@ virFileResolveLinkHelper(const char *linkpath,
* directories, if linkpath is absolute and the basename is
* already a non-symlink. */
if (IS_ABSOLUTE_FILE_NAME(linkpath) && !intermediatePaths) {
if (lstat(linkpath, &st) < 0)
if (g_lstat(linkpath, &st) < 0)
return -1;
if (!S_ISLNK(st.st_mode)) {
@ -1613,9 +1613,9 @@ virFileResolveAllLinks(const char *linkpath, char **resultpath)
int
virFileIsLink(const char *linkpath)
{
struct stat st;
GStatBuf st;
if (lstat(linkpath, &st) < 0)
if (g_lstat(linkpath, &st) < 0)
return -errno;
return S_ISLNK(st.st_mode) != 0;