ADD file via upload

master
pt7yg3sn6 3 years ago
parent 09b5bfedda
commit 477f97e918

@ -0,0 +1,46 @@
#define __LIBRARY__
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <string.h>
#include <asm/segment.h>
#include <linux/sched.h>
#include <linux/kernel.h>
struct linux_dirent {
long d_ino;
off_t d_off;
unsigned short d_reclen;
char d_name[14];
};
int sys_getdents(unsigned int fd, struct linux_dirent *dirp, unsigned int count)
{
struct m_inode *m_ino;
struct buffer_head *buff_hd;
struct dir_entry *dir;
struct linux_dirent usr;
int i, j, res;
i = 0;
res = 0;
m_ino = current->filp[fd]->f_inode;
buff_hd = bread(m_ino->i_dev, m_ino->i_zone[0]);
dir = (struct dir_entry *)buff_hd->b_data;
while (dir[i].inode > 0)
{
if (res + sizeof(struct linux_dirent) > count)
break;
usr.d_ino = dir[i].inode;
usr.d_off = 0;
usr.d_reclen = sizeof(struct linux_dirent);
for (j = 0; j < 14; j++)
{
usr.d_name[j] = dir[i].name[j];
}
for(j = 0;j <sizeof(struct linux_dirent); j++){
put_fs_byte(((char *)(&usr))[j],(char *)dirp + res);
res++;
}
i++;
}
return res;
}
Loading…
Cancel
Save