Changeset 2b3dd78 in mainline for uspace/lib/posix/src/unistd.c


Ignore:
Timestamp:
2018-01-31T12:02:00Z (7 years ago)
Author:
Jenda <jenda.jzqk73@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5595841
Parents:
a0a9cc2 (diff), 14d789c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge remote-tracking branch 'upstream/master' into forwardport

change tmon includes because of new stdlib

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/src/unistd.c

    ra0a9cc2 r2b3dd78  
    3434 */
    3535
    36 #define LIBPOSIX_INTERNAL
    37 #define __POSIX_DEF__(x) posix_##x
    38 
    3936#include "internal/common.h"
    4037#include "posix/unistd.h"
     
    5754
    5855/* Array of environment variable strings (NAME=VALUE). */
    59 char **posix_environ = NULL;
    60 char *posix_optarg;
     56char **environ = NULL;
    6157
    6258/**
     
    7066 * @return Always 0 on HelenOS.
    7167 */
    72 unsigned int posix_sleep(unsigned int seconds)
     68unsigned int sleep(unsigned int seconds)
    7369{
    7470        return thread_sleep(seconds);
     
    8076 * @return User name (static) string or NULL if not found.
    8177 */
    82 char *posix_getlogin(void)
     78char *getlogin(void)
    8379{
    8480        /* There is currently no support for user accounts in HelenOS. */
     
    9389 * @return Zero on success, error code otherwise.
    9490 */
    95 int posix_getlogin_r(char *name, size_t namesize)
     91int getlogin_r(char *name, size_t namesize)
    9692{
    9793        /* There is currently no support for user accounts in HelenOS. */
    9894        if (namesize >= 5) {
    99                 posix_strcpy(name, (char *) "user");
     95                strcpy(name, (char *) "user");
    10096                return 0;
    10197        } else {
     
    111107 * @return Boolean result of the test.
    112108 */
    113 int posix_isatty(int fd)
     109int isatty(int fd)
    114110{
    115111        // TODO
     
    126122 * @return Buffer pointer on success, NULL on failure.
    127123 */
    128 char *posix_getcwd(char *buf, size_t size)
     124char *getcwd(char *buf, size_t size)
    129125{
    130126        if (failed(vfs_cwd_get(buf, size)))
     
    138134 * @param path New working directory.
    139135 */
    140 int posix_chdir(const char *path)
     136int chdir(const char *path)
    141137{
    142138        if (failed(vfs_cwd_set(path)))
     
    150146 * @return Page size of the process.
    151147 */
    152 int posix_getpagesize(void)
     148int getpagesize(void)
    153149{
    154150        return PAGE_SIZE;
     
    160156 * @return Process ID.
    161157 */
    162 posix_pid_t posix_getpid(void)
     158pid_t getpid(void)
    163159{
    164160        return task_get_id();
     
    170166 * @return User ID.
    171167 */
    172 posix_uid_t posix_getuid(void)
     168uid_t getuid(void)
    173169{
    174170        /* There is currently no support for user accounts in HelenOS. */
     
    181177 * @return Group ID.
    182178 */
    183 posix_gid_t posix_getgid(void)
     179gid_t getgid(void)
    184180{
    185181        /* There is currently no support for user accounts in HelenOS. */
     
    193189 * @return 0 on success, -1 on error.
    194190 */
    195 int posix_close(int fildes)
     191int close(int fildes)
    196192{
    197193        posix_pos[fildes] = 0;
     
    210206 * @return Number of read bytes on success, -1 otherwise.
    211207 */
    212 ssize_t posix_read(int fildes, void *buf, size_t nbyte)
     208ssize_t read(int fildes, void *buf, size_t nbyte)
    213209{
    214210        size_t nread;
     
    226222 * @return Number of written bytes on success, -1 otherwise.
    227223 */
    228 ssize_t posix_write(int fildes, const void *buf, size_t nbyte)
     224ssize_t write(int fildes, const void *buf, size_t nbyte)
    229225{
    230226        size_t nwr;
     
    243239 *         as measured in bytes from the beginning of the file, -1 otherwise.
    244240 */
    245 posix_off_t posix_lseek(int fildes, posix_off_t offset, int whence)
    246 {
    247         struct stat st;
     241off_t lseek(int fildes, off_t offset, int whence)
     242{
     243        vfs_stat_t st;
    248244
    249245        switch (whence) {
     
    274270 * @return Zero on success, -1 otherwise.
    275271 */
    276 int posix_fsync(int fildes)
     272int fsync(int fildes)
    277273{
    278274        if (failed(vfs_sync(fildes)))
     
    289285 * @return Zero on success, -1 otherwise.
    290286 */
    291 int posix_ftruncate(int fildes, posix_off_t length)
     287int ftruncate(int fildes, off_t length)
    292288{
    293289        if (failed(vfs_resize(fildes, (aoff64_t) length)))
     
    303299 * @return Zero on success, -1 otherwise.
    304300 */
    305 int posix_rmdir(const char *path)
     301int rmdir(const char *path)
    306302{
    307303        if (failed(vfs_unlink_path(path)))
     
    317313 * @return Zero on success, -1 otherwise.
    318314 */
    319 int posix_unlink(const char *path)
     315int unlink(const char *path)
    320316{
    321317        if (failed(vfs_unlink_path(path)))
     
    331327 * @return On success, new file descriptor for the same file, otherwise -1.
    332328 */
    333 int posix_dup(int fildes)
    334 {
    335         return posix_fcntl(fildes, F_DUPFD, 0);
     329int dup(int fildes)
     330{
     331        return fcntl(fildes, F_DUPFD, 0);
    336332}
    337333
     
    344340 * @return fildes2 on success, -1 otherwise.
    345341 */
    346 int posix_dup2(int fildes, int fildes2)
     342int dup2(int fildes, int fildes2)
    347343{
    348344        int file;
     
    360356 * @return Zero on success, -1 otherwise.
    361357 */
    362 int posix_access(const char *path, int amode)
     358int access(const char *path, int amode)
    363359{
    364360        if (amode == F_OK || (amode & (X_OK | W_OK | R_OK))) {
     
    368364                 * Check file existence by attempting to open it.
    369365                 */
    370                 int fd = posix_open(path, O_RDONLY);
     366                int fd = open(path, O_RDONLY);
    371367                if (fd < 0)
    372368                        return -1;
    373                 posix_close(fd);
     369                close(fd);
    374370                return 0;
    375371        } else {
     
    386382 * @return Variable value.
    387383 */
    388 long posix_sysconf(int name)
     384long sysconf(int name)
    389385{
    390386        long clk_tck = 0;
     
    403399        stats_physmem_t *mem_stats = stats_get_physmem();
    404400        if (mem_stats) {
    405                 phys_pages = (long) (mem_stats->total / posix_getpagesize());
    406                 avphys_pages = (long) (mem_stats->free / posix_getpagesize());
     401                phys_pages = (long) (mem_stats->total / getpagesize());
     402                avphys_pages = (long) (mem_stats->free / getpagesize());
    407403                free(mem_stats);
    408404                mem_stats = 0;
     
    415411                return avphys_pages;
    416412        case _SC_PAGESIZE:
    417                 return posix_getpagesize();
     413                return getpagesize();
    418414        case _SC_CLK_TCK:
    419415                return clk_tck;
     
    430426 * @return
    431427 */
    432 long posix_pathconf(const char *path, int name)
     428long pathconf(const char *path, int name)
    433429{
    434430        // TODO: low priority, just a compile-time dependency of binutils
     
    441437 * @return
    442438 */
    443 posix_pid_t posix_fork(void)
     439pid_t fork(void)
    444440{
    445441        // TODO: low priority, just a compile-time dependency of binutils
     
    454450 * @return
    455451 */
    456 int posix_execv(const char *path, char *const argv[])
     452int execv(const char *path, char *const argv[])
    457453{
    458454        // TODO: low priority, just a compile-time dependency of binutils
     
    467463 * @return
    468464 */
    469 int posix_execvp(const char *file, char *const argv[])
     465int execvp(const char *file, char *const argv[])
    470466{
    471467        // TODO: low priority, just a compile-time dependency of binutils
     
    479475 * @return
    480476 */
    481 int posix_pipe(int fildes[2])
     477int pipe(int fildes[2])
    482478{
    483479        // TODO: low priority, just a compile-time dependency of binutils
     
    486482}
    487483
    488 unsigned int posix_alarm(unsigned int seconds)
     484unsigned int alarm(unsigned int seconds)
    489485{
    490486        not_implemented();
Note: See TracChangeset for help on using the changeset viewer.