Changeset d96d9bc in mainline for uspace/lib/c


Ignore:
Timestamp:
2017-04-02T20:38:50Z (9 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c23275a
Parents:
1e2e5795
Message:

Rename chdir() to vfs_cwd_set() and getcwd() to vfs_cwd_get()

Location:
uspace/lib/c
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/libc.c

    r1e2e5795 rd96d9bc  
    116116                __stdio_init();
    117117                vfs_root_set(inbox_get("root"));
    118                 (void) chdir(__pcb->cwd);
     118                (void) vfs_cwd_set(__pcb->cwd);
    119119        }
    120120       
  • uspace/lib/c/generic/loader.c

    r1e2e5795 rd96d9bc  
    124124                return ENOMEM;
    125125       
    126         if (getcwd(cwd, MAX_PATH_LEN + 1) == NULL)
     126        if (vfs_cwd_get(cwd, MAX_PATH_LEN + 1) != EOK)
    127127                str_cpy(cwd, MAX_PATH_LEN + 1, "/");
    128128       
  • uspace/lib/c/generic/vfs/vfs.c

    r1e2e5795 rd96d9bc  
    808808 *
    809809 * @param path Path
    810  * @return 0 on success. On error returns -1 and sets errno.
    811  */
    812 int chdir(const char *path)
     810 * @return EOK on success or a negative error code otherwise.
     811 */
     812int vfs_cwd_set(const char *path)
    813813{
    814814        size_t abs_size;
    815815        char *abs = vfs_absolutize(path, &abs_size);
    816         if (!abs) {
    817                 errno = ENOMEM;
    818                 return -1;
    819         }
     816        if (!abs)
     817                return ENOMEM;
    820818       
    821819        int fd = vfs_lookup(abs, WALK_DIRECTORY);
    822820        if (fd < 0) {
    823821                free(abs);
    824                 errno = fd;
    825                 return -1;
     822                return fd;
    826823        }
    827824       
     
    839836       
    840837        fibril_mutex_unlock(&cwd_mutex);
    841         return 0;
     838        return EOK;
    842839}
    843840
     
    846843 * @param buf Buffer
    847844 * @param size Size of @a buf
    848  * @return On success returns @a buf. On failure returns @c NULL and sets errno.
    849  */
    850 char *getcwd(char *buf, size_t size)
    851 {
    852         if (size == 0) {
    853                 errno = EINVAL;
    854                 return NULL;
    855         }
    856        
     845 * @return EOK on success and a non-negative error code otherwise.
     846 */
     847int vfs_cwd_get(char *buf, size_t size)
     848{
    857849        fibril_mutex_lock(&cwd_mutex);
    858850       
    859851        if ((cwd_size == 0) || (size < cwd_size + 1)) {
    860852                fibril_mutex_unlock(&cwd_mutex);
    861                 errno = ERANGE;
    862                 return NULL;
     853                return ERANGE;
    863854        }
    864855       
     
    866857        fibril_mutex_unlock(&cwd_mutex);
    867858       
    868         return buf;
     859        return EOK;
    869860}
    870861
  • uspace/lib/c/include/unistd.h

    r1e2e5795 rd96d9bc  
    5858#define getpagesize()  (PAGE_SIZE)
    5959
    60 extern char *getcwd(char *, size_t);
    61 extern int chdir(const char *);
    62 
    6360extern void exit(int) __attribute__((noreturn));
    6461extern int usleep(useconds_t);
  • uspace/lib/c/include/vfs/vfs.h

    r1e2e5795 rd96d9bc  
    7474
    7575extern char *vfs_absolutize(const char *, size_t *);
     76extern int vfs_cwd_set(const char *path);
     77extern int vfs_cwd_get(char *path, size_t);
    7678
    7779extern int vfs_fhandle(FILE *, int *);
Note: See TracChangeset for help on using the changeset viewer.