Changeset 368ee04 in mainline for uspace/lib/posix/source/sys/stat.c


Ignore:
Timestamp:
2017-04-05T18:10:39Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
93ad8166
Parents:
39f892a9 (diff), 2166728 (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 from lp:~jakub/helenos/vfs-2.5-cherrypick

This merge cherry-picks some of the changesets from Jiri Zarevucky's:

lp:~zarevucky-jiri/helenos/vfs-2.5

and then continues independently, yet sometime in a similar vein.

Roughly speaking, Jiri's branch is merged entirely up to its revision
1926 and then cherry-picked on and off until its revision 1965. Among
these changes are:

  • relativization of the API,
  • client-side roots,
  • server-side mounts,
  • inbox for passing arbitrary files from parent to child,
  • some streamlining and cleanup.

Additional changes include:

  • addressing issues introduced by the above changes,
  • client-side I/O cursors (file positions),
  • all HelenOS file system APIs begin with the vfs_ prefix and can be used after including vfs/vfs.h,
  • removal of some POSIX-ish headers and definitions,
  • additional cleanup.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/source/sys/stat.c

    r39f892a9 r368ee04  
    3939#include "../internal/common.h"
    4040#include "posix/sys/stat.h"
    41 #include "libc/sys/stat.h"
     41#include "libc/vfs/vfs.h"
    4242
    4343#include "posix/errno.h"
     
    4949 * @param dest POSIX stat struct.
    5050 * @param src HelenOS stat struct.
     51 *
     52 * @return 0 on success, -1 on error.
    5153 */
    52 static void stat_to_posix(struct posix_stat *dest, struct stat *src)
     54static int stat_to_posix(struct posix_stat *dest, struct stat *src)
    5355{
    5456        memset(dest, 0, sizeof(struct posix_stat));
     
    6870        dest->st_nlink = src->lnkcnt;
    6971        dest->st_size = src->size;
     72
     73        if (src->size > INT64_MAX) {
     74                errno = ERANGE;
     75                return -1;
     76        }
     77
     78        return 0;
    7079}
    7180
     
    8089{
    8190        struct stat hst;
    82         int rc = negerrno(fstat, fd, &hst);
     91        int rc = rcerrno(vfs_stat, fd, &hst);
    8392        if (rc < 0)
    84                 return rc;
    85         stat_to_posix(st, &hst);
    86         return 0;
     93                return -1;
     94        return stat_to_posix(st, &hst);
    8795}
    8896
     
    110118{
    111119        struct stat hst;
    112         int rc = negerrno(stat, path, &hst);
     120        int rc = rcerrno(vfs_stat_path, path, &hst);
    113121        if (rc < 0)
    114                 return rc;
    115         stat_to_posix(st, &hst);
    116         return 0;
     122                return -1;
     123        return stat_to_posix(st, &hst);
    117124}
    118125
     
    124131 * @return Zero on success, -1 otherwise.
    125132 */
    126 int posix_chmod(const char *path, mode_t mode)
     133int posix_chmod(const char *path, posix_mode_t mode)
    127134{
    128135        /* HelenOS doesn't support permissions, return success. */
     
    137144 * @return Previous file mode creation mask.
    138145 */
    139 mode_t posix_umask(mode_t mask)
     146posix_mode_t posix_umask(posix_mode_t mask)
    140147{
    141148        /* HelenOS doesn't support permissions, return empty mask. */
     
    143150}
    144151
     152/**
     153 * Create a directory.
     154 *
     155 * @param path Path to the new directory.
     156 * @param mode Permission bits to be set.
     157 * @return Zero on success, -1 otherwise.
     158 */
     159int posix_mkdir(const char *path, posix_mode_t mode)
     160{
     161        int rc = rcerrno(vfs_link_path, path, KIND_DIRECTORY, NULL);
     162        if (rc != EOK)
     163                return -1;
     164        else
     165                return 0;
     166}
     167
    145168/** @}
    146169 */
Note: See TracChangeset for help on using the changeset viewer.