mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +00:00
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:
parent
ea7b20a263
commit
d0312c584f
@ -14232,7 +14232,7 @@ qemuDomainCreateDeviceRecursive(const char *device,
|
|||||||
{
|
{
|
||||||
char *devicePath = NULL;
|
char *devicePath = NULL;
|
||||||
char *target = NULL;
|
char *target = NULL;
|
||||||
struct stat sb;
|
GStatBuf sb;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
bool isLink = false;
|
bool isLink = false;
|
||||||
bool isDev = false;
|
bool isDev = false;
|
||||||
@ -14250,7 +14250,7 @@ qemuDomainCreateDeviceRecursive(const char *device,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lstat(device, &sb) < 0) {
|
if (g_lstat(device, &sb) < 0) {
|
||||||
if (errno == ENOENT && allow_noent) {
|
if (errno == ENOENT && allow_noent) {
|
||||||
/* Ignore non-existent device. */
|
/* Ignore non-existent device. */
|
||||||
return 0;
|
return 0;
|
||||||
@ -15106,7 +15106,7 @@ struct qemuDomainAttachDeviceMknodData {
|
|||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
const char *file;
|
const char *file;
|
||||||
const char *target;
|
const char *target;
|
||||||
struct stat sb;
|
GStatBuf sb;
|
||||||
void *acl;
|
void *acl;
|
||||||
#ifdef WITH_SELINUX
|
#ifdef WITH_SELINUX
|
||||||
char *tcon;
|
char *tcon;
|
||||||
@ -15284,7 +15284,7 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
|
|||||||
data.vm = vm;
|
data.vm = vm;
|
||||||
data.file = file;
|
data.file = file;
|
||||||
|
|
||||||
if (lstat(file, &data.sb) < 0) {
|
if (g_lstat(file, &data.sb) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Unable to access %s"), file);
|
_("Unable to access %s"), file);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -2365,7 +2365,7 @@ virSecurityDACGetProcessLabelInternal(pid_t pid,
|
|||||||
|
|
||||||
path = g_strdup_printf("/proc/%d", (int)pid);
|
path = g_strdup_printf("/proc/%d", (int)pid);
|
||||||
|
|
||||||
if (lstat(path, &sb) < 0) {
|
if (g_lstat(path, &sb) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("unable to get uid and gid for PID %d via procfs"),
|
_("unable to get uid and gid for PID %d via procfs"),
|
||||||
pid);
|
pid);
|
||||||
|
@ -1522,7 +1522,7 @@ virStorageBackendVolOpen(const char *path, struct stat *sb,
|
|||||||
char *base = last_component(path);
|
char *base = last_component(path);
|
||||||
bool noerror = (flags & VIR_STORAGE_VOL_OPEN_NOERROR);
|
bool noerror = (flags & VIR_STORAGE_VOL_OPEN_NOERROR);
|
||||||
|
|
||||||
if (lstat(path, sb) < 0) {
|
if (g_lstat(path, sb) < 0) {
|
||||||
if (errno == ENOENT) {
|
if (errno == ENOENT) {
|
||||||
if (noerror) {
|
if (noerror) {
|
||||||
VIR_WARN("ignoring missing file '%s'", path);
|
VIR_WARN("ignoring missing file '%s'", path);
|
||||||
|
@ -223,7 +223,7 @@ virCgroupV1ResolveMountLink(const char *mntDir,
|
|||||||
g_autofree char *linkSrc = NULL;
|
g_autofree char *linkSrc = NULL;
|
||||||
g_autofree char *tmp = NULL;
|
g_autofree char *tmp = NULL;
|
||||||
char *dirName;
|
char *dirName;
|
||||||
struct stat sb;
|
GStatBuf sb;
|
||||||
|
|
||||||
tmp = g_strdup(mntDir);
|
tmp = g_strdup(mntDir);
|
||||||
|
|
||||||
@ -241,7 +241,7 @@ virCgroupV1ResolveMountLink(const char *mntDir,
|
|||||||
linkSrc = g_strdup_printf("%s/%s", tmp, typeStr);
|
linkSrc = g_strdup_printf("%s/%s", tmp, typeStr);
|
||||||
*dirName = '/';
|
*dirName = '/';
|
||||||
|
|
||||||
if (lstat(linkSrc, &sb) < 0) {
|
if (g_lstat(linkSrc, &sb) < 0) {
|
||||||
if (errno == ENOENT) {
|
if (errno == ENOENT) {
|
||||||
VIR_WARN("Controller %s co-mounted at %s is missing symlink at %s",
|
VIR_WARN("Controller %s co-mounted at %s is missing symlink at %s",
|
||||||
typeStr, tmp, linkSrc);
|
typeStr, tmp, linkSrc);
|
||||||
|
@ -1002,11 +1002,11 @@ int virFileDeleteTree(const char *dir)
|
|||||||
|
|
||||||
while ((direrr = virDirRead(dh, &de, dir)) > 0) {
|
while ((direrr = virDirRead(dh, &de, dir)) > 0) {
|
||||||
g_autofree char *filepath = NULL;
|
g_autofree char *filepath = NULL;
|
||||||
struct stat sb;
|
GStatBuf sb;
|
||||||
|
|
||||||
filepath = g_strdup_printf("%s/%s", dir, de->d_name);
|
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'"),
|
virReportSystemError(errno, _("Cannot access '%s'"),
|
||||||
filepath);
|
filepath);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1555,7 +1555,7 @@ virFileResolveLinkHelper(const char *linkpath,
|
|||||||
bool intermediatePaths,
|
bool intermediatePaths,
|
||||||
char **resultpath)
|
char **resultpath)
|
||||||
{
|
{
|
||||||
struct stat st;
|
GStatBuf st;
|
||||||
|
|
||||||
*resultpath = NULL;
|
*resultpath = NULL;
|
||||||
|
|
||||||
@ -1563,7 +1563,7 @@ virFileResolveLinkHelper(const char *linkpath,
|
|||||||
* directories, if linkpath is absolute and the basename is
|
* directories, if linkpath is absolute and the basename is
|
||||||
* already a non-symlink. */
|
* already a non-symlink. */
|
||||||
if (IS_ABSOLUTE_FILE_NAME(linkpath) && !intermediatePaths) {
|
if (IS_ABSOLUTE_FILE_NAME(linkpath) && !intermediatePaths) {
|
||||||
if (lstat(linkpath, &st) < 0)
|
if (g_lstat(linkpath, &st) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!S_ISLNK(st.st_mode)) {
|
if (!S_ISLNK(st.st_mode)) {
|
||||||
@ -1613,9 +1613,9 @@ virFileResolveAllLinks(const char *linkpath, char **resultpath)
|
|||||||
int
|
int
|
||||||
virFileIsLink(const char *linkpath)
|
virFileIsLink(const char *linkpath)
|
||||||
{
|
{
|
||||||
struct stat st;
|
GStatBuf st;
|
||||||
|
|
||||||
if (lstat(linkpath, &st) < 0)
|
if (g_lstat(linkpath, &st) < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
return S_ISLNK(st.st_mode) != 0;
|
return S_ISLNK(st.st_mode) != 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user