4 * Copyright (C) 1991, 1992 Linus Torvalds
6 * proc base directory handling functions
8 * 1999, Al Viro. Rewritten. Now it covers the whole per-process part.
9 * Instead of using magical inumbers to determine the kind of object
10 * we allocate and fill in-core inodes upon lookup. They don't even
11 * go into icache. We cache the reference to task_struct upon lookup too.
12 * Eventually it should become a filesystem in its own. We don't use the
13 * rest of procfs anymore.
16 #include <asm/uaccess.h>
18 #include <linux/config.h>
19 #include <linux/errno.h>
20 #include <linux/sched.h>
21 #include <linux/proc_fs.h>
22 #include <linux/stat.h>
23 #include <linux/init.h>
24 #include <linux/file.h>
25 #include <linux/string.h>
28 * For hysterical raisins we keep the same inumbers as in the old procfs.
29 * Feel free to change the macro below - just keep the range distinct from
30 * inumbers of the rest of procfs (currently those are in 0x0000--0xffff).
31 * As soon as we'll get a separate superblock we will be able to forget
32 * about magical ranges too.
35 #define fake_ino(pid,ino) (((pid)<<16)|(ino))
37 ssize_t
proc_pid_read_maps(struct task_struct
*,struct file
*,char*,size_t,loff_t
*);
38 int proc_pid_stat(struct task_struct
*,char*);
39 int proc_pid_status(struct task_struct
*,char*);
40 int proc_pid_statm(struct task_struct
*,char*);
41 int proc_pid_cpu(struct task_struct
*,char*);
43 /* MOUNT_REWRITE: make all files have non-NULL ->f_vfsmnt (pipefs, sockfs) */
45 #define NULL_VFSMNT /* remove as soon as pipefs and sockfs will be there */
47 static int proc_fd_link(struct inode
*inode
, struct dentry
**dentry
, struct vfsmount
**mnt
)
49 if (inode
->u
.proc_i
.file
) {
51 if (!inode
->u
.proc_i
.file
->f_vfsmnt
)
55 *mnt
= mntget(inode
->u
.proc_i
.file
->f_vfsmnt
);
56 *dentry
= dget(inode
->u
.proc_i
.file
->f_dentry
);
62 static int proc_exe_link(struct inode
*inode
, struct dentry
**dentry
, struct vfsmount
**mnt
)
64 struct mm_struct
* mm
;
65 struct vm_area_struct
* vma
;
67 struct task_struct
*task
= inode
->u
.proc_i
.task
;
72 atomic_inc(&mm
->mm_users
);
79 if ((vma
->vm_flags
& VM_EXECUTABLE
) &&
81 *mnt
= mntget(vma
->vm_file
->f_vfsmnt
);
82 *dentry
= dget(vma
->vm_file
->f_dentry
);
94 static int proc_cwd_link(struct inode
*inode
, struct dentry
**dentry
, struct vfsmount
**mnt
)
98 task_lock(inode
->u
.proc_i
.task
);
99 fs
= inode
->u
.proc_i
.task
->fs
;
101 atomic_inc(&fs
->count
);
102 task_unlock(inode
->u
.proc_i
.task
);
104 *mnt
= mntget(fs
->pwdmnt
);
105 *dentry
= dget(fs
->pwd
);
112 static int proc_root_link(struct inode
*inode
, struct dentry
**dentry
, struct vfsmount
**mnt
)
114 struct fs_struct
*fs
;
115 int result
= -ENOENT
;
116 task_lock(inode
->u
.proc_i
.task
);
117 fs
= inode
->u
.proc_i
.task
->fs
;
119 atomic_inc(&fs
->count
);
120 task_unlock(inode
->u
.proc_i
.task
);
122 *mnt
= mntget(fs
->rootmnt
);
123 *dentry
= dget(fs
->root
);
130 static int proc_pid_environ(struct task_struct
*task
, char * buffer
)
132 struct mm_struct
*mm
;
137 atomic_inc(&mm
->mm_users
);
140 int len
= mm
->env_end
- mm
->env_start
;
143 res
= access_process_vm(task
, mm
->env_start
, buffer
, len
, 0);
149 static int proc_pid_cmdline(struct task_struct
*task
, char * buffer
)
151 struct mm_struct
*mm
;
156 atomic_inc(&mm
->mm_users
);
159 int len
= mm
->arg_end
- mm
->arg_start
;
162 res
= access_process_vm(task
, mm
->arg_start
, buffer
, len
, 0);
168 /************************************************************************/
169 /* Here the fs part begins */
170 /************************************************************************/
172 /* permission checks */
174 static int standard_permission(struct inode
*inode
, int mask
)
176 int mode
= inode
->i_mode
;
178 if ((mask
& S_IWOTH
) && IS_RDONLY(inode
) &&
179 (S_ISREG(mode
) || S_ISDIR(mode
) || S_ISLNK(mode
)))
180 return -EROFS
; /* Nobody gets write access to a read-only fs */
181 else if ((mask
& S_IWOTH
) && IS_IMMUTABLE(inode
))
182 return -EACCES
; /* Nobody gets write access to an immutable file */
183 else if (current
->fsuid
== inode
->i_uid
)
185 else if (in_group_p(inode
->i_gid
))
187 if (((mode
& mask
& S_IRWXO
) == mask
) || capable(CAP_DAC_OVERRIDE
))
189 /* read and search access */
190 if ((mask
== S_IROTH
) ||
191 (S_ISDIR(mode
) && !(mask
& ~(S_IROTH
| S_IXOTH
))))
192 if (capable(CAP_DAC_READ_SEARCH
))
197 static int proc_permission(struct inode
*inode
, int mask
)
199 struct dentry
*de
, *base
, *root
;
200 struct vfsmount
*our_vfsmnt
, *vfsmnt
, *mnt
;
202 if (standard_permission(inode
, mask
) != 0)
205 base
= current
->fs
->root
;
206 our_vfsmnt
= current
->fs
->rootmnt
;
207 if (proc_root_link(inode
, &root
, &vfsmnt
)) /* Ewww... */
213 while (vfsmnt
!= our_vfsmnt
) {
214 if (vfsmnt
== vfsmnt
->mnt_parent
)
216 de
= vfsmnt
->mnt_mountpoint
;
217 vfsmnt
= vfsmnt
->mnt_parent
;
220 if (!is_subdir(de
, base
))
232 static ssize_t
pid_maps_read(struct file
* file
, char * buf
,
233 size_t count
, loff_t
*ppos
)
235 struct inode
* inode
= file
->f_dentry
->d_inode
;
236 struct task_struct
*task
= inode
->u
.proc_i
.task
;
239 res
= proc_pid_read_maps(task
, file
, buf
, count
, ppos
);
243 static struct file_operations proc_maps_operations
= {
247 #define PROC_BLOCK_SIZE (3*1024) /* 4K page size but our output routines use some slack for overruns */
249 static ssize_t
proc_info_read(struct file
* file
, char * buf
,
250 size_t count
, loff_t
*ppos
)
252 struct inode
* inode
= file
->f_dentry
->d_inode
;
256 struct task_struct
*task
= inode
->u
.proc_i
.task
;
258 if (count
> PROC_BLOCK_SIZE
)
259 count
= PROC_BLOCK_SIZE
;
260 if (!(page
= __get_free_page(GFP_KERNEL
)))
263 length
= inode
->u
.proc_i
.op
.proc_read(task
, (char*)page
);
269 /* Static 4kB (or whatever) block capacity */
270 if (*ppos
>= length
) {
274 if (count
+ *ppos
> length
)
275 count
= length
- *ppos
;
277 copy_to_user(buf
, (char *) page
+ *ppos
, count
);
283 static struct file_operations proc_info_file_operations
= {
284 read
: proc_info_read
,
287 #define MAY_PTRACE(p) \
288 (p==current||(p->p_pptr==current&&(p->flags&PF_PTRACED)&&p->state==TASK_STOPPED))
290 static ssize_t
mem_read(struct file
* file
, char * buf
,
291 size_t count
, loff_t
*ppos
)
293 struct task_struct
*task
= file
->f_dentry
->d_inode
->u
.proc_i
.task
;
295 unsigned long src
= *ppos
;
298 if (!MAY_PTRACE(task
))
301 page
= (char *)__get_free_page(GFP_USER
);
306 int this_len
, retval
;
308 this_len
= (count
> PAGE_SIZE
) ? PAGE_SIZE
: count
;
309 retval
= access_process_vm(task
, src
, page
, this_len
, 0);
315 if (copy_to_user(buf
, page
, retval
)) {
325 free_page((unsigned long) page
);
329 static ssize_t
mem_write(struct file
* file
, const char * buf
,
330 size_t count
, loff_t
*ppos
)
334 struct task_struct
*task
= file
->f_dentry
->d_inode
->u
.proc_i
.task
;
335 unsigned long dst
= *ppos
;
337 if (!MAY_PTRACE(task
))
340 page
= (char *)__get_free_page(GFP_USER
);
345 int this_len
, retval
;
347 this_len
= (count
> PAGE_SIZE
) ? PAGE_SIZE
: count
;
348 if (copy_from_user(page
, buf
, this_len
)) {
352 retval
= access_process_vm(task
, dst
, page
, this_len
, 1);
364 free_page((unsigned long) page
);
368 static struct file_operations proc_mem_operations
= {
373 static struct inode_operations proc_mem_inode_operations
= {
374 permission
: proc_permission
,
377 static int proc_pid_follow_link(struct dentry
*dentry
, struct nameidata
*nd
)
379 struct inode
*inode
= dentry
->d_inode
;
382 struct vfsmount
*dummy
= mntget(nd
->mnt
);
385 /* We don't need a base pointer in the /proc filesystem */
388 error
= proc_permission(inode
, MAY_EXEC
);
392 error
= inode
->u
.proc_i
.op
.proc_get_link(inode
, &nd
->dentry
, &nd
->mnt
);
400 static int do_proc_readlink(struct dentry
*dentry
, struct vfsmount
*mnt
,
401 char * buffer
, int buflen
)
403 struct inode
* inode
;
404 char * tmp
= (char*)__get_free_page(GFP_KERNEL
), *path
, *pattern
;
410 /* Check for special dentries.. */
412 inode
= dentry
->d_inode
;
413 if (inode
&& IS_ROOT(dentry
)) {
414 if (S_ISSOCK(inode
->i_mode
))
415 pattern
= "socket:[%lu]";
416 if (S_ISFIFO(inode
->i_mode
))
417 pattern
= "pipe:[%lu]";
421 len
= sprintf(tmp
, pattern
, inode
->i_ino
);
424 path
= d_path(dentry
, mnt
, tmp
, PAGE_SIZE
);
425 len
= tmp
+ PAGE_SIZE
- 1 - path
;
430 copy_to_user(buffer
, path
, buflen
);
431 free_page((unsigned long)tmp
);
435 static int proc_pid_readlink(struct dentry
* dentry
, char * buffer
, int buflen
)
438 struct inode
*inode
= dentry
->d_inode
;
440 struct vfsmount
*mnt
= NULL
;
442 error
= proc_permission(inode
, MAY_EXEC
);
446 error
= inode
->u
.proc_i
.op
.proc_get_link(inode
, &de
, &mnt
);
450 error
= do_proc_readlink(de
, mnt
, buffer
, buflen
);
457 static struct inode_operations proc_pid_link_inode_operations
= {
458 readlink
: proc_pid_readlink
,
459 follow_link
: proc_pid_follow_link
469 enum pid_directory_inos
{
483 PROC_PID_FD_DIR
= 0x8000, /* 0x8000-0xffff */
486 #define E(type,name,mode) {(type),sizeof(name)-1,(name),(mode)}
487 static struct pid_entry base_stuff
[] = {
488 E(PROC_PID_FD
, "fd", S_IFDIR
|S_IRUSR
|S_IXUSR
),
489 E(PROC_PID_ENVIRON
, "environ", S_IFREG
|S_IRUSR
),
490 E(PROC_PID_STATUS
, "status", S_IFREG
|S_IRUGO
),
491 E(PROC_PID_CMDLINE
, "cmdline", S_IFREG
|S_IRUGO
),
492 E(PROC_PID_STAT
, "stat", S_IFREG
|S_IRUGO
),
493 E(PROC_PID_STATM
, "statm", S_IFREG
|S_IRUGO
),
495 E(PROC_PID_CPU
, "cpu", S_IFREG
|S_IRUGO
),
497 E(PROC_PID_MAPS
, "maps", S_IFREG
|S_IRUGO
),
498 E(PROC_PID_MEM
, "mem", S_IFREG
|S_IRUSR
|S_IWUSR
),
499 E(PROC_PID_CWD
, "cwd", S_IFLNK
|S_IRWXUGO
),
500 E(PROC_PID_ROOT
, "root", S_IFLNK
|S_IRWXUGO
),
501 E(PROC_PID_EXE
, "exe", S_IFLNK
|S_IRWXUGO
),
508 static int proc_readfd(struct file
* filp
, void * dirent
, filldir_t filldir
)
510 struct inode
*inode
= filp
->f_dentry
->d_inode
;
511 struct task_struct
*p
= inode
->u
.proc_i
.task
;
512 unsigned int fd
, pid
, ino
;
515 struct files_struct
* files
;
523 if (filldir(dirent
, ".", 1, 0, inode
->i_ino
) < 0)
527 ino
= fake_ino(pid
, PROC_PID_INO
);
528 if (filldir(dirent
, "..", 2, 1, ino
) < 0)
535 atomic_inc(&files
->count
);
539 for (fd
= filp
->f_pos
-2;
541 fd
++, filp
->f_pos
++) {
544 if (!fcheck_files(files
, fd
))
551 buf
[j
] = '0' + (i
% 10);
555 ino
= fake_ino(pid
, PROC_PID_FD_DIR
+ fd
);
556 if (filldir(dirent
, buf
+j
, NUMBUF
-j
, fd
+2, ino
) < 0)
559 put_files_struct(files
);
565 static int proc_base_readdir(struct file
* filp
,
566 void * dirent
, filldir_t filldir
)
570 struct inode
*inode
= filp
->f_dentry
->d_inode
;
573 pid
= inode
->u
.proc_i
.task
->pid
;
574 if (!inode
->u
.proc_i
.task
->p_pptr
)
579 if (filldir(dirent
, ".", 1, i
, inode
->i_ino
) < 0)
585 if (filldir(dirent
, "..", 2, i
, PROC_ROOT_INO
) < 0)
592 if (i
>=sizeof(base_stuff
)/sizeof(base_stuff
[0]))
596 if (filldir(dirent
, p
->name
, p
->len
, filp
->f_pos
, fake_ino(pid
, p
->type
)) < 0)
605 /* building an inode */
607 static struct inode
*proc_pid_make_inode(struct super_block
* sb
, struct task_struct
*task
, int ino
)
609 struct inode
* inode
;
611 /* We need a new inode */
613 inode
= get_empty_inode();
620 inode
->i_dev
= sb
->s_dev
;
621 inode
->i_mtime
= inode
->i_atime
= inode
->i_ctime
= CURRENT_TIME
;
622 inode
->i_ino
= fake_ino(task
->pid
, ino
);
624 inode
->u
.proc_i
.file
= NULL
;
626 * grab the reference to task.
628 inode
->u
.proc_i
.task
= task
;
629 get_task_struct(task
);
635 if (ino
== PROC_PID_INO
|| task
->dumpable
) {
636 inode
->i_uid
= task
->euid
;
637 inode
->i_gid
= task
->egid
;
650 static int pid_fd_revalidate(struct dentry
* dentry
, int flags
)
656 * Exceptional case: normally we are not allowed to unhash a busy
657 * directory. In this case, however, we can do it - no aliasing problems
658 * due to the way we treat inodes.
660 static int pid_base_revalidate(struct dentry
* dentry
, int flags
)
662 if (dentry
->d_inode
->u
.proc_i
.task
->p_pptr
)
668 static int pid_delete_dentry(struct dentry
* dentry
)
673 static struct dentry_operations pid_fd_dentry_operations
=
675 d_revalidate
: pid_fd_revalidate
,
676 d_delete
: pid_delete_dentry
,
679 static struct dentry_operations pid_dentry_operations
=
681 d_delete
: pid_delete_dentry
,
684 static struct dentry_operations pid_base_dentry_operations
=
686 d_revalidate
: pid_base_revalidate
,
687 d_delete
: pid_delete_dentry
,
692 static struct dentry
*proc_lookupfd(struct inode
* dir
, struct dentry
* dentry
)
695 struct task_struct
*task
= dir
->u
.proc_i
.task
;
697 struct files_struct
* files
;
703 len
= dentry
->d_name
.len
;
704 name
= dentry
->d_name
.name
;
705 if (len
> 1 && *name
== '0') goto out
;
717 inode
= proc_pid_make_inode(dir
->i_sb
, task
, PROC_PID_FD_DIR
+fd
);
723 atomic_inc(&files
->count
);
727 read_lock(&files
->file_lock
);
728 file
= inode
->u
.proc_i
.file
= fcheck_files(files
, fd
);
732 read_unlock(&files
->file_lock
);
733 put_files_struct(files
);
734 inode
->i_op
= &proc_pid_link_inode_operations
;
736 inode
->i_mode
= S_IFLNK
;
737 inode
->u
.proc_i
.op
.proc_get_link
= proc_fd_link
;
738 if (file
->f_mode
& 1)
739 inode
->i_mode
|= S_IRUSR
| S_IXUSR
;
740 if (file
->f_mode
& 2)
741 inode
->i_mode
|= S_IWUSR
| S_IXUSR
;
742 dentry
->d_op
= &pid_fd_dentry_operations
;
743 d_add(dentry
, inode
);
747 put_files_struct(files
);
748 read_unlock(&files
->file_lock
);
752 return ERR_PTR(-ENOENT
);
755 static struct file_operations proc_fd_operations
= {
756 read
: generic_read_dir
,
757 readdir
: proc_readfd
,
761 * proc directories can do almost nothing..
763 static struct inode_operations proc_fd_inode_operations
= {
764 lookup
: proc_lookupfd
,
765 permission
: proc_permission
,
768 static struct dentry
*proc_base_lookup(struct inode
*dir
, struct dentry
*dentry
)
772 struct task_struct
*task
= dir
->u
.proc_i
.task
;
778 for (p
= base_stuff
; p
->name
; p
++) {
779 if (p
->len
!= dentry
->d_name
.len
)
781 if (!memcmp(dentry
->d_name
.name
, p
->name
, p
->len
))
788 inode
= proc_pid_make_inode(dir
->i_sb
, task
, p
->type
);
792 inode
->i_mode
= p
->mode
;
794 * Yes, it does not scale. And it should not. Don't add
795 * new entries into /proc/<pid>/ without very good reasons.
800 inode
->i_op
= &proc_fd_inode_operations
;
801 inode
->i_fop
= &proc_fd_operations
;
804 inode
->i_op
= &proc_pid_link_inode_operations
;
805 inode
->u
.proc_i
.op
.proc_get_link
= proc_exe_link
;
808 inode
->i_op
= &proc_pid_link_inode_operations
;
809 inode
->u
.proc_i
.op
.proc_get_link
= proc_cwd_link
;
812 inode
->i_op
= &proc_pid_link_inode_operations
;
813 inode
->u
.proc_i
.op
.proc_get_link
= proc_root_link
;
815 case PROC_PID_ENVIRON
:
816 inode
->i_fop
= &proc_info_file_operations
;
817 inode
->u
.proc_i
.op
.proc_read
= proc_pid_environ
;
819 case PROC_PID_STATUS
:
820 inode
->i_fop
= &proc_info_file_operations
;
821 inode
->u
.proc_i
.op
.proc_read
= proc_pid_status
;
824 inode
->i_fop
= &proc_info_file_operations
;
825 inode
->u
.proc_i
.op
.proc_read
= proc_pid_stat
;
827 case PROC_PID_CMDLINE
:
828 inode
->i_fop
= &proc_info_file_operations
;
829 inode
->u
.proc_i
.op
.proc_read
= proc_pid_cmdline
;
832 inode
->i_fop
= &proc_info_file_operations
;
833 inode
->u
.proc_i
.op
.proc_read
= proc_pid_statm
;
836 inode
->i_fop
= &proc_maps_operations
;
840 inode
->i_fop
= &proc_info_file_operations
;
841 inode
->u
.proc_i
.op
.proc_read
= proc_pid_cpu
;
845 inode
->i_op
= &proc_mem_inode_operations
;
846 inode
->i_fop
= &proc_mem_operations
;
849 printk("procfs: impossible type (%d)",p
->type
);
851 return ERR_PTR(-EINVAL
);
853 dentry
->d_op
= &pid_dentry_operations
;
854 d_add(dentry
, inode
);
858 return ERR_PTR(error
);
861 static struct file_operations proc_base_operations
= {
862 read
: generic_read_dir
,
863 readdir
: proc_base_readdir
,
866 static struct inode_operations proc_base_inode_operations
= {
867 lookup
: proc_base_lookup
,
873 static int proc_self_readlink(struct dentry
*dentry
, char *buffer
, int buflen
)
876 sprintf(tmp
, "%d", current
->pid
);
877 return vfs_readlink(dentry
,buffer
,buflen
,tmp
);
880 static int proc_self_follow_link(struct dentry
*dentry
, struct nameidata
*nd
)
883 sprintf(tmp
, "%d", current
->pid
);
884 return vfs_follow_link(nd
,tmp
);
887 static struct inode_operations proc_self_inode_operations
= {
888 readlink
: proc_self_readlink
,
889 follow_link
: proc_self_follow_link
,
892 struct dentry
*proc_pid_lookup(struct inode
*dir
, struct dentry
* dentry
)
895 struct task_struct
*task
;
901 name
= dentry
->d_name
.name
;
902 len
= dentry
->d_name
.len
;
903 if (len
== 4 && !memcmp(name
, "self", 4)) {
904 inode
= get_empty_inode();
906 return ERR_PTR(-ENOMEM
);
907 inode
->i_sb
= dir
->i_sb
;
908 inode
->i_dev
= dir
->i_sb
->s_dev
;
909 inode
->i_mtime
= inode
->i_atime
= inode
->i_ctime
= CURRENT_TIME
;
910 inode
->i_ino
= fake_ino(0, PROC_PID_INO
);
911 inode
->u
.proc_i
.file
= NULL
;
912 inode
->u
.proc_i
.task
= NULL
;
913 inode
->i_mode
= S_IFLNK
|S_IRWXUGO
;
914 inode
->i_uid
= inode
->i_gid
= 0;
916 inode
->i_op
= &proc_self_inode_operations
;
917 d_add(dentry
, inode
);
929 if (pid
& 0xffff0000)
933 read_lock(&tasklist_lock
);
934 task
= find_task_by_pid(pid
);
936 get_task_struct(task
);
937 read_unlock(&tasklist_lock
);
941 inode
= proc_pid_make_inode(dir
->i_sb
, task
, PROC_PID_INO
);
943 free_task_struct(task
);
947 inode
->i_mode
= S_IFDIR
|S_IRUGO
|S_IXUGO
;
948 inode
->i_op
= &proc_base_inode_operations
;
949 inode
->i_fop
= &proc_base_operations
;
951 inode
->i_flags
|=S_IMMUTABLE
;
953 dentry
->d_op
= &pid_base_dentry_operations
;
954 d_add(dentry
, inode
);
957 return ERR_PTR(-ENOENT
);
960 void proc_pid_delete_inode(struct inode
*inode
)
962 if (inode
->u
.proc_i
.file
)
963 fput(inode
->u
.proc_i
.file
);
964 if (inode
->u
.proc_i
.task
)
965 free_task_struct(inode
->u
.proc_i
.task
);
968 #define PROC_NUMBUF 10
969 #define PROC_MAXPIDS 20
972 * Get a few pid's to return for filldir - we need to hold the
973 * tasklist lock while doing this, and we must release it before
974 * we actually do the filldir itself, so we use a temp buffer..
976 static int get_pid_list(int index
, unsigned int *pids
)
978 struct task_struct
*p
;
982 read_lock(&tasklist_lock
);
991 if (nr_pids
>= PROC_MAXPIDS
)
994 read_unlock(&tasklist_lock
);
998 int proc_pid_readdir(struct file
* filp
, void * dirent
, filldir_t filldir
)
1000 unsigned int pid_array
[PROC_MAXPIDS
];
1001 char buf
[PROC_NUMBUF
];
1002 unsigned int nr
= filp
->f_pos
- FIRST_PROCESS_ENTRY
;
1003 unsigned int nr_pids
, i
;
1006 ino_t ino
= fake_ino(0,PROC_PID_INO
);
1007 if (filldir(dirent
, "self", 4, filp
->f_pos
, ino
) < 0)
1013 nr_pids
= get_pid_list(nr
, pid_array
);
1015 for (i
= 0; i
< nr_pids
; i
++) {
1016 int pid
= pid_array
[i
];
1017 ino_t ino
= fake_ino(pid
,PROC_PID_INO
);
1018 unsigned long j
= PROC_NUMBUF
;
1020 do buf
[--j
] = '0' + (pid
% 10); while (pid
/=10);
1022 if (filldir(dirent
, buf
+j
, PROC_NUMBUF
-j
, filp
->f_pos
, ino
) < 0)