Ignore:
File:
1 edited

Legend:

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

    rec18957a r9b1503e  
    3636#define LIBPOSIX_INTERNAL
    3737
     38#include "stat.h"
    3839#include "../internal/common.h"
    39 #include "stat.h"
    40 
    41 #include "../errno.h"
    42 #include "../libc/mem.h"
     40#include <mem.h>
    4341
    4442/**
    45  * Convert HelenOS stat struct into POSIX stat struct (if possible).
     43 * Convert HelenOS stat struct into POSIX stat struct (if possible)
    4644 *
    47  * @param dest POSIX stat struct.
    48  * @param src HelenOS stat struct.
     45 * @param dest
     46 * @param src
    4947 */
    5048static void stat_to_posix(struct posix_stat *dest, struct stat *src)
     
    6866
    6967/**
    70  * Retrieve file status for file associated with file descriptor.
    7168 *
    72  * @param fd File descriptor of the opened file.
    73  * @param st Status structure to be filled with information.
    74  * @return Zero on success, -1 otherwise.
     69 * @param fd
     70 * @param st
     71 * @return
    7572 */
    7673int posix_fstat(int fd, struct posix_stat *st)
    7774{
    7875        struct stat hst;
    79         int rc = fstat(fd, &hst);
    80         if (rc < 0) {
    81                 /* fstat() returns negative error code instead of using errno.
    82                  */
    83                 errno = -rc;
     76        if (fstat(fd, &hst) == -1) {
     77                // TODO: propagate a POSIX compatible errno
    8478                return -1;
    8579        }
     
    8983
    9084/**
    91  * Retrieve file status for symbolic link.
    9285 *
    93  * @param path Path to the symbolic link.
    94  * @param st Status structure to be filled with information.
    95  * @return Zero on success, -1 otherwise.
     86 * @param path
     87 * @param st
     88 * @return
    9689 */
    97 int posix_lstat(const char *path, struct posix_stat *st)
     90int posix_lstat(const char *restrict path, struct posix_stat *restrict st)
    9891{
    99         /* There are currently no symbolic links in HelenOS. */
    100         return posix_stat(path, st);
     92        // TODO
     93        not_implemented();
    10194}
    10295
    10396/**
    104  * Retrieve file status for regular file (or symbolic link target).
    10597 *
    106  * @param path Path to the file/link.
    107  * @param st Status structure to be filled with information.
    108  * @return Zero on success, -1 otherwise.
     98 * @param path
     99 * @param st
     100 * @return
    109101 */
    110102int posix_stat(const char *path, struct posix_stat *st)
    111103{
    112104        struct stat hst;
    113         int rc = stat(path, &hst);
    114         if (rc < 0) {
    115                 /* stat() returns negative error code instead of using errno.
    116                  */
    117                 errno = -rc;
     105        if (stat(path, &hst) == -1) {
     106                // TODO: propagate a POSIX compatible errno
    118107                return -1;
    119108        }
     
    123112
    124113/**
    125  * Change permission bits for the file if possible.
    126114 *
    127  * @param path Path to the file.
    128  * @param mode Permission bits to be set.
    129  * @return Zero on success, -1 otherwise.
     115 * @param path
     116 * @param mode
     117 * @return
    130118 */
    131119int posix_chmod(const char *path, mode_t mode)
    132120{
    133         /* HelenOS doesn't support permissions, return success. */
    134         return 0;
     121        // TODO
     122        not_implemented();
    135123}
    136124
    137125/**
    138  * Set the file mode creation mask of the process.
    139126 *
    140  * @param mask Set permission bits are cleared in the related creation
    141  *     functions. Non-permission bits are ignored.
    142  * @return Previous file mode creation mask.
     127 * @param mask
     128 * @return
    143129 */
    144130mode_t posix_umask(mode_t mask)
    145131{
    146         /* HelenOS doesn't support permissions, return empty mask. */
    147         return 0;
     132        // TODO
     133        not_implemented();
    148134}
    149135
Note: See TracChangeset for help on using the changeset viewer.