Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync from master #6981

Merged
merged 23 commits into from
Feb 25, 2023
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
feed84b
fix rt_kprint 64bit error
zhkag Feb 20, 2023
ff58949
update rtdevice.h add lcd
XYZ-20240101 Feb 18, 2023
aaba21c
[fix]避免字符设备特殊控制指令和通用控制指令冲突
JonasWen Feb 21, 2023
1533b88
[arduino][lpc55s69] : 对接RTduino
Z8MAN8 Feb 22, 2023
b3b8c23
[spi] rt_spi_configure 增加对cs_pin处理
liYony Feb 23, 2023
52cb2f0
[lwIP] apply AF_UNIX feature (#6954)
Guozhanxin Feb 23, 2023
6d4764a
serial_v2 rt_device_write/read return data type as rt_ssize_t
JonasWen Feb 23, 2023
96a636f
[Renesas]Add tft-lcd lvgl support
Rbb666 Feb 22, 2023
08c2a65
[rtduino][lpc55s69] 修正RTduino框架下的引脚错误 (#6963)
kurisaW Feb 23, 2023
382e9bc
[rt-smart] handling kernel from accessing unmapped user stack (#6957)
polarvid Feb 24, 2023
7bf6648
[serial]增加at32的serial_v2驱动
JonasWen Feb 23, 2023
a5c62b9
[bsp/at32] add support usb driver (#6968)
sheltonyu Feb 25, 2023
022760c
[Infineon]Fix scb5 can't use bug
Rbb666 Feb 24, 2023
faddfec
[rtduino][lpc55s69] update (#6972)
Z8MAN8 Feb 25, 2023
7763183
[rtduino][lpc55s69] 纠正uart引脚错误并使能相关依赖项 (#6976)
kurisaW Feb 25, 2023
e50a7e3
🐞 fix(components/drivers/tty/pty.c): fix ptmx not init (#6970)
xqyjlj Feb 25, 2023
4c1c6ef
解决关中断时进行了调度操作
zhkag Feb 24, 2023
d3553e7
fixed fstat/stat/readlink syscall.
geniusgogo Feb 24, 2023
53afeda
fix inet_ioctlsocket set O_LARGEFILE flag by musl.
geniusgogo Feb 24, 2023
a53367a
fixed O_LARGEFILE not defined ci build error.
geniusgogo Feb 25, 2023
fef2607
[lwp] save virtual addr in shm structure
polarvid Feb 25, 2023
12f0df9
[libcpu/aarch64] stop when no page is free
polarvid Feb 25, 2023
e63e33a
[ch32][bsp] fix warning: rt_size_t to rt_ssize_t
linshire Feb 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed fstat/stat/readlink syscall.
  • Loading branch information
geniusgogo authored and Guozhanxin committed Feb 25, 2023
commit d3553e7220fd410b3e2d7635ab5a74ca45436e1d
105 changes: 102 additions & 3 deletions components/lwp/lwp_syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ int sys_fstat(int file, struct stat *buf)
{
#ifdef ARCH_MM_MMU
int ret = -1;
struct stat statbuff;
struct stat statbuff = {0};

if (!lwp_user_accessable((void *)buf, sizeof(struct stat)))
{
Expand Down Expand Up @@ -2575,7 +2575,45 @@ int sys_log(const char* log, int size)
int sys_stat(const char *file, struct stat *buf)
{
int ret = 0;
ret = stat(file, buf);
int err;
size_t len;
size_t copy_len;
char *copy_path;
struct stat statbuff = {0};

if (!lwp_user_accessable((void *)buf, sizeof(struct stat)))
{
return -EFAULT;
}

len = lwp_user_strlen(file, &err);
if (err)
{
return -EFAULT;
}

copy_path = (char*)rt_malloc(len + 1);
if (!copy_path)
{
return -ENOMEM;
}

copy_len = lwp_get_from_user(copy_path, (void*)file, len);
if (copy_len == 0)
{
rt_free(copy_path);
return -EFAULT;
}
copy_path[copy_len] = '\0';

ret = stat(copy_path, &statbuff);
rt_free(copy_path);

if (ret == 0)
{
lwp_put_to_user(buf, &statbuff, sizeof statbuff);
}

return (ret < 0 ? GET_ERRNO() : ret);
}

Expand Down Expand Up @@ -4157,6 +4195,67 @@ int sys_getrandom(void *buf, size_t buflen, unsigned int flags)
#endif
return ret;
}

ssize_t sys_readlink(char* path, char *buf, size_t bufsz)
{
size_t len, copy_len;
int err;
int fd = -1;
struct dfs_fd *d;
char *copy_path;

len = lwp_user_strlen(path, &err);
if (err)
{
return -EFAULT;
}

if (!lwp_user_accessable(buf, bufsz))
{
return -EINVAL;
}

copy_path = (char*)rt_malloc(len + 1);
if (!copy_path)
{
return -ENOMEM;
}

copy_len = lwp_get_from_user(copy_path, path, len);
copy_path[copy_len] = '\0';

/* musl __procfdname */
err = sscanf(copy_path, "/proc/self/fd/%d", &fd);
rt_free(copy_path);

if (err != 1)
{
LOG_E("readlink: path not is /proc/self/fd/* , call by musl __procfdname()?");
return -EINVAL;
}

d = fd_get(fd);
if (!d)
{
return -EBADF;
}

if (!d->vnode)
{
return -EBADF;
}

copy_len = strlen(d->vnode->fullpath);
if (copy_len > bufsz)
{
copy_len = bufsz;
}

bufsz = lwp_put_to_user(buf, d->vnode->fullpath, copy_len);

return bufsz;
}

int sys_setaffinity(pid_t pid, size_t size, void *set)
{
if (!lwp_user_accessable(set, sizeof(cpu_set_t)))
Expand Down Expand Up @@ -4672,7 +4771,7 @@ const static void* func_table[] =
SYSCALL_SIGN(sys_setrlimit),
SYSCALL_SIGN(sys_setsid),
SYSCALL_SIGN(sys_getrandom),
SYSCALL_SIGN(sys_notimpl), // SYSCALL_SIGN(sys_readlink) /* 145 */
SYSCALL_SIGN(sys_readlink), // SYSCALL_SIGN(sys_readlink) /* 145 */
SYSCALL_USPACE(SYSCALL_SIGN(sys_mremap)),
SYSCALL_USPACE(SYSCALL_SIGN(sys_madvise)),
SYSCALL_SIGN(sys_sched_setparam),
Expand Down