mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-13 04:34:35 +03:00
Add compat wrapper for fstatat
This commit is contained in:

committed by
cgzones

parent
049046c700
commit
bbf01054bf
46
Compat.c
Normal file
46
Compat.c
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
htop - Compat.c
|
||||
(C) 2020 Christian Göttsche
|
||||
Released under the GNU GPLv2, see the COPYING file
|
||||
in the source distribution for its full text.
|
||||
*/
|
||||
|
||||
#include "config.h" // IWYU pragma: keep
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "Compat.h"
|
||||
#ifndef HAVE_FSTATAT
|
||||
#include "XUtils.h"
|
||||
#endif
|
||||
|
||||
|
||||
int Compat_fstatat(int dirfd,
|
||||
const char* dirpath,
|
||||
const char* pathname,
|
||||
struct stat* statbuf,
|
||||
int flags) {
|
||||
|
||||
#ifdef HAVE_FSTATAT
|
||||
|
||||
(void)dirpath;
|
||||
|
||||
return fstatat(dirfd, pathname, statbuf, flags);
|
||||
|
||||
#else
|
||||
|
||||
(void)dirfd;
|
||||
|
||||
char path[4096];
|
||||
xSnprintf(path, sizeof(path), "%s/%s", dirpath, pathname);
|
||||
|
||||
if (flags & AT_SYMLINK_NOFOLLOW)
|
||||
return lstat(path, statbuf);
|
||||
|
||||
return stat(path, statbuf);
|
||||
|
||||
#endif
|
||||
}
|
Reference in New Issue
Block a user