📄 zfsgetfdcnt.c
字号:
/*
* File : ZFSGetFDCnt.c
* Description: This file contains the implementation of ZFS APIs
* 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: ZFSGetDirFileCount
//Description: This API will return the number of files/directories present in the given directory path
INT32 ZFSGetDirFileCount( IN INT8 *dir_path )
{
UINT off = 0 ;
UINT len = 0 ;
INT32 fd_count ;
PZFS_DIR_LIST_t pdir_node, pcwd_dir_node ;
PZFS_VOL_INFO_t pvol_info ;
UINT8 status ;
// if ZFS is not initialized, return error
if( !IsZFSInited() )
return ZFSERR_NOT_INITIALIZED ;
if( dir_path == NULL )
return ZFSERR_INVALID_ARGUMENTS ;
// now check the validity of the dir path given in the argument
if( !ValidatePath( dir_path ) )
return ZFSERR_INVALID_FILEDIR_PATH ;
// get the length of the directory
len = strlen( (const INT8 *)dir_path ) ;
// disable preemption
RZKAcquireSemaphore(hSem_FS,INFINITE_SUSPEND);
// preempt_status = DisablePreemption() ;
if( GetCwdInfoForCurThread( &pvol_info, &pcwd_dir_node ) != ZFS_TRUE )
{
RZKReleaseSemaphore(hSem_FS);
// EnablePreemption( preempt_status ) ;
return ZFSERR_INVALID_VOLUME ;
}
// now validated, disable preemption, find the absolute path
status = IsAbsPath( dir_path, &pvol_info, &off, &pdir_node ) ;
if( status != ZFS_TRUE )
{
RZKReleaseSemaphore(hSem_FS);
// EnablePreemption( preempt_status ) ;
return ZFSERR_INVALID_FILEDIR_PATH ;
}
if( !IsVolumeValid(pvol_info) )
{
RZKReleaseSemaphore(hSem_FS);
// EnablePreemption( preempt_status ) ;
return ZFSERR_INVALID_VOLUME ;
}
if( pdir_node == NULL )
{
// this is relative path, get the directory node of the relative path
// get the CWD_INFO table
pdir_node = pcwd_dir_node ;
}
pdir_node = GetNodeForPath( pdir_node, dir_path + off, (len - off ) ) ;
if( pdir_node == NULL )
{
RZKReleaseSemaphore(hSem_FS);
// EnablePreemption( preempt_status ) ;
return ZFSERR_INVALID_FILEDIR_PATH ;
}
// node is found, just update the cwd info into the CWD_INFO structure
fd_count = pdir_node->fd_cnt ;
RZKReleaseSemaphore(hSem_FS);
// EnablePreemption( preempt_status ) ;
return fd_count ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -