Find all "regular" files open for write on solaris?

How do I find all "regular" files on solaris(8) that are open for write ( +read as well).

I tried using pfiles, and lsof commands, but not sure how to get exactly what I wanted.

 
ps -e | awk '{ print $1 }' | xargs -i pfiles {} 2>/dev/null
pfiles /proc/* | grep "^ */" | sort -u

I get no output.

part is working fine.
But

part does not return anything.

Can you check it on your end. Also I am not sure what you are trying to do with that second argument,, if you explain I can give it a try.

I have no Solaris 8 to check. My command works fine with Solaris 10 and 11. The grep is extracting filenames from the pfiles output.

Can you post a sample output of

pfiles /proc/*

on Solaris 8 ?

Here is first few lines of output.

$>  pfiles /proc/* 2>/dev/null | more
1194:   -ksh
  Current rlimit: 8192 file descriptors
   0: S_IFCHR mode:0620 dev:85,0 ino:112719 uid:3051 gid:7 rdev:24,3
      O_RDWR|O_LARGEFILE
   1: S_IFCHR mode:0620 dev:85,0 ino:112719 uid:3051 gid:7 rdev:24,3
      O_RDWR|O_LARGEFILE
   2: S_IFCHR mode:0620 dev:85,0 ino:112719 uid:3051 gid:7 rdev:24,3
      O_RDWR|O_LARGEFILE
  63: S_IFREG mode:0600 dev:85,3 ino:236544 uid:3051 gid:3051 size:3064
      O_RDWR|O_APPEND|O_LARGEFILE FD_CLOEXEC
1225:   pfiles /proc/0 /proc/1 /proc/103 /proc/1124 /proc/1125 /proc/1126 /pro
  Current rlimit: 8192 file descriptors
   0: S_IFCHR mode:0620 dev:85,0 ino:112719 uid:3051 gid:7 rdev:24,3
      O_RDWR|O_LARGEFILE
   1: S_IFIFO mode:0000 dev:287,0 ino:14203390 uid:3051 gid:3051 size:0
      O_RDWR
   2: S_IFCHR mode:0666 dev:85,0 ino:112451 uid:0 gid:3 rdev:13,2
      O_WRONLY|O_LARGEFILE
   3: S_IFDIR mode:0500 dev:285,0 ino:8150 uid:3051 gid:3051 size:8208
      O_RDONLY|O_NDELAY|O_LARGEFILE FD_CLOEXEC
1226:   more
  Current rlimit: 8192 file descriptors
   0: S_IFIFO mode:0000 dev:287,0 ino:14203390 uid:3051 gid:3051 size:0
      O_RDWR
   1: S_IFCHR mode:0620 dev:85,0 ino:112719 uid:3051 gid:7 rdev:24,3
      O_RDWR|O_LARGEFILE
   2: S_IFCHR mode:0620 dev:85,0 ino:112719 uid:3051 gid:7 rdev:24,3
      O_RDWR|O_LARGEFILE
13173:  /<process_dir>/<process.exe> <startup_commmand_options>
  Current rlimit: 8192 file descriptors
   0: S_IFCHR mode:0666 dev:85,0 ino:112721 uid:0 gid:0 rdev:24,5
      O_RDWR|O_LARGEFILE
   1: S_IFCHR mode:0666 dev:85,0 ino:112721 uid:0 gid:0 rdev:24,5
      O_RDWR|O_LARGEFILE
   2: S_IFREG mode:0666 dev:85,3 ino:1036466 uid:3051 gid:3068 size:0
      O_RDWR|O_APPEND
   3: S_IFREG mode:0771 dev:85,3 ino:1724623 uid:3051 gid:3051 size:0
      O_RDWR

Well, pfiles started to show the full path with Solaris 10. For older releases, the simpler solution would be to install lsof from sunfreeware.

We do have lsof installed. What do I need to do to get only open files for writing from lsof output ?

lsof -T | grep REG | nawk '$4 ~ /.*[wu]/ { print $9}' | sort -u

That works great. May I know what '10' means in the following output in the second column?

COMMAND     PID     USER   FD   TYPE        DEVICE   SIZE/OFF     NODE NAME
cstd.agt     530     root   10u  VREG        85,2     8184     16254  /var/adm/utmpx

Is there a way that I can get full command used in this output[first column] using any flag[lsof's] that we generally see with '/usr/ucb/ps -auxww'?

File descriptor #10.

I don't think so.

Thanks a lot. This thread now can be closed.