Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode
Phoenix-RTOS Documentation
Light Logo Dark Logo
Phoenix-RTOS Documentation

Contents

  • Introduction
  • Architecture
  • Project repository
  • Building
    • Linux (Ubuntu)
    • Windows
  • Running system on targets
    • Running system on aarch64a53-zynqmp-zcu104
    • Running system on armv7m4-stm32l4x6-nucleo
    • Running system on armv7m7-imxrt105x-evk
    • Running system on armv7m7-imxrt106x-evk
    • Running system on armv7m7-imxrt117x-evk
    • Running system on armv8m33-mcxn94x-frdm
    • Running system on armv7a7-imx6ull-evk
    • Running system on armv7a9-zynq7000
      • Running system on armv7a9-zynq7000-zedboard
      • Running system on armv7a9-zynq7000-zturn
      • Running system on armv7a9-zynq7000-qemu
    • Running system on armv8r52-mps3an536-qemu
    • Running system on ia32-generic-qemu
    • Running system on riscv64-generic-qemu
    • Running system on riscv64-generic-spike
    • Running system on riscv64-grfpga-artya7
    • Running system on riscv64-gr765-vcu118
    • Running system on sparcv8leon-gr716-mini
    • Running system on sparcv8leon-gr712rc-board
    • Running system on sparcv8leon-gr716-mimas
    • Running system on sparcv8leon-generic-qemu
    • Running system on sparcv8leon-gr740-mini
  • Loader
    • Functionality
    • Architecture
    • Command-line interface
  • Kernel
    • HAL
      • HAL for ARM 64-bit targets
      • HAL for ARMv7 Cortex-M based targets
      • HAL for ARMv7 Cortex-R based targets
      • HAL for ARMv7 Cortex-A based targets
      • HAL for ARMv8 Cortex-M based targets
      • HAL for ARMv8 Cortex-R based targets
      • HAL for IA32 based targets
      • HAL for RISC-V 64 based targets
      • HAL for SPARCv8 LEON based targets
    • Processes and threads
      • Process and thread overview
      • Scheduler
      • Management
      • Synchronization primitives
      • Message passing
      • Namespace
    • Memory management
      • Paging technique and Memory Management Unit
      • Memory mapper
      • Zone allocator
      • Fine-grained allocator
      • Memory objects
      • Other memory protection mechanisms
      • Memory management subsystem
    • System calls
      • Prototypes and definition
      • Adding syscall
      • Debug
      • Memory management
      • Process management
      • Threads management
      • Threads synchronization
      • Inter-process communication
      • File operations
      • Socket operations
      • Interrupts management
      • Performance monitoring
      • Time management
      • Platform management
      • RISC-V specific
    • Common routines
  • Standard library
    • Functions
      • assert.h
        • assert
      • ctype.h
        • isalnum
        • isalpha
        • isblank
        • iscntrl
        • isdigit
        • isgraph
        • islower
        • isprint
        • ispunct
        • isspace
        • isupper
        • isxdigit
        • tolower
        • toupper
      • dirent.h
        • closedir
        • opendir
        • readdir
        • rewinddir
        • scandir
        • seekdir
        • telldir
      • fcntl.h
        • creat
        • fcntl
        • open
      • fnmatch.h
        • fnmatch
      • grp.h
        • getgrgid
        • getgrnam
      • ioctl.h
        • ioctl
      • libgen.h
        • basename
        • dirname
      • math.h
        • acos
        • atan
        • atan2
        • ceil
        • copysignl
        • cos
        • cosh
        • exp
        • fabs
        • floor
        • fmod
        • frexp
        • ldexp
        • log
        • log10
        • modf
        • pow
        • sin
        • sinh
        • sqrt
        • tanh
      • netdb.h
        • freeaddrinfo
        • gai_strerror
        • getaddrinfo
      • pthread.h
        • pthread_atfork
        • pthread_attr_destroy
        • pthread_attr_getdetachstate
        • pthread_attr_getguardsize
        • pthread_attr_getinheritsched
        • pthread_attr_getschedparam
        • pthread_attr_getscope
        • pthread_attr_getstack
        • pthread_attr_getstacksize
        • pthread_attr_setschedpolicy
        • pthread_cancel
        • pthread_cleanup_pop
        • pthread_cond_broadcast
        • pthread_cond_clockwait
        • pthread_cond_destroy
        • pthread_cond_timedwait
        • pthread_condattr_destroy
        • pthread_condattr_getclock
        • pthread_condattr_getpshared
        • pthread_create
        • pthread_detach
        • pthread_equal
        • pthread_exit
        • pthread_getcpuclockid
        • pthread_getschedparam
        • pthread_getspecific
        • pthread_join
        • pthread_key_create
        • pthread_key_delete
        • pthread_mutex_consistent
        • pthread_mutex_destroy
        • pthread_mutex_getprioceiling
        • pthread_mutex_lock
        • pthread_mutex_timedlock
        • pthread_mutexattr_destroy
        • pthread_mutexattr_getprioceiling
        • pthread_mutexattr_getprotocol
        • pthread_mutexattr_getpshared
        • pthread_mutexattr_getrobust
        • pthread_mutexattr_gettype
        • pthread_once
        • pthread_rwlock_clockrdlock
        • pthread_rwlock_clockwrlock
        • pthread_rwlock_destroy
        • pthread_rwlock_rdlock
        • pthread_rwlock_timedrdlock
        • pthread_rwlock_timedwrlock
        • pthread_rwlock_trywrlock
        • pthread_rwlock_unlock
        • pthread_rwlockattr_destroy
        • pthread_rwlockattr_getpshared
        • pthread_self
        • pthread_setschedprio
        • pthread_spin_destroy
        • pthread_spin_lock
        • pthread_spin_unlock
        • pthread_testcancel
      • pwd.h
        • endpwent
        • getpwnam
        • getpwuid
      • sched.h
        • sched_get_priority_max
        • sched_getparam
        • sched_getscheduler
        • sched_rr_get_interval
        • sched_setparam
        • sched_setscheduler
        • sched_yield
      • semaphore.h
        • sem_clockwait
        • sem_close
        • sem_destroy
        • sem_getvalue
        • sem_init
        • sem_open
        • sem_post
        • sem_timedwait
        • sem_trywait
        • sem_unlink
        • sem_wait
      • setjmp.h
        • longjmp
        • setjmp
        • siglongjmp
        • sigsetjmp
      • signal.h
        • kill
        • killpg
        • pthread_kill
        • raise
        • sigaction
        • sigaddset
        • sigdelset
        • sigemptyset
        • sigfillset
        • sigismember
        • signal
        • sigpending
        • sigprocmask
        • sigsuspend
        • sigtimedwait
        • sigwait
      • stdio.h
        • clearerr
        • fclose
        • fdopen
        • feof
        • ferror
        • fflush
        • fgetc
        • fgetpos
        • fgets
        • fileno
        • fopen
        • fprintf
        • fputc
        • fputs
        • fread
        • freopen
        • fscanf
        • fseek
        • fsetpos
        • ftell
        • fwrite
        • getc
        • getc_unlocked
        • getchar
        • getline
        • gets
        • pclose
        • perror
        • popen
        • printf
        • putc
        • putchar
        • putchar_unlocked
        • puts
        • remove
        • rename
        • rewind
        • scanf
        • setbuf
        • setvbuf
        • sprintf
        • sscanf
        • tempnam
        • tmpfile
        • tmpnam
        • ungetc
        • vprintf
        • vscanf
      • stdlib.h
        • abort
        • at_quick_exit
        • atexit
        • atof
        • atoi
        • atol
        • bsearch
        • calloc
        • clearenv
        • exit
        • free
        • getenv
        • labs
        • ldiv
        • malloc
        • mblen
        • mbtowc
        • mkdtemp
        • putenv
        • qsort
        • quick_exit
        • rand
        • realloc
        • realpath
        • setenv
        • strtod
        • strtol
        • strtoul
        • system
        • unsetenv
      • string.h
        • memchr
        • memcmp
        • memcpy
        • memmove
        • memset
        • strcat
        • strchr
        • strcmp
        • strcoll
        • strcpy
        • strcspn
        • strdup
        • strerror
        • strlen
        • strncat
        • strncmp
        • strncpy
        • strpbrk
        • strrchr
        • strsignal
        • strspn
        • strstr
        • strtok
        • strxfrm
      • syslog.h
        • syslog
        • openlog
        • syslog
      • sys/interrupt.h
        • interrupt_queueBroadcast
        • interrupt_queueCreate
        • interrupt_queueCreateLocked
        • interrupt_queueSignal
        • interrupt_queueWait
        • interrupt_queueWaitLocked
      • sys/mman.h
        • meminfo
        • mmap
        • munmap
      • sys/mount.h
        • umount
      • sys/msg.h
        • msgRecv
        • msgRespond
        • msgSend
      • sys/resource.h
        • getpriority
      • sys/select.h
        • select
      • sys/socket.h
        • accept
        • bind
        • connect
        • getpeername
        • getsockname
        • getsockopt
        • listen
        • recv
        • recvfrom
        • recvmsg
        • send
        • sendmsg
        • sendto
        • shutdown
        • sockatmark
        • socket
        • socketpair
      • sys/stat.h
        • fstat
        • fstatat
        • mkdir
        • mkfifo
        • stat
        • umask
      • sys/statvfs.h
        • statvfs
      • sys/times.h
        • times
        • utimes
      • sys/utsname.h
        • uname
      • sys/wait.h
        • waitpid
      • termios.h
        • cfgetispeed
        • cfgetospeed
        • cfsetispeed
        • cfsetospeed
        • tcdrain
        • tcflow
        • tcflush
        • tcgetattr
        • tcgetsid
        • tcsendbreak
      • sys/threads.h
        • condCreate
        • condCreateWithAttr
        • condSignal
        • condWait
        • getPriority
        • mutexCreate
        • mutexCreateWithAttr
        • mutexLock
        • mutexTry
        • mutexUnlock
        • priority
        • resourceDestroy
        • setPriority
      • time.h
        • asctime
        • clock_getcpuclockid
        • clock_getres
        • clock_nanosleep
        • ctime
        • difftime
        • nanosleep
        • time
        • utime
      • unistd.h
        • _exit
        • alarm
        • chdir
        • close
        • crypt
        • dup
        • exec
        • fork
        • fsync
        • ftruncate
        • getcwd
        • getegid
        • gethostid
        • gethostname
        • getopt
        • getpgid
        • getpgrp
        • getpid
        • getppid
        • getsid
        • getuid
        • isatty
        • link
        • lseek
        • nice
        • pause
        • pipe
        • read
        • readlink
        • rmdir
        • setpgid
        • setpgrp
        • setsid
        • sleep
        • sysconf
        • tcgetpgrp
        • tcsetpgrp
        • truncate
        • unlink
        • usleep
        • vfork
        • write
      • wchar.h
        • wcscmp
    • POSIX layer
  • Device drivers
    • Interface
    • Accessing hardware
    • Handling interrupts
    • Libsdio
    • Simsensors
  • Filesystems
  • Network stack
    • PPPoU driver
  • USB stack
    • USB Host stack
    • Libusb
  • Utilities
    • Phoenix Shell (psh)
      • bind
      • cat
      • cd
      • clear
      • cp
      • date
      • dd
      • df
      • dmesg
      • echo
      • edit
      • exec
      • exit
      • export
      • help
      • history
      • hm
      • ifconfig
      • kill
      • ln
      • ls
      • mem
      • mkdir
      • mount
      • nc
      • nslookup
      • ntpclient
      • perf
      • ping
      • pm
      • printenv
      • ps
      • pshapp
      • pshlogin
      • pwd
      • reboot
      • reset
      • rm
      • rmdir
      • / (runfile)
      • sync
      • sysexec
      • top
      • touch
      • tty
      • umount
      • unset
      • uptime
      • wget
    • Phoenix Downloader (psd)
  • Host utilities
    • Phoenix disk tool (psdisk)
    • Phoenix Serial Uploader (psu)
    • Phoenix Server (phoenixd)
  • Libraries
    • Common Gateway Interface library (libcgi)
    • VirtIO library (libvirtio)
    • VGA library (libvga)
    • Graphics library (libgraph)
    • Universally Unique identifiers library (libuuid)
    • Cache library (libcache)
    • Software watchdog library (libswdg)
    • SHA-256 library (libsha256)
  • Ports
    • Port definition (port.def.sh) specification
    • Picking ports to install using ports.yaml
    • List of available ports
    • Port-specific docs
      • Azure IoT C SDK Port
      • MbedTLS Port
      • WebAssembly Micro Runtime Port
  • Tests and testing process
  • Software Code Standards for C and Assembly Code
    • Appendix 1 - Phoenix MISRA C Profile
  • Debugging utilities
    • Tracing
      • Large targets quick-start
      • Small (RTT) targets quick-start
      • Obtaining trace from QEMU MBR disk image
      • Using Perfetto GUI to view kernel traces
      • Adding custom kernel events
Phoenix-RTOS ver. latest
Document Release Versions:
latest
3.4.0
3.3.2
3.3.1
  • Standard library
  • Functions
  • unistd.h
  • readlink

Back to top

readlink¶

Synopsis¶

#include <unistd.h>

ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize);

Status¶

Implemented

Conformance¶

IEEE Std 1003.1-2017

Description¶

The readlink() function shall place the contents of the symbolic link referred to by path in the buffer buf which has size bufsize. If the number of bytes in the symbolic link is less than bufsize, the contents of the remainder of buf are unspecified. If the buf argument is not large enough to contain the link content, the first bufsize bytes shall be placed in buf.

If the value of bufsize is greater than SSIZE_MAX, the result is implementation-defined.

Upon successful completion, readlink() shall mark for update the last data access timestamp of the symbolic link.

Applications should not assume that the contents of the symbolic link placed in buf are null-terminated.

Return value¶

Upon successful completion, readlink() shall return the count of bytes placed in the buffer. Otherwise, it shall return a value of -1, leave the buffer unchanged, and set errno to indicate the error.

Errors¶

The readlink() function shall fail if:

  • EACCES - Search permission is denied for a component of the path prefix of path.

  • EINVAL - The path argument names a file that is not a symbolic link.

  • EIO - An I/O error occurred while reading from the file system.

  • ELOOP - A loop exists in symbolic links encountered during resolution of the path argument.

  • ENAMETOOLONG - The length of a component of a path name is longer than the name length limit of the filesystem, which may differ from NAME_MAX (see POSIX deviations).

  • ENOENT - A component of path does not name an existing file or path is an empty string.

  • ENOTDIR - A component of the path prefix names an existing file that is neither a directory nor a symbolic link to a directory, or the path argument contains at least one non-<slash> character and ends with one or more trailing <slash> characters and the last path name component names an existing file that is neither a directory nor a symbolic link to a directory.

The readlink() function may fail if:

  • ELOOP - More than SYMLOOP_MAX symbolic links were encountered during resolution of the path argument.

  • ENAMETOOLONG - The length of a path name exceeds PATH_MAX, or path name resolution of a symbolic link produced an intermediate result with a length that exceeds PATH_MAX.

POSIX deviations¶

The length of a path name component is not checked against NAME_MAX by libphoenix, but by the filesystem server, against the name length limit of the filesystem, which may differ from NAME_MAX. readlink() only looks the name up, so the error reported for a too-long component depends on the filesystem: jffs2 reports ENAMETOOLONG, while ext2 and dummyfs check the length only when a new directory entry is created, so the lookup of the name fails with ENOENT. Checking every component in libphoenix would require knowing the name length limit of every mounted filesystem in each process, so the check is left to the filesystem server, which knows its own limit.

Next
rmdir
Previous
read
Copyright © 2024-2025, Phoenix Systems
Made with Sphinx and @pradyunsg's Furo
On this page
  • readlink
    • Synopsis
    • Status
    • Conformance
    • Description
    • Return value
    • Errors
    • POSIX deviations