aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-11-05 23:14:42 -0400
committerMike Frysinger <vapier@gentoo.org>2021-11-05 23:14:42 -0400
commit632cc66ba52eb6aa7fd3e457c64d9186389a20b4 (patch)
treef8ce207063dd445841183f1d0d832c92f41b3c6d /libsbutil
parentbuild: require at least a C99 compiler (diff)
downloadsandbox-632cc66ba52eb6aa7fd3e457c64d9186389a20b4.tar.gz
sandbox-632cc66ba52eb6aa7fd3e457c64d9186389a20b4.tar.bz2
sandbox-632cc66ba52eb6aa7fd3e457c64d9186389a20b4.zip
change FS calls to use 64-bit interfaces explicitly
Make sure we use 64-bit FS interfaces when accessing the FS. This is needed not only to stat or open large files, but even files with 64-bit inodes. Bug: https://bugs.gentoo.org/583282 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsbutil')
-rw-r--r--libsbutil/include/rcscripts/util/file.h2
-rw-r--r--libsbutil/sb_close.c4
-rw-r--r--libsbutil/src/file.c24
3 files changed, 15 insertions, 15 deletions
diff --git a/libsbutil/include/rcscripts/util/file.h b/libsbutil/include/rcscripts/util/file.h
index 197f211..8bbde00 100644
--- a/libsbutil/include/rcscripts/util/file.h
+++ b/libsbutil/include/rcscripts/util/file.h
@@ -23,7 +23,7 @@ bool rc_is_dir (const char *pathname, bool follow_link);
/* The following functions do not care about errors - it only returns
* the size/mtime of 'pathname' if it exists, and is the type requested,
* or else 0. */
-off_t rc_get_size (const char *pathname, bool follow_link);
+off64_t rc_get_size (const char *pathname, bool follow_link);
/* The following return a pointer on success, or NULL with errno set on error.
* If it returned NULL, but errno is not set, then there was no error, but
diff --git a/libsbutil/sb_close.c b/libsbutil/sb_close.c
index 5379197..113deab 100644
--- a/libsbutil/sb_close.c
+++ b/libsbutil/sb_close.c
@@ -34,7 +34,7 @@ int sb_close(int fd)
void sb_close_all_fds(void)
{
DIR *dirp;
- struct dirent *de;
+ struct dirent64 *de;
int dfd, fd;
const char *fd_dir = sb_get_fd_dir();
@@ -43,7 +43,7 @@ void sb_close_all_fds(void)
sb_ebort("could not process %s\n", fd_dir);
dfd = dirfd(dirp);
- while ((de = readdir(dirp)) != NULL) {
+ while ((de = readdir64(dirp)) != NULL) {
if (de->d_name[0] == '.')
continue;
fd = atoi(de->d_name);
diff --git a/libsbutil/src/file.c b/libsbutil/src/file.c
index a1a4a0e..5a361f4 100644
--- a/libsbutil/src/file.c
+++ b/libsbutil/src/file.c
@@ -21,13 +21,13 @@ rc_file_exists (const char *pathname)
bool
rc_is_file (const char *pathname, bool follow_link)
{
- struct stat buf;
+ struct stat64 buf;
int retval;
if (!check_str (pathname))
return false;
- retval = follow_link ? stat (pathname, &buf) : lstat (pathname, &buf);
+ retval = follow_link ? stat64 (pathname, &buf) : lstat64 (pathname, &buf);
if ((-1 != retval) && (S_ISREG (buf.st_mode)))
retval = true;
else
@@ -39,13 +39,13 @@ rc_is_file (const char *pathname, bool follow_link)
bool
rc_is_dir (const char *pathname, bool follow_link)
{
- struct stat buf;
+ struct stat64 buf;
int retval;
if (!check_str (pathname))
return false;
- retval = follow_link ? stat (pathname, &buf) : lstat (pathname, &buf);
+ retval = follow_link ? stat64 (pathname, &buf) : lstat64 (pathname, &buf);
if ((-1 != retval) && (S_ISDIR (buf.st_mode)))
retval = true;
else
@@ -54,16 +54,16 @@ rc_is_dir (const char *pathname, bool follow_link)
return retval;
}
-off_t
+off64_t
rc_get_size (const char *pathname, bool follow_link)
{
- struct stat buf;
+ struct stat64 buf;
int retval;
if (!check_str (pathname))
return 0;
- retval = follow_link ? stat (pathname, &buf) : lstat (pathname, &buf);
+ retval = follow_link ? stat64 (pathname, &buf) : lstat64 (pathname, &buf);
if (-1 != retval)
retval = buf.st_size;
else
@@ -76,7 +76,7 @@ char **
rc_ls_dir (const char *pathname, bool hidden, bool sort)
{
DIR *dp;
- struct dirent *dir_entry;
+ struct dirent64 *dir_entry;
char **dirlist = NULL;
if (!check_arg_str (pathname))
@@ -102,7 +102,7 @@ rc_ls_dir (const char *pathname, bool hidden, bool sort)
{
/* Clear errno to distinguish between EOF and error */
errno = 0;
- dir_entry = readdir (dp);
+ dir_entry = readdir64 (dp);
/* Only an error if 'errno' != 0, else EOF */
if ((NULL == dir_entry) && (0 != errno))
{
@@ -184,10 +184,10 @@ error:
int
rc_file_map (const char *filename, char **buf, size_t * bufsize)
{
- struct stat stats;
+ struct stat64 stats;
int fd;
- fd = open (filename, O_RDONLY);
+ fd = open64 (filename, O_RDONLY);
if (fd < 0)
{
rc_errno_set (errno);
@@ -195,7 +195,7 @@ rc_file_map (const char *filename, char **buf, size_t * bufsize)
return -1;
}
- if (fstat (fd, &stats) < 0)
+ if (fstat64 (fd, &stats) < 0)
{
rc_errno_set (errno);
DBG_MSG ("Failed to stat file!\n");