Changeset 35a35651 in mainline for uspace/lib/c/generic/vfs/vfs.c


Ignore:
Timestamp:
2012-05-04T11:31:47Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b00255a
Parents:
f2b3d3e
Message:

Previous work-dir handling only in Bdsh, not in libc

File:
1 edited

Legend:

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

    rf2b3d3e r35a35651  
    5858static async_sess_t *vfs_sess = NULL;
    5959
    60 /* Current (working) directory. */
    6160static FIBRIL_MUTEX_INITIALIZE(cwd_mutex);
     61
    6262static int cwd_fd = -1;
    6363static char *cwd_path = NULL;
    6464static size_t cwd_size = 0;
    65 
    66 /* Previous directory. */
    67 static FIBRIL_MUTEX_INITIALIZE(pwd_mutex);
    68 static int pwd_fd = -1;
    69 static char *pwd_path = NULL;
    70 static size_t pwd_size = 0;
    71 
    7265
    7366/** Start an async exchange on the VFS session.
     
    758751        fibril_mutex_lock(&cwd_mutex);
    759752       
    760 
    761         fibril_mutex_lock(&pwd_mutex);
    762 
    763         if (pwd_fd >= 0)
    764                 close(pwd_fd);
    765 
    766 
    767         if (pwd_path)
    768                 free(pwd_path);
    769 
    770 
    771         pwd_fd = cwd_fd;
    772         pwd_path = cwd_path;
    773         pwd_size = cwd_size;
    774 
    775         fibril_mutex_unlock(&pwd_mutex);
    776 
     753        if (cwd_fd >= 0)
     754                close(cwd_fd);
     755       
     756       
     757        if (cwd_path)
     758                free(cwd_path);
     759       
    777760        cwd_fd = fd;
    778761        cwd_path = abs;
     
    798781        fibril_mutex_unlock(&cwd_mutex);
    799782       
    800         return buf;
    801 }
    802 
    803 
    804 char *getprevwd(char *buf, size_t size)
    805 {
    806         if (size == 0)
    807                 return NULL;
    808 
    809         fibril_mutex_lock(&pwd_mutex);
    810 
    811         if ((pwd_size == 0) || (size < pwd_size + 1)) {
    812                 fibril_mutex_unlock(&pwd_mutex);
    813                 return NULL;
    814         }
    815 
    816         str_cpy(buf, size, pwd_path);
    817         fibril_mutex_unlock(&pwd_mutex);
    818 
    819783        return buf;
    820784}
Note: See TracChangeset for help on using the changeset viewer.