libio_.h

来自「AMLOGIC DPF source code」· C头文件 代码 · 共 267 行

H
267
字号
/*******************************************************************
 * 
 *  Copyright C 2005 by Amlogic, Inc. All Rights Reserved.
 *
 *  Description: 
 *
 *  Author: Amlogic Software
 *  Created: Fri Nov 11 01:05:21 2005
 *
 *******************************************************************/
/*
 *  Libio Internal Information
 *
 *  COPYRIGHT (c) 1989-1999.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.avfs.com/license/LICENSE.
 *
 *  libio_.h,v 1.19.2.2 2003/11/25 17:27:38 jennifer Exp
 */

#ifndef __AVFS_LIBIO_INTERNAL__h
#define __AVFS_LIBIO_INTERNAL__h

#ifdef __cplusplus
extern "C" {
#endif
#if 0
//porting
#include <avfs.h>
#include <avfs/libio.h>                /* include before standard IO */

#include <sys/types.h>                  

#include <errno.h>
#else
#include "libio.h"
#endif
/*
 *  Semaphore to protect the io table
 */

#define AVFS_LIBIO_SEM         avfs_build_name('L', 'B', 'I', 'O')
#define AVFS_LIBIO_IOP_SEM(n)  avfs_build_name('L', 'B', 'I', n)

#if 0
// porting
extern avfs_id                          avfs_libio_semaphore;
#endif
extern avfs_filesystem_file_handlers_r  avfs_filesystem_null_handlers;

/*
 *  File descriptor Table Information
 */

extern unsigned32      avfs_libio_number_iops;
extern avfs_libio_t  *avfs_libio_iops;
extern avfs_libio_t  *avfs_libio_last_iop;
extern avfs_libio_t *avfs_libio_iop_freelist;

/*
 *  avfs_libio_iop
 *
 *  Macro to return the file descriptor pointer.
 */

#define avfs_libio_iop(_fd) \
  ((((unsigned32)(_fd)) < avfs_libio_number_iops) ? \
         &avfs_libio_iops[_fd] : 0)

/*  
 *  avfs_libio_check_is_open
 *  
 *  Macro to check if a file descriptor is actually open.
 */

#define avfs_libio_check_is_open(_iop) \
  do {                                               \
      if (((_iop)->flags & LIBIO_FLAGS_OPEN) == 0) { \
          errno = EBADF;                             \
          return -1;                                 \
      }                                              \
  } while (0)

/*
 *  avfs_libio_check_fd
 *
 *  Macro to check if a file descriptor number is valid.
 */

#define avfs_libio_check_fd(_fd) \
  do {                                                     \
      if ((unsigned32) (_fd) >= avfs_libio_number_iops) { \
          errno = EBADF;                                   \
          return -1;                                       \
      }                                                    \
  } while (0)

/*
 *  avfs_libio_check_buffer
 *
 *  Macro to check if a buffer pointer is valid.
 */

#define avfs_libio_check_buffer(_buffer) \
  do {                                    \
      if ((_buffer) == 0) {               \
          errno = EINVAL;                 \
          return -1;                      \
      }                                   \
  } while (0)

/*
 *  avfs_libio_check_count
 *
 *  Macro to check if a count or length is valid.
 */

#define avfs_libio_check_count(_count) \
  do {                                  \
      if ((_count) == 0) {              \
          return 0;                     \
      }                                 \
  } while (0)

/*
 *  avfs_libio_check_permissions
 *
 *  Macro to check if a file descriptor is open for this operation.
 */

#define avfs_libio_check_permissions(_iop, _flag)    \
  do {                                                \
      if (((_iop)->flags & (_flag)) == 0) {           \
            avfs_set_errno_and_return_minus_one( EINVAL ); \
          }                                               \
  } while (0)

/*
 *  avfs_filesystem_freenode
 *
 *  Macro to free a node.
 */

#define avfs_filesystem_freenode( _node ) \
  do { \
    if ( (_node)->ops )\
      if ( (_node)->ops->freenod_h ) \
        (*(_node)->ops->freenod_h)( (_node) ); \
  } while (0)

/*
 *  avfs_filesystem_is_separator
 *
 *  Macro to determine if a character is a path name separator.
 *
 *  NOTE:  This macro handles MS-DOS and UNIX style names.
 */

#define avfs_filesystem_is_separator( _ch ) \
   ( ((_ch) == '/') || ((_ch) == '\\') || ((_ch) == '\0'))

/*
 *  avfs_filesystem_get_start_loc
 *
 *  Macro to determine if path is absolute or relative.
 */

#define avfs_filesystem_get_start_loc( _path, _index, _loc )  \
  do {                                                         \
    if ( avfs_filesystem_is_separator( (_path)[ 0 ] ) ) {     \
      *(_loc) = avfs_filesystem_root;                         \
      *(_index) = 1;                                           \
    } else {                                                   \
      *(_loc) = avfs_filesystem_current;                      \
      *(_index) = 0;                                           \
    }                                                          \
  } while (0)

#define avfs_filesystem_get_sym_start_loc( _path, _index, _loc )  \
  do {                                                         \
    if ( avfs_filesystem_is_separator( (_path)[ 0 ] ) ) {     \
      *(_loc) = avfs_filesystem_root;                         \
      *(_index) = 1;                                           \
    } else {                                                   \
      *(_index) = 0;                                           \
    }                                                          \
  } while (0)


/*
 *  External structures
 */
// porting
//#include <avfs/userenv.h>
//#include "userenv.h"
#if 0
// porting
extern avfs_user_env_t * avfs_current_user_env; 
extern avfs_user_env_t   avfs_global_user_env; 
#endif

/*
 *  Instantiate a private copy of the per user information for the calling task.
 */

avfs_status_code avfs_libio_set_private_env(void);
#if 0
// porting
avfs_status_code avfs_libio_share_private_env(avfs_id task_id) ;
#endif
	
/*
 *  File Descriptor Routine Prototypes
 */

avfs_libio_t *avfs_libio_allocate(void);

unsigned32 avfs_libio_fcntl_flags(
  unsigned32 fcntl_flags
);

unsigned32 avfs_libio_to_fcntl_flags(
  unsigned32 flags
);

void avfs_libio_free(
  avfs_libio_t *iop
);

int avfs_libio_is_open_files_in_fs(
  avfs_filesystem_mount_table_entry_t *mt_entry
);

int avfs_libio_is_file_open(
  void  *node_access
);

/*
 *  File System Routine Prototypes
 */

int avfs_filesystem_evaluate_path(
  const char                        *pathname,
  int                                flags,
  avfs_filesystem_location_info_t  *pathloc,
  int                                follow_link
);

int avfs_filesystem_evaluate_parent(
  int                                flags,
  avfs_filesystem_location_info_t  *pathloc
);

void avfs_filesystem_initialize();

int init_fs_mount_table();

#ifdef __cplusplus
}
#endif

#endif
/* end of include file */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?