Changeset d96d9bc in mainline for uspace/lib/c/generic/vfs/vfs.c


Ignore:
Timestamp:
2017-04-02T20:38:50Z (7 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()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.