mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-12 20:24:35 +03:00
Add compat wrapper for readlinkat
This commit is contained in:
26
Compat.c
26
Compat.c
@ -13,9 +13,7 @@ in the source distribution for its full text.
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "Compat.h"
|
||||
#ifndef HAVE_FSTATAT
|
||||
#include "XUtils.h"
|
||||
#endif
|
||||
|
||||
|
||||
int Compat_fstatat(int dirfd,
|
||||
@ -44,3 +42,27 @@ int Compat_fstatat(int dirfd,
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
int Compat_readlinkat(int dirfd,
|
||||
const char* dirpath,
|
||||
const char* pathname,
|
||||
char* buf,
|
||||
size_t bufsize) {
|
||||
|
||||
#ifdef HAVE_READLINKAT
|
||||
|
||||
(void)dirpath;
|
||||
|
||||
return readlinkat(dirfd, pathname, buf, bufsize);
|
||||
|
||||
#else
|
||||
|
||||
(void)dirfd;
|
||||
|
||||
char path[4096];
|
||||
xSnprintf(path, sizeof(path), "%s/%s", dirpath, pathname);
|
||||
|
||||
return readlink(path, buf, bufsize);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user