13#define DBG_TAG "DFS.seq"
14#define DBG_LVL DBG_WARNING
26static void *dfs_seq_alloc(
unsigned long size)
43 LOG_W(
"dfs_seq_open: file->data != null\n");
60static int dfs_seq_traverse(
struct dfs_seq_file *seq, off_t offset)
88 if (dfs_seq_is_full(seq))
92 if (pos + seq->
count > offset)
94 seq->
from = offset - pos;
110 seq->
buf = dfs_seq_alloc(seq->
size <<= 1);
111 return !seq->
buf ? -ENOMEM : -EAGAIN;
140 while ((err = dfs_seq_traverse(seq, *pos)) == -EAGAIN)
167 rt_memcpy((
char *)
buf + copied, seq->
buf + seq->
from, n);
190 if (!dfs_seq_is_full(seq))
196 seq->
buf = dfs_seq_alloc(seq->
size <<= 1);
211 size_t offs = seq->
count;
212 off_t pos = seq->
index;
215 if (pos == seq->
index)
217 LOG_W(
".next function %p did not update position index\n", seq->
ops->
next);
229 else if (err || dfs_seq_is_full(seq))
237 rt_memcpy((
char *)
buf + copied, seq->
buf, n);
245 copied = seq->
count ? -EFAULT : err;
262 off_t retval = -EINVAL;
276 while ((retval = dfs_seq_traverse(seq, offset)) == -EAGAIN);
328 dfs_seq_overflow(seq);
360 dfs_seq_overflow(seq);
363 rt_memcpy(seq->
buf + seq->
count, s, len);
378 dfs_seq_overflow(seq);
393 dfs_seq_overflow(seq);
int dfs_seq_release(struct dfs_file *file)
off_t dfs_seq_lseek(struct dfs_file *file, off_t offset, int whence)
void dfs_seq_pad(struct dfs_seq_file *seq, char c)
void dfs_seq_putc(struct dfs_seq_file *seq, char c)
void dfs_seq_puts(struct dfs_seq_file *seq, const char *s)
void dfs_seq_vprintf(struct dfs_seq_file *seq, const char *f, va_list args)
ssize_t dfs_seq_read(struct dfs_file *file, void *buf, size_t size, off_t *pos)
int dfs_seq_open(struct dfs_file *file, const struct dfs_seq_ops *ops)
int dfs_seq_write(struct dfs_seq_file *seq, const void *data, size_t len)
void dfs_seq_printf(struct dfs_seq_file *seq, const char *f,...)
#define RT_WAITING_FOREVER
rt_weak void * rt_calloc(rt_size_t count, rt_size_t size)
This function will contiguously allocate enough space for count objects that are size bytes of memory...
rt_weak void rt_free(void *ptr)
This function will release the previously allocated memory block by rt_malloc. The released memory bl...
rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time)
rt_err_t rt_mutex_detach(rt_mutex_t mutex)
This function will detach a static mutex object.
rt_err_t rt_mutex_init(rt_mutex_t mutex, const char *name, rt_uint8_t flag)
Initialize a static mutex object.
rt_err_t rt_mutex_release(rt_mutex_t mutex)
This function will release a mutex. If there is thread suspended on the mutex, the thread will be res...
struct dfs_dentry * dentry
const struct dfs_file * file
const struct dfs_seq_ops * ops
int(* show)(struct dfs_seq_file *seq, void *data)
void *(* next)(struct dfs_seq_file *seq, void *data, off_t *index)
void(* stop)(struct dfs_seq_file *seq, void *data)
void *(* start)(struct dfs_seq_file *seq, off_t *index)