提交 d0312c58 编写于 作者: D Daniel P. Berrangé

src: use g_lstat() instead of lstat()

The GLib g_lstat() function provides a portable impl for
Win32.
Reviewed-by: NFabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 ea7b20a2
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册