libio.h
来自「AMLOGIC DPF source code」· C头文件 代码 · 共 658 行 · 第 1/2 页
H
658 行
/*******************************************************************
*
* Copyright C 2005 by Amlogic, Inc. All Rights Reserved.
*
* Description:
*
* Author: Amlogic Software
* Created: Fri Nov 11 01:05:14 2005
*
*******************************************************************/
/*
* System call and file system interface definition
*
* General purpose communication channel for AVFS to allow UNIX/POSIX
* system call behavior under AVFS. Initially this supported only
* IO to devices but has since been enhanced to support networking
* and support for mounted file systems.
*
* 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.41.2.2 2003/09/04 18:46:58 joel Exp
*/
#ifndef _AVFS_LIBIO_H
#define _AVFS_LIBIO_H
#if 0
//porting
#include <avfs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
/*
* Define data types which must be constructed using forward references.
*/
#include <avfs/fs.h>
#else
//#include "fs.h"
#endif
/*
* Valid AVFS file types.
*/
#define AVFS_FILESYSTEM_DIRECTORY 1
#define AVFS_FILESYSTEM_DEVICE 2
#define AVFS_FILESYSTEM_HARD_LINK 3
#define AVFS_FILESYSTEM_SYM_LINK 4
#define AVFS_FILESYSTEM_MEMORY_FILE 5
typedef int avfs_filesystem_node_types_t;
/*
* File Handler Operations Table
*/
typedef int (*avfs_filesystem_open_t)(
avfs_libio_t *iop,
const char *pathname,
unsigned32 flag,
unsigned32 mode
);
typedef int (*avfs_filesystem_close_t)(
avfs_libio_t *iop
);
typedef ssize_t (*avfs_filesystem_read_t)(
avfs_libio_t *iop,
void *buffer,
unsigned32 count
);
typedef ssize_t (*avfs_filesystem_write_t)(
avfs_libio_t *iop,
const void *buffer,
unsigned32 count
);
typedef int (*avfs_filesystem_ioctl_t)(
avfs_libio_t *iop,
unsigned32 command,
void *buffer
);
typedef int (*avfs_filesystem_lseek_t)(
avfs_libio_t *iop,
off_t length,
int whence
);
typedef int (*avfs_filesystem_fstat_t)(
avfs_filesystem_location_info_t *loc,
struct stat *buf
);
typedef int (*avfs_filesystem_fchmod_t)(
avfs_filesystem_location_info_t *loc,
mode_t mode
);
typedef int (*avfs_filesystem_ftruncate_t)(
avfs_libio_t *iop,
off_t length
);
typedef int (*avfs_filesystem_fpathconf_t)(
avfs_libio_t *iop,
int name
);
typedef int (*avfs_filesystem_fsync_t)(
avfs_libio_t *iop
);
typedef int (*avfs_filesystem_fdatasync_t)(
avfs_libio_t *iop
);
typedef int (*avfs_filesystem_fcntl_t)(
int cmd,
avfs_libio_t *iop
);
typedef int (*avfs_filesystem_rmnod_t)(
avfs_filesystem_location_info_t *pathloc /* IN */
);
struct _avfs_filesystem_file_handlers_r {
avfs_filesystem_open_t open_h;
avfs_filesystem_close_t close_h;
avfs_filesystem_read_t read_h;
avfs_filesystem_write_t write_h;
avfs_filesystem_ioctl_t ioctl_h;
avfs_filesystem_lseek_t lseek_h;
avfs_filesystem_fstat_t fstat_h;
avfs_filesystem_fchmod_t fchmod_h;
avfs_filesystem_ftruncate_t ftruncate_h;
avfs_filesystem_fpathconf_t fpathconf_h;
avfs_filesystem_fsync_t fsync_h;
avfs_filesystem_fdatasync_t fdatasync_h;
avfs_filesystem_fcntl_t fcntl_h;
avfs_filesystem_rmnod_t rmnod_h;
};
/*
* File System Operations Table
*/
/*
* XXX
* This routine does not allocate any space and avfs_filesystem_freenode_t
* is not called by the generic after calling this routine.
* ie. node_access does not have to contain valid data when the
* routine returns.
*/
typedef int (*avfs_filesystem_mknod_t)(
const char *path, /* IN */
mode_t mode, /* IN */
dev_t dev, /* IN */
avfs_filesystem_location_info_t *pathloc /* IN/OUT */
);
/*
* avfs_filesystem_freenode_t must be called by the generic after
* calling this routine
*/
typedef int (*avfs_filesystem_evalpath_t)(
const char *pathname, /* IN */
int flags, /* IN */
avfs_filesystem_location_info_t *pathloc /* IN/OUT */
);
typedef int (*avfs_filesystem_evalmake_t)(
const char *path, /* IN */
avfs_filesystem_location_info_t *pathloc, /* IN/OUT */
const char **name /* OUT */
);
typedef int (*avfs_filesystem_link_t)(
avfs_filesystem_location_info_t *to_loc, /* IN */
avfs_filesystem_location_info_t *parent_loc, /* IN */
const char *name /* IN */
);
typedef int (*avfs_filesystem_unlink_t)(
avfs_filesystem_location_info_t *pathloc /* IN */
);
typedef int (*avfs_filesystem_chown_t)(
avfs_filesystem_location_info_t *pathloc, /* IN */
uid_t owner, /* IN */
gid_t group /* IN */
);
typedef int (*avfs_filesystem_freenode_t)(
avfs_filesystem_location_info_t *pathloc /* IN */
);
typedef int (* avfs_filesystem_mount_t ) (
avfs_filesystem_mount_table_entry_t *mt_entry /* in */
);
typedef int (* avfs_filesystem_fsmount_me_t )(
avfs_filesystem_mount_table_entry_t *mt_entry
);
typedef int (* avfs_filesystem_unmount_t ) (
avfs_filesystem_mount_table_entry_t *mt_entry /* in */
);
typedef int (* avfs_filesystem_fsunmount_me_t ) (
avfs_filesystem_mount_table_entry_t *mt_entry /* in */
);
typedef avfs_filesystem_node_types_t (* avfs_filesystem_node_type_t) (
avfs_filesystem_location_info_t *pathloc /* in */
);
typedef int (* avfs_filesystem_utime_t)(
avfs_filesystem_location_info_t *pathloc, /* IN */
time_t actime, /* IN */
time_t modtime /* IN */
);
typedef int (*avfs_filesystem_evaluate_link_t)(
avfs_filesystem_location_info_t *pathloc, /* IN/OUT */
int flags /* IN */
);
typedef int (*avfs_filesystem_symlink_t)(
avfs_filesystem_location_info_t *loc, /* IN */
const char *link_name, /* IN */
const char *node_name
);
typedef int (*avfs_filesystem_readlink_t)(
avfs_filesystem_location_info_t *loc, /* IN */
char *buf, /* OUT */
size_t bufsize
);
/*
* operations table that must be defined for every file system.
*/
/*
* File system types
*/
struct _avfs_filesystem_operations_table {
avfs_filesystem_evalpath_t evalpath_h;
avfs_filesystem_evalmake_t evalformake_h;
avfs_filesystem_link_t link_h;
avfs_filesystem_unlink_t unlink_h;
avfs_filesystem_node_type_t node_type_h;
avfs_filesystem_mknod_t mknod_h;
avfs_filesystem_chown_t chown_h;
avfs_filesystem_freenode_t freenod_h;
avfs_filesystem_mount_t mount_h;
avfs_filesystem_fsmount_me_t fsmount_me_h;
avfs_filesystem_unmount_t unmount_h;
avfs_filesystem_fsunmount_me_t fsunmount_me_h;
avfs_filesystem_utime_t utime_h;
avfs_filesystem_evaluate_link_t eval_link_h;
avfs_filesystem_symlink_t symlink_h;
avfs_filesystem_readlink_t readlink_h;
};
#if 0
/* Now in exec/include/avfs/fs.h */
/*
* Structure used to determine a location/filesystem in the tree.
*/
struct avfs_filesystem_location_info_tt
{
void *node_access;
avfs_filesystem_file_handlers_r *handlers;
avfs_filesystem_operations_table *ops;
avfs_filesystem_mount_table_entry_t *mt_entry;
};
#endif
/*
* Structure used to contain file system specific information which
* is required to support fpathconf().
*/
typedef struct {
int link_max;
int max_canon;
int max_input;
int name_max;
int path_max;
int pipe_buf;
int posix_async_io;
int posix_chown_restrictions;
int posix_no_trunc;
int posix_prio_io;
int posix_sync_io;
int posix_vdisable;
} avfs_filesystem_limits_and_options_t;
/*
* Structure for a mount table entry.
*/
struct avfs_filesystem_mount_table_entry_tt {
Chain_Node Node;
avfs_filesystem_location_info_t mt_point_node;
avfs_filesystem_location_info_t mt_fs_root;
int options;
void *fs_info;
avfs_filesystem_limits_and_options_t pathconf_limits_and_options;
/*
* When someone adds a mounted filesystem on a real device,
* this will need to be used.
*
* The best option long term for this is probably an open file descriptor.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?