MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / sys_fchdir

Function sys_fchdir

components/lwp/lwp_syscall.c:7541–7568  ·  view source on GitHub ↗

* @brief Changes the current working directory to the one associated with the specified file descriptor. * * This function changes the current working directory of the calling process * to the directory associated with the file descriptor `fd`. The file descriptor * should refer to an open directory. If the file descriptor does not refer to a * directory, or if the process lacks the necessary

Source from the content-addressed store, hash-verified

7539 * @see sys_chdir(), sys_getcwd(), sys_opendir(), sys_open()
7540 */
7541sysret_t sys_fchdir(int fd)
7542{
7543 int errcode = -ENOSYS;
7544#ifdef ARCH_MM_MMU
7545#ifdef RT_USING_DFS_V2
7546 int err = -1;
7547 struct dfs_file *d;
7548 char *kpath;
7549
7550 d = fd_get(fd);
7551 if (!d || !d->vnode)
7552 {
7553 return -EBADF;
7554 }
7555 kpath = dfs_dentry_full_path(d->dentry);
7556 if (!kpath)
7557 {
7558 return -EACCES;
7559 }
7560
7561 err = chdir(kpath);
7562 errcode = err != 0 ? GET_ERRNO() : 0;
7563
7564 kmem_put(kpath);
7565#endif
7566#endif
7567 return errcode;
7568}
7569
7570/**
7571 * @brief Creates a new directory with the specified path and mode.

Callers

nothing calls this directly

Calls 4

dfs_dentry_full_pathFunction · 0.85
kmem_putFunction · 0.85
fd_getFunction · 0.50
chdirFunction · 0.50

Tested by

no test coverage detected