Skip to content

Commit

Permalink
[FS] MkDir - Use relative paths correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswalmsley committed Sep 28, 2015
1 parent 334060d commit b242f5a
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions os/src/fs/bt_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,42 @@ BT_HANDLE BT_Open(const BT_i8 *szpPath, BT_u32 mode, BT_ERROR *pError) {
BT_EXPORT_SYMBOL(BT_Open);

BT_ERROR BT_MkDir(const BT_i8 *szpPath) {
BT_MOUNTPOINT *pMount = BT_GetMountPoint(szpPath);

BT_ERROR Error = BT_ERR_NONE;

BT_i8 *absolute_path = (BT_i8 *) szpPath;

#ifdef BT_CONFIG_PROCESS_CWD
absolute_path = BT_kMalloc(BT_PATH_MAX);
if(!absolute_path) {
Error = BT_ERR_GENERIC;
goto err_out;
}

Error = to_absolute_path(absolute_path, BT_PATH_MAX, szpPath, BT_FALSE);
if(Error) {
goto err_free_out;
}
#endif

BT_MOUNTPOINT *pMount = BT_GetMountPoint(absolute_path);
if(!pMount) {
return BT_ERR_GENERIC;
Error = BT_ERR_GENERIC;
goto err_free_out;
}

const BT_i8 *path = get_relative_path(pMount, szpPath);
const BT_i8 *path = get_relative_path(pMount, absolute_path);

const BT_IF_FS *pFS = pMount->pFS->hFS->h.pIf->oIfs.pFilesystemIF;
return pFS->pfnMkDir(pMount->hMount, path);
Error = pFS->pfnMkDir(pMount->hMount, path);

err_free_out:
#ifdef BT_CONFIG_PROCESS_CWD
BT_kFree(absolute_path);
err_out:
#endif

return Error;
}
BT_EXPORT_SYMBOL(BT_MkDir);

Expand Down

0 comments on commit b242f5a

Please sign in to comment.