📄 zfsgetcwdlen.c
字号:
/*
* File : ZFSGetCwdLen.c
* Description: This file contains the implementation of ZFSGetCwdLen API
* Author : Mahadev K C
* Created on : 30-APR-2003
*
* Copyright 2004 ZiLOG Inc. ALL RIGHTS RESERVED.
*
* This file contains unpublished confidential and proprietary information
* of ZiLOG, Inc.
* NO PART OF THIS WORK MAY BE DUPLICATED, STORED, PUBLISHED OR DISCLOSED
* IN ANY FORM WITHOUT THE PRIOR WRITTEN CONSENT OF ZiLOG, INC.
* This is not a license and no use of any kind of this work is authorized
* in the absence of a written license granted by ZiLOG, Inc. in ZiLOG's
* sole discretion
*/
#include "ZSysgen.h"
#include "ZTypes.h"
#include "ZThread.h"
#include "ZSemaphore.h"
#include "glextern.h"
extern RZK_SEMAPHOREHANDLE_t hSem_FS;
//Function Name: ZFSGetCwd
//Description: This API gets the current working directory for the thread
INT ZFSGetCwdLen( VOID )
{
// get the cwd node, and traverse in reverse to get the directory name and store the same in the
// the pointer provided by the user.
INT8 *pstr ;
PZFS_DIR_LIST_t pdir_node, pcwd_dir_node ;
PZFS_VOL_INFO_t pvol_info ;
UINT off = 0 ;
ZFS_STATUS_t status ;
// if ZFS is not initialized, return error
if( !IsZFSInited() )
return ZFSERR_NOT_INITIALIZED ;
pstr = GetCwdPathForHandle( GetCurrentThread() ) ;
RZKAcquireSemaphore(hSem_FS,INFINITE_SUSPEND);
// preempt_status = DisablePreemption() ;
// check whether the CWD is valid or not: it may happen that
// cwd in this thread may have an invalid volume:
if( GetCwdInfoForCurThread( &pvol_info, &pcwd_dir_node ) != ZFS_TRUE )
{
// EnablePreemption( preempt_status ) ;
RZKReleaseSemaphore(hSem_FS);
return ZFSERR_INVALID_VOLUME ;
}
// now validated, disable preemption, find the absolute path with reduced length
status = IsAbsPath( pstr, &pvol_info, &off, &pdir_node) ;
if( status != ZFS_TRUE )
{
// EnablePreemption( preempt_status ) ;
RZKReleaseSemaphore(hSem_FS);
return ZFSERR_INTERNAL ;
}
if( !IsVolumeValid(pvol_info) )
{
// EnablePreemption( preempt_status ) ;
RZKReleaseSemaphore(hSem_FS);
return ZFSERR_INVALID_VOLUME ;
}
RZKReleaseSemaphore(hSem_FS);
// EnablePreemption( preempt_status ) ;
return strlen( (const INT8 *)pstr ) ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -