更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
stdio.c 文件参考

浏览源代码.

函数

off_t _lseek (int fd, off_t offset, int whence)
 
off64_t _lseek64 (int fd, int offsetHigh, int offsetLow, off64_t *result, int whence)
 

函数说明

◆ _lseek()

off_t _lseek ( int  fd,
off_t  offset,
int  whence 
)

在文件 stdio.c38 行定义.

39{
40 int ret;
41 struct file *filep = NULL;
42
43 /* Get the file structure corresponding to the file descriptor. */
44 ret = fs_getfilep(fd, &filep);
45 if (ret < 0) {
46 /* The errno value has already been set */
47 return (off_t)-get_errno();
48 }
49
50 /* libc seekdir function should set the whence to SEEK_SET, so we can discard
51 * the whence argument here */
52 if (filep->f_oflags & O_DIRECTORY) {
53 /* defensive coding */
54 if (filep->f_dir == NULL) {
55 return (off_t)-EINVAL;
56 }
57 if (offset == 0) {
58 rewinddir(filep->f_dir);
59 } else {
60 seekdir(filep->f_dir, offset);
61 }
62 ret = telldir(filep->f_dir);
63 if (ret < 0) {
64 return (off_t)-get_errno();
65 }
66 return ret;
67 }
68
69 /* Then let file_seek do the real work */
70 ret = file_seek(filep, offset, whence);
71 if (ret < 0) {
72 return -get_errno();
73 }
74 return ret;
75}
int f_oflags
void * f_dir
这是这个函数的调用关系图:

◆ _lseek64()

off64_t _lseek64 ( int  fd,
int  offsetHigh,
int  offsetLow,
off64_t result,
int  whence 
)

在文件 stdio.c77 行定义.

78{
79 off64_t ret;
80 struct file *filep = NULL;
81 off64_t offset = ((off64_t)offsetHigh << 32) + (uint)offsetLow; /* 32: offsetHigh is high 32 bits */
82
83 /* Get the file structure corresponding to the file descriptor. */
84 ret = fs_getfilep(fd, &filep);
85 if (ret < 0) {
86 /* The errno value has already been set */
87 return (off64_t)-get_errno();
88 }
89
90 /* libc seekdir function should set the whence to SEEK_SET, so we can discard
91 * the whence argument here */
92 if (filep->f_oflags & O_DIRECTORY) {
93 /* defensive coding */
94 if (filep->f_dir == NULL) {
95 return (off64_t)-EINVAL;
96 }
97 if (offsetLow == 0) {
98 rewinddir(filep->f_dir);
99 } else {
100 seekdir(filep->f_dir, offsetLow);
101 }
102 ret = telldir(filep->f_dir);
103 if (ret < 0) {
104 return (off64_t)-get_errno();
105 }
106 goto out;
107 }
108
109 /* Then let file_seek do the real work */
110 ret = file_seek64(filep, offset, whence);
111 if (ret < 0) {
112 return (off64_t)-get_errno();
113 }
114
115out:
116 *result = ret;
117
118 return 0;
119}
ARG_NUM_3 ARG_NUM_1 ARG_NUM_2 ARG_NUM_2 ARG_NUM_3 ARG_NUM_1 ARG_NUM_4 ARG_NUM_2 ARG_NUM_2 ARG_NUM_5 ARG_NUM_2 ARG_NUM_0 ARG_NUM_2 ARG_NUM_1 ARG_NUM_2 ARG_NUM_3 ARG_NUM_7 ARG_NUM_2 ARG_NUM_3 ARG_NUM_2 ARG_NUM_4 off64_t
这是这个函数的调用关系图: