TuyaOS
结构体 | 宏定义 | 类型定义 | 枚举 | 函数
tkl_storage.h 文件参考

Common process - storage: sdCard U-Disk HDD SSD etc. 更多...

#include "tuya_cloud_types.h"
tkl_storage.h 的引用(Include)关系图:

浏览源代码.

结构体

struct  TKL_STORAGE_EVENT_MSG
 

宏定义

#define BUSTP_SATA   "sata"
 
#define BUSTP_SDIO   "sdcard"
 
#define BUSTP_USB   "usb"
 
#define DEVICE_HOTPLUG_ADD   1
 
#define DEVICE_HOTPLUG_DEL   0
 
#define FSTP_EXT34   "ext4"
 
#define FSTP_FAT32   "vfat"
 
#define FSTP_XFS   "xfs"
 
#define MAX_DEVICE_NUM   10
 
#define MAX_FSTP_LEN   16
 
#define MAX_PART_NUM   10
 
#define MAX_PATH_LEN   256
 
#define PART_ADD   1
 
#define PART_DEL   2
 

类型定义

typedef VOID(* TKL_STORAGE_BADBLK_CB) (ULONG_T blk_idx, VOID *user_ctx)
 
typedef VOID(* TKL_STORAGE_EVENT_CB) (TKL_STORAGE_EVENT_MSG *msg, VOID *user_ctx)
 
typedef VOID(* TKL_STORAGE_PROGRESS_CB) (INT_T progress, VOID *user_ctx)
 

枚举

enum  TKL_STORAGE_EVT_MSGTP { EVT_HOTPLUG , EVT_FS_ERR }
 

函数

OPERATE_RET tkl_storage_check_badblocks (CHAR_T *dev_name, TKL_STORAGE_BADBLK_CB cb, VOID *user_ctx)
 check bad blocks 更多...
 
OPERATE_RET tkl_storage_df (CHAR_T *mount_point, TKL_STORAGE_DF_T *df)
 report filesystem disk space usage 更多...
 
OPERATE_RET tkl_storage_fsck (CHAR_T *blk_dev, CHAR_T *fs_type, CHAR_T *parm, INT_T flags, TKL_STORAGE_PROGRESS_CB cb, VOID *user_ctx)
 check and repair a filesystem 更多...
 
OPERATE_RET tkl_storage_get_device_info (CHAR_T *dev_name, TKL_STORAGE_DEVICE_INFO_T *list)
 get one device info 更多...
 
OPERATE_RET tkl_storage_get_device_list (TKL_STORAGE_DEVICE_INFO_T *list, INT_T num)
 get block device list 更多...
 
OPERATE_RET tkl_storage_get_internal_dir (CHAR_T path[256])
 get internal r/w dir 更多...
 
OPERATE_RET tkl_storage_get_part_list (CHAR_T *dev_name, TKL_STORAGE_PART_INFO_T *list, INT_T num)
 get partition info 更多...
 
OPERATE_RET tkl_storage_ioctl (CHAR_T *dev_name, ULONG_T request, VOID *args)
 scsi generic ioctl 更多...
 
OPERATE_RET tkl_storage_loop_event (TKL_STORAGE_EVENT_CB event_cb, VOID *user_ctx)
 loop storage event, eg. hotplug will not return except an error occured. 更多...
 
OPERATE_RET tkl_storage_make_part (CHAR_T *part_name, CHAR_T *part_type, CHAR_T *fs_type, BOOL_T isadd, UINT_T part_index, LONG_T start, LONG_T end)
 make partition. refer to parted/fdisk 更多...
 
OPERATE_RET tkl_storage_mkfs (CHAR_T *fs_type, CHAR_T *fs_dev, CHAR_T *parm, TKL_STORAGE_PROGRESS_CB cb, VOID *user_ctx)
 partiton format, build filesystem 更多...
 
OPERATE_RET tkl_storage_mount (CHAR_T *source, CHAR_T *target, CHAR_T *fs_type, ULONG_T flags, VOID *data)
 mount a filesystem partition. refer to mount system call 更多...
 
OPERATE_RET tkl_storage_umount (CHAR_T *target, INT_T flags)
 umount a filesystem partition. refer to umount system call 更多...
 

详细描述

Common process - storage: sdCard U-Disk HDD SSD etc.

版本
0.1
日期
2021-08-31

函数说明

◆ tkl_storage_check_badblocks()

OPERATE_RET tkl_storage_check_badblocks ( CHAR_T *  dev_name,
TKL_STORAGE_BADBLK_CB  cb,
VOID *  user_ctx 
)

check bad blocks

参数
dev_namedevice node name
cbcallback to report bad blocks
user_ctxcaller's private context, optional
返回
OPERATE_RET 0 on success. A negative error code on error.

◆ tkl_storage_df()

OPERATE_RET tkl_storage_df ( CHAR_T *  mount_point,
TKL_STORAGE_DF_T df 
)

report filesystem disk space usage

参数
mount_pathmount point
dffs state loaded on success
返回
OPERATE_RET 0 on success. A negative error code on error.

◆ tkl_storage_fsck()

OPERATE_RET tkl_storage_fsck ( CHAR_T *  blk_dev,
CHAR_T *  fs_type,
CHAR_T *  parm,
INT_T  flags,
TKL_STORAGE_PROGRESS_CB  cb,
VOID *  user_ctx 
)

check and repair a filesystem

参数
blk_devdevice node
fs_typefilesystem type
parmfsck parame, eg. fsck.vfat -f /dev/sda1
flagsreserved flags
cbprogress callback, optional
user_ctxcaller's private context, optional
返回
OPERATE_RET 0 on success. A negative error code on error.

◆ tkl_storage_get_device_info()

OPERATE_RET tkl_storage_get_device_info ( CHAR_T *  dev_name,
TKL_STORAGE_DEVICE_INFO_T list 
)

get one device info

参数
listdevice list loaded on success
返回
OPERATE_RET return list number on success. A negative error code on error.

◆ tkl_storage_get_device_list()

OPERATE_RET tkl_storage_get_device_list ( TKL_STORAGE_DEVICE_INFO_T list,
INT_T  num 
)

get block device list

参数
listdevice list loaded on success
numlist number
返回
OPERATE_RET return list number on success. A negative error code on error.

◆ tkl_storage_get_internal_dir()

OPERATE_RET tkl_storage_get_internal_dir ( CHAR_T  path[256])

get internal r/w dir

参数
pathabsolute path returned on success
返回
OPERATE_RET 0 on success. A negative error code on error.

◆ tkl_storage_get_part_list()

OPERATE_RET tkl_storage_get_part_list ( CHAR_T *  dev_name,
TKL_STORAGE_PART_INFO_T list,
INT_T  num 
)

get partition info

参数
dev_namedevice node wanted to list
listpartition list loaded on success
numlist number
返回
OPERATE_RET return list number on success. A negative error code on error.

◆ tkl_storage_ioctl()

OPERATE_RET tkl_storage_ioctl ( CHAR_T *  dev_name,
ULONG_T  request,
VOID *  args 
)

scsi generic ioctl

参数
dev_namedevice node name
requestrequest. TODO: copy scsi header files for request
argsargs
返回
OPERATE_RET 0 on success. A negative error code on error.

◆ tkl_storage_loop_event()

OPERATE_RET tkl_storage_loop_event ( TKL_STORAGE_EVENT_CB  event_cb,
VOID *  user_ctx 
)

loop storage event, eg. hotplug will not return except an error occured.

参数
event_cbcallback handle storage event
user_ctxuser private data, optional
返回
OPERATE_RET 0 on success. A negative error code on error.

◆ tkl_storage_make_part()

OPERATE_RET tkl_storage_make_part ( CHAR_T *  part_name,
CHAR_T *  part_type,
CHAR_T *  fs_type,
BOOL_T  isadd,
UINT_T  part_index,
LONG_T  start,
LONG_T  end 
)

make partition. refer to parted/fdisk

参数
part_namepartition label, optional
part_typepartition type, eg. primary logical extended
fs_typefilesystem type, eg. ext4 xfs, optional
isaddpart is add or delet, 1:add, 2:delete
part_indexmeans part number, eg. primary[1-4] logical [5 or over]
startpartition start position, KB
endpartition end position, KB
返回
OPERATE_RET 0 on success. A negative error code on error.

◆ tkl_storage_mkfs()

OPERATE_RET tkl_storage_mkfs ( CHAR_T *  fs_type,
CHAR_T *  fs_dev,
CHAR_T *  parm,
TKL_STORAGE_PROGRESS_CB  cb,
VOID *  user_ctx 
)

partiton format, build filesystem

参数
fs_typefilesystem type, eg. ext4 fat32
fs_devdevice node, eg. /dev/sda1
parmmkfs parame, eg. mkfs.vfat -F 32 -n "name" /dev/sda1
cbprogress callback, optional
user_ctxcaller's private context, optional
返回
OPERATE_RET 0 on success. A negative error code on error.

◆ tkl_storage_mount()

OPERATE_RET tkl_storage_mount ( CHAR_T *  source,
CHAR_T *  target,
CHAR_T *  fs_type,
ULONG_T  flags,
VOID *  data 
)

mount a filesystem partition. refer to mount system call

参数
sourcedevice node
targetdir wanted mount to
fs_typefilesystem type
flagsfilesystem r/w/a flags, optional
datafilesystem-specific params, optional
返回
OPERATE_RET 0 on success. A negative error code on error.

◆ tkl_storage_umount()

OPERATE_RET tkl_storage_umount ( CHAR_T *  target,
INT_T  flags 
)

umount a filesystem partition. refer to umount system call

参数
targetdir fs mounted
flagsreserved flags
返回
OPERATE_RET 0 on success. A negative error code on error.