Skip to content

Commit

Permalink
Adding ATFILE glue functions
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtrujy committed Jan 24, 2024
1 parent 8e23858 commit 09153fc
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/libcglue/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ FDMAN_OBJS = __descriptor_data_pool.o __descriptormap.o __fdman_init.o __fdman_g
GLUE_OBJS = __dummy_passwd.o __psp_heap_blockid.o __psp_free_heap.o _fork.o _wait.o _open.o _close.o _read.o \
_write.o _fstat.o _stat.o lstat.o access.o _fcntl.o _lseek.o chdir.o mkdir.o rmdir.o getdents.o _link.o _unlink.o \
_rename.o _getpid.o _kill.o _sbrk.o _gettimeofday.o _times.o ftime.o clock_getres.o clock_gettime.o clock_settime.o \
_isatty.o symlink.o truncate.o chmod.o fchmod.o fchmodat.o pathconf.o readlink.o utime.o fchown.o _getentropy.o getpwuid.o \
fsync.o getpwnam.o getuid.o geteuid.o basename.o statvfs.o
_isatty.o symlink.o truncate.o chmod.o fchmod.o pathconf.o readlink.o utime.o fchown.o _getentropy.o getpwuid.o \
fsync.o getpwnam.o getuid.o geteuid.o basename.o statvfs.o \
openat.o renameat.o fchmodat.o fstatat.o mkdirat.o faccessat.o fchownat.o linkat.o readlinkat.o unlinkat.o

INIT_OBJS = __libpthreadglue_init.o __libcglue_init.o __libcglue_deinit.o _exit.o abort.o exit.o

Expand Down
103 changes: 96 additions & 7 deletions src/libcglue/glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,13 +886,6 @@ int fchmod(int fd, mode_t mode)
}
#endif

#ifdef F_fchmodat
int fchmodat(int fd, const char *path, mode_t mode, int flag)
{
return chmod(path, mode);
}
#endif

#ifdef F_pathconf
long int pathconf(const char *path, int name) {
errno = ENOSYS;
Expand Down Expand Up @@ -1058,3 +1051,99 @@ int statvfs (const char *__path, struct statvfs *__buf)
__buf->f_namemax = MAXNAMLEN;
}
#endif /* F_statvfs */

/* ATFILE functions */

#ifdef F_openat
int openat(int dirfd, const char *pathname, int flags, mode_t mode)
{
// TODO: Do better implementation following https://linux.die.net/man/2/openat
// for now use the same as open
return _open(pathname, flags, mode);
}
#endif /* F_openat */

#ifdef F_renameat
int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath)
{
// TODO: Do better implementation following https://linux.die.net/man/2/renameat
// for now use the same as rename
return _rename(oldpath, newpath);
}
#endif /* F_renameat */

#ifdef F_fchmodat
int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags)
{
// TODO: Do better implementation following https://linux.die.net/man/2/fchmodat
// for now use the same as chmod
return chmod(pathname, mode);
}
#endif /* F_fchmodat */

#ifdef F_fstatat
int fstatat(int dirfd, const char *pathname, struct stat *buf, int flags)
{
// TODO: Do better implementation following https://linux.die.net/man/2/fstatat
// for now use the same as stat
return _stat(pathname, buf);
}
#endif /* F_fstatat */

#ifdef F_mkdirat
int mkdirat(int dirfd, const char *pathname, mode_t mode)
{
// TODO: Do better implementation following https://linux.die.net/man/2/mkdirat
// for now use the same as mkdir
return mkdir(pathname, mode);
}
#endif /* F_mkdirat */

#ifdef F_faccessat
int faccessat(int dirfd, const char *pathname, int mode, int flags)
{
// TODO: Do better implementation following https://linux.die.net/man/2/faccessat
// for now use the same as access
return access(pathname, mode);
}
#endif /* F_faccessat */

#ifdef F_fchownat
int fchownat(int dirfd, const char *pathname, uid_t owner, gid_t group, int flags)
{
// TODO: Do better implementation following https://linux.die.net/man/2/fchownat
// for now use the same as chown
return chown(pathname, owner, group);
}
#endif /* F_fchownat */

#ifdef F_linkat
int linkat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags) {
// TODO: Do better implementation following https://linux.die.net/man/2/linkat
// for now use the same as link
return link(oldpath, newpath);
}
#endif /* F_linkat */

#ifdef F_readlinkat
int readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz)
{
// TODO: Do better implementation following https://linux.die.net/man/2/linkat
// for now use the same as readlink
return readlink(pathname, buf, bufsiz);
}
#endif /* F_readlinkat */

#ifdef F_unlinkat
int unlinkat(int dirfd, const char *pathname, int flags)
{
// If flags contains AT_REMOVEDIR, then the path refers to a directory.
// Otherwise, the path refers to a file.
if (flags & AT_REMOVEDIR) {
return rmdir(pathname);
}
else {
return unlink(pathname);
}
}
#endif /* F_unlinkat */

0 comments on commit 09153fc

Please sign in to comment.