0

Linux-0.12 中的 sched.h:

struct task_struct {
/* these are hardcoded - don't touch */
        long state;     /* -1 unrunnable, 0 runnable, >0 stopped */
        long counter;
        long priority;
        long signal;
        struct sigaction sigaction[32];
        long blocked;   /* bitmap of masked signals */
/* various fields */
        int exit_code;
        unsigned long start_code,end_code,end_data,brk,start_stack;
        long pid,pgrp,session,leader;
        int     groups[NGROUPS];
        /* 
         * pointers to parent process, youngest child, younger sibling,
         * older sibling, respectively.  (p->father can be replaced with 
         * p->p_pptr->pid)
         */
        struct task_struct      *p_pptr, *p_cptr, *p_ysptr, *p_osptr;
        unsigned short uid,euid,suid;
        unsigned short gid,egid,sgid;
        unsigned long timeout,alarm;
        long utime,stime,cutime,cstime,start_time;
        struct rlimit rlim[RLIM_NLIMITS];
        unsigned int flags;     /* per process flags, defined below */
        unsigned short used_math;
/* file system info */
        int tty;                /* -1 if no tty, so it must be signed */
        unsigned short umask;
        struct m_inode * pwd;
        struct m_inode * root;
        struct m_inode * executable;
        struct m_inode * library;
        unsigned long close_on_exec;
        struct file * filp[NR_OPEN];
/* ldt for this task 0 - zero 1 - cs 2 - ds&ss */
        struct desc_struct ldt[3];
/* tss for this task */
        struct tss_struct tss;
};

struct m_inode * root和 有什么不同struct m_inode * pwd
谢谢你。

4

3 回答 3

1

cwd是您可以更改的当前工作目录chdir()root是可以更改的根目录chroot()(查找 chroot jail)。

于 2013-05-16T16:50:30.930 回答
1

pwd 是一个 dentry 结构。dentry 是将文件名映射到 inode 编号的东西。pwd 只是您所在的当前目录。root 是根目录,所以我假设它是根目录 /。

http://www.makelinux.net/books/lkd2/ch12lev1sec10

于 2013-05-16T13:46:05.413 回答
1

此类结构中的 pwd 表示当前工作目录,通常与 Linux 中的命令 pwd 不同。

如果你想举个例子,使用 ps 在终端中获取一个正在运行的进程的 pid XXX,然后 cd /proc/XXX/,有该进程的 root 和 cwd(当前工作目录)。

于 2013-05-16T13:52:50.373 回答