Hi All, Is there a simple way to list all currently open file descriptors ? TIA.. Regards, Venkat -- This message posted from opensolaris.org
Venkat C wrote:> Hi All, > > Is there a simple way to list all currently open file descriptors ?# ls -l /proc/*/path :-) - Bart -- Bart Smaalders Solaris Kernel Performance barts at cyber.eng.sun.com http://blogs.sun.com/barts
dtrace -n ''syscall::open*:entry {printf("%s %s %d", execname,copyinstr(arg0),pid);}''>From: Bart Smaalders <bart.smaalders at Sun.COM> >To: Venkat C <venkatesh_ch at yahoo.com> >CC: dtrace-discuss at opensolaris.org >Subject: Re: [dtrace-discuss] all open files >Date: Mon, 09 Jul 2007 17:52:05 -0700 > >Venkat C wrote: > > Hi All, > > > > Is there a simple way to list all currently open file descriptors ? > > ># ls -l /proc/*/path > >:-) > >- Bart > >-- >Bart Smaalders Solaris Kernel Performance >barts at cyber.eng.sun.com http://blogs.sun.com/barts >_______________________________________________ >dtrace-discuss mailing list >dtrace-discuss at opensolaris.org_________________________________________________________________ ??????????????? MSN Hotmail? http://www.hotmail.com
That''ll show you all the open() system calls, but not the currently open files... Zhou Aaron wrote:> dtrace -n ''syscall::open*:entry {printf("%s %s %d", > execname,copyinstr(arg0),pid);}'' > > >> From: Bart Smaalders <bart.smaalders at Sun.COM> >> To: Venkat C <venkatesh_ch at yahoo.com> >> CC: dtrace-discuss at opensolaris.org >> Subject: Re: [dtrace-discuss] all open files >> Date: Mon, 09 Jul 2007 17:52:05 -0700 >> >> Venkat C wrote: >>> Hi All, >>> >>> Is there a simple way to list all currently open file descriptors ? >> >> # ls -l /proc/*/path >> >> :-) >> >> - Bart >> >> -- >> Bart Smaalders Solaris Kernel Performance >> barts at cyber.eng.sun.com http://blogs.sun.com/barts >> _______________________________________________ >> dtrace-discuss mailing list >> dtrace-discuss at opensolaris.org > > _________________________________________________________________ > ??????????????? MSN Hotmail? http://www.hotmail.com > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org
Thanks for your correcting. Another question: In userland, is there any other way to open file except for the open()/creat() syscall? of course, in kernel area, don''t need to care open or not, just reference to vnode,then can do any operation for associated file.>From: Dan Mick <dan.mick at sun.com> >To: Zhou Aaron <aaron.zhou1018 at hotmail.com> >CC: bart.smaalders at sun.com, venkatesh_ch at yahoo.com,dtrace-discuss at opensolaris.org>Subject: Re: [dtrace-discuss] all open files >Date: Mon, 09 Jul 2007 19:09:31 -0700 > >That''ll show you all the open() system calls, but not the currently >open files... > >Zhou Aaron wrote: > > dtrace -n ''syscall::open*:entry {printf("%s %s %d", > > execname,copyinstr(arg0),pid);}'' > > > > > >> From: Bart Smaalders <bart.smaalders at Sun.COM> > >> To: Venkat C <venkatesh_ch at yahoo.com> > >> CC: dtrace-discuss at opensolaris.org > >> Subject: Re: [dtrace-discuss] all open files > >> Date: Mon, 09 Jul 2007 17:52:05 -0700 > >> > >> Venkat C wrote: > >>> Hi All, > >>> > >>> Is there a simple way to list all currently open file descriptors ? > >> > >> # ls -l /proc/*/path > >> > >> :-) > >> > >> - Bart > >> > >> -- > >> Bart Smaalders Solaris Kernel Performance > >> barts at cyber.eng.sun.com http://blogs.sun.com/barts > >> _______________________________________________ > >> dtrace-discuss mailing list > >> dtrace-discuss at opensolaris.org > > > > _________________________________________________________________ > > ??????????????? MSN Hotmail? http://www.hotmail.com > > > > _______________________________________________ > > dtrace-discuss mailing list > > dtrace-discuss at opensolaris.org >_________________________________________________________________ ??????????????? MSN Hotmail? http://www.hotmail.com
Venkat, "pfiles <pid>" should list all the open file descriptors with other necessary details. -- Sanjeev Venkat C wrote:>Hi All, > >Is there a simple way to list all currently open file descriptors ? > >TIA.. > >Regards, >Venkat >-- >This message posted from opensolaris.org >_______________________________________________ >dtrace-discuss mailing list >dtrace-discuss at opensolaris.org > >-- Solaris Revenue Products Engineering, India Engineering Center, Sun Microsystems India Pvt Ltd. Tel: x27521 +91 80 669 27521
file system is managed by kernel so, every regular file open request is sent to kernel by calling open/creat no matter what the user functions are. it''s the basic OS concept. ?07-7-10?Zhou Aaron <aaron.zhou1018 at hotmail.com> ???> > Thanks for your correcting. > Another question: In userland, is there any other way to open file except > for the open()/creat() syscall? of course, in kernel area, don''t need to > care open or not, just reference to vnode,then can do any operation for > associated file. > > > >From: Dan Mick <dan.mick at sun.com> > >To: Zhou Aaron <aaron.zhou1018 at hotmail.com> > >CC: bart.smaalders at sun.com, venkatesh_ch at yahoo.com, > dtrace-discuss at opensolaris.org > >Subject: Re: [dtrace-discuss] all open files > >Date: Mon, 09 Jul 2007 19:09:31 -0700 > > > >That''ll show you all the open() system calls, but not the currently > >open files... > > > >Zhou Aaron wrote: > > > dtrace -n ''syscall::open*:entry {printf("%s %s %d", > > > execname,copyinstr(arg0),pid);}'' > > > > > > > > >> From: Bart Smaalders <bart.smaalders at Sun.COM> > > >> To: Venkat C <venkatesh_ch at yahoo.com> > > >> CC: dtrace-discuss at opensolaris.org > > >> Subject: Re: [dtrace-discuss] all open files > > >> Date: Mon, 09 Jul 2007 17:52:05 -0700 > > >> > > >> Venkat C wrote: > > >>> Hi All, > > >>> > > >>> Is there a simple way to list all currently open file descriptors ? > > >> > > >> # ls -l /proc/*/path > > >> > > >> :-) > > >> > > >> - Bart > > >> > > >> -- > > >> Bart Smaalders Solaris Kernel Performance > > >> barts at cyber.eng.sun.com http://blogs.sun.com/barts > > >> _______________________________________________ > > >> dtrace-discuss mailing list > > >> dtrace-discuss at opensolaris.org > > > > > > _________________________________________________________________ > > > ??????????????? MSN Hotmail? http://www.hotmail.com > > > > > > _______________________________________________ > > > dtrace-discuss mailing list > > > dtrace-discuss at opensolaris.org > > > > _________________________________________________________________ > ??????????????? MSN Hotmail? http://www.hotmail.com > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20070710/637a829b/attachment.html>
yes, i know this. Thanks.>From: "?? Tao Jie" <eulertao at gmail.com> >To: "Zhou Aaron" <aaron.zhou1018 at hotmail.com> >CC: dan.mick at sun.com, venkatesh_ch at yahoo.com,dtrace-discuss at opensolaris.org>Subject: Re: [dtrace-discuss] all open files >Date: Tue, 10 Jul 2007 12:14:56 +0800 > >file system is managed by kernel >so, every regular file open request is sent to kernel by calling >open/creat >no matter what the user functions are. > >it''s the basic OS concept. > > >?07-7-10?Zhou Aaron <aaron.zhou1018 at hotmail.com> ??? >> >>Thanks for your correcting. >>Another question: In userland, is there any other way to open file >>except >>for the open()/creat() syscall? of course, in kernel area, don''t >>need to >>care open or not, just reference to vnode,then can do any operation >>for >>associated file. >> >> >> >From: Dan Mick <dan.mick at sun.com> >> >To: Zhou Aaron <aaron.zhou1018 at hotmail.com> >> >CC: bart.smaalders at sun.com, venkatesh_ch at yahoo.com, >>dtrace-discuss at opensolaris.org >> >Subject: Re: [dtrace-discuss] all open files >> >Date: Mon, 09 Jul 2007 19:09:31 -0700 >> > >> >That''ll show you all the open() system calls, but not the >>currently >> >open files... >> > >> >Zhou Aaron wrote: >> > > dtrace -n ''syscall::open*:entry {printf("%s %s %d", >> > > execname,copyinstr(arg0),pid);}'' >> > > >> > > >> > >> From: Bart Smaalders <bart.smaalders at Sun.COM> >> > >> To: Venkat C <venkatesh_ch at yahoo.com> >> > >> CC: dtrace-discuss at opensolaris.org >> > >> Subject: Re: [dtrace-discuss] all open files >> > >> Date: Mon, 09 Jul 2007 17:52:05 -0700 >> > >> >> > >> Venkat C wrote: >> > >>> Hi All, >> > >>> >> > >>> Is there a simple way to list all currently open file >>descriptors ? >> > >> >> > >> # ls -l /proc/*/path >> > >> >> > >> :-) >> > >> >> > >> - Bart >> > >> >> > >> -- >> > >> Bart Smaalders Solaris Kernel Performance >> > >> barts at cyber.eng.sun.com http://blogs.sun.com/barts >> > >> _______________________________________________ >> > >> dtrace-discuss mailing list >> > >> dtrace-discuss at opensolaris.org >> > > >> > > >>_________________________________________________________________ >> > > ??????????????? MSN Hotmail? >>http://www.hotmail.com >> > > >> > > _______________________________________________ >> > > dtrace-discuss mailing list >> > > dtrace-discuss at opensolaris.org >> > >> >>_________________________________________________________________ >>??????????????? MSN Hotmail? >>http://www.hotmail.com >> >>_______________________________________________ >>dtrace-discuss mailing list >>dtrace-discuss at opensolaris.org_________________________________________________________________ ?????????????? MSN Messenger: http://messenger.msn.com/cn
Zhou Aaron wrote:> Thanks for your correcting. > Another question: In userland, is there any other way to open file > except for the open()/creat() syscall?I''m not sure. There may be other variants of open/creat.> of course, in kernel area, don''t > need to care open or not, just reference to vnode,then can do any > operation for associated file.Well, that vnode has to get created and initialized somehow. But how are these questions helpful to the problem?> > >> From: Dan Mick <dan.mick at sun.com> >> To: Zhou Aaron <aaron.zhou1018 at hotmail.com> >> CC: bart.smaalders at sun.com, venkatesh_ch at yahoo.com, > dtrace-discuss at opensolaris.org >> Subject: Re: [dtrace-discuss] all open files >> Date: Mon, 09 Jul 2007 19:09:31 -0700 >> >> That''ll show you all the open() system calls, but not the currently >> open files... >> >> Zhou Aaron wrote: >> > dtrace -n ''syscall::open*:entry {printf("%s %s %d", >> > execname,copyinstr(arg0),pid);}'' >> > >> > >> >> From: Bart Smaalders <bart.smaalders at Sun.COM> >> >> To: Venkat C <venkatesh_ch at yahoo.com> >> >> CC: dtrace-discuss at opensolaris.org >> >> Subject: Re: [dtrace-discuss] all open files >> >> Date: Mon, 09 Jul 2007 17:52:05 -0700 >> >> >> >> Venkat C wrote: >> >>> Hi All, >> >>> >> >>> Is there a simple way to list all currently open file descriptors ? >> >> >> >> # ls -l /proc/*/path >> >> >> >> :-) >> >> >> >> - Bart >> >> >> >> -- >> >> Bart Smaalders Solaris Kernel Performance >> >> barts at cyber.eng.sun.com http://blogs.sun.com/barts >> >> _______________________________________________ >> >> dtrace-discuss mailing list >> >> dtrace-discuss at opensolaris.org >> > >> > _________________________________________________________________ >> > ??????????????? MSN Hotmail? http://www.hotmail.com >> > >> > _______________________________________________ >> > dtrace-discuss mailing list >> > dtrace-discuss at opensolaris.org >> > > _________________________________________________________________ > ??????????????? MSN Hotmail? http://www.hotmail.com
Hello Dan, Thanks. According to this email subject line, I think there isn''t a way can list all open files, because some application can use other way (such as ioctl()) to open file, or directly open file from kernel area(such VOP_OPEN or other way implemented by himself) in a module,isn''t it?>From: Dan Mick <dan.mick at sun.com> >To: Zhou Aaron <aaron.zhou1018 at hotmail.com> >CC: bart.smaalders at sun.com, venkatesh_ch at yahoo.com,dtrace-discuss at opensolaris.org>Subject: Re: [dtrace-discuss] all open files >Date: Tue, 10 Jul 2007 01:03:58 -0700 > >Zhou Aaron wrote: > > Thanks for your correcting. > > Another question: In userland, is there any other way to open file > > except for the open()/creat() syscall? > >I''m not sure. There may be other variants of open/creat. > > > of course, in kernel area, don''t > > need to care open or not, just reference to vnode,then can do any > > operation for associated file. > >Well, that vnode has to get created and initialized somehow. But how >are these questions helpful to the problem? > > > > > > >> From: Dan Mick <dan.mick at sun.com> > >> To: Zhou Aaron <aaron.zhou1018 at hotmail.com> > >> CC: bart.smaalders at sun.com, venkatesh_ch at yahoo.com, > > dtrace-discuss at opensolaris.org > >> Subject: Re: [dtrace-discuss] all open files > >> Date: Mon, 09 Jul 2007 19:09:31 -0700 > >> > >> That''ll show you all the open() system calls, but not the currently > >> open files... > >> > >> Zhou Aaron wrote: > >> > dtrace -n ''syscall::open*:entry {printf("%s %s %d", > >> > execname,copyinstr(arg0),pid);}'' > >> > > >> > > >> >> From: Bart Smaalders <bart.smaalders at Sun.COM> > >> >> To: Venkat C <venkatesh_ch at yahoo.com> > >> >> CC: dtrace-discuss at opensolaris.org > >> >> Subject: Re: [dtrace-discuss] all open files > >> >> Date: Mon, 09 Jul 2007 17:52:05 -0700 > >> >> > >> >> Venkat C wrote: > >> >>> Hi All, > >> >>> > >> >>> Is there a simple way to list all currently open file descriptors?> >> >> > >> >> # ls -l /proc/*/path > >> >> > >> >> :-) > >> >> > >> >> - Bart > >> >> > >> >> -- > >> >> Bart Smaalders Solaris Kernel Performance > >> >> barts at cyber.eng.sun.com http://blogs.sun.com/barts > >> >> _______________________________________________ > >> >> dtrace-discuss mailing list > >> >> dtrace-discuss at opensolaris.org > >> > > >> > _________________________________________________________________ > >> > ??????????????? MSN Hotmail? http://www.hotmail.com > >> > > >> > _______________________________________________ > >> > dtrace-discuss mailing list > >> > dtrace-discuss at opensolaris.org > >> > > > > _________________________________________________________________ > > ??????????????? MSN Hotmail? http://www.hotmail.com > >_________________________________________________________________ ???? MSN Explorer: http://explorer.msn.com/lccn/
:>Zhou Aaron wrote: >> Thanks for your correcting. >> Another question: In userland, is there any other way to open file >> except for the open()/creat() syscall?>I''m not sure. There may be other variants of open/creat.open64/creat64 (but those tend to be hidden/automatic) openat() (opens relative to a specific directory)>Well, that vnode has to get created and initialized somehow. But how >are these questions helpful to the problem?Yes, by calling the appropriate functions. (Not part of the DDI/DDK as of yet, I believe) Casper
>Hello Dan,>Thanks. According to this email subject line, I think there isn''t a way can >list all open files, because some application can use other way (such as >ioctl()) to open file, or directly open file from kernel area(such VOP_OPEN >or other way implemented by himself) in a module,isn''t it?That is not correct; because all files opened by applications end up as file descriptors; so they''ll all end up as /proc/<pid>/fd/* and /proc/<pid>/path/*. The path is not always known nor can it always be known. Casper
"Zhou" == Zhou Aaron <aaron.zhou1018 at hotmail.com> writes: Zhou> Another question: In userland, is there any other way to open Zhou> file except for the open()/creat() syscall? of course, in kernel Zhou> area, don''t need to care open or not, just reference to Zhou> vnode,then can do any operation for associated file. Depends what you mean by "file". Are you interested in all the ways you can get a file descriptor? If that''s the case, you need to add dup/dup2 and socket. Oh, how about pipe? -- Dave Marquardt Sun Microsystems, Inc. Austin, TX +1 512 401-1077 (SUN internal: x64077)
Dave Marquardt writes:> "Zhou" == Zhou Aaron <aaron.zhou1018 at hotmail.com> writes: > > Zhou> Another question: In userland, is there any other way to open > Zhou> file except for the open()/creat() syscall? of course, in kernel > Zhou> area, don''t need to care open or not, just reference to > Zhou> vnode,then can do any operation for associated file. > > Depends what you mean by "file". Are you interested in all the ways > you can get a file descriptor? If that''s the case, you need to add > dup/dup2 and socket. Oh, how about pipe?... and accept() and descriptor passing and the various ioctls that can return open fds. -- James Carlson, Solaris Networking <james.d.carlson at sun.com> Sun Microsystems / 1 Network Drive 71.232W Vox +1 781 442 2084 MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677
I think you''re misunderstanding the purpose and use of dtrace. it''s about instrumenting code paths. If the code path was executed long ago, dtrace will be of little use. Sometimes it helps me to think of dtrace as "incredibly smart, output-rich, data-reducing breakpoints", but that''s just because I''m a debugger geek. In other words, what you''re looking for is more "parse a table recording past events in current state" than "wait for an event and do something when it happens". Venkatesh wrote:> Hi All, > > Thank you all for the responses. Many referred to > /proc/*/path and pfiles, which i am already aware of. > However i was wondering, if there is a way to get the same > info from "dtrace". > > We can find using "syscall::open*:entry" , however this > does not account for already open files. > > Is there any other way , using dtrace to find all the open > files. > > Regards, > Venkat > > > --- James Carlson <james.d.carlson at Sun.COM> wrote: > >> Dave Marquardt writes: >>> "Zhou" == Zhou Aaron <aaron.zhou1018 at hotmail.com> >> writes: >>> Zhou> Another question: In userland, is there any other >> way to open >>> Zhou> file except for the open()/creat() syscall? of >> course, in kernel >>> Zhou> area, don''t need to care open or not, just >> reference to >>> Zhou> vnode,then can do any operation for associated >> file. >>> Depends what you mean by "file". Are you interested in >> all the ways >>> you can get a file descriptor? If that''s the case, you >> need to add >>> dup/dup2 and socket. Oh, how about pipe? >> ... and accept() and descriptor passing and the various >> ioctls that >> can return open fds. >> >> -- >> James Carlson, Solaris Networking >> <james.d.carlson at sun.com> >> Sun Microsystems / 1 Network Drive 71.232W Vox >> +1 781 442 2084 >> MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax >> +1 781 442 1677 >> > > > > > ____________________________________________________________________________________ > Finding fabulous fares is fun. > Let Yahoo! FareChase search your favorite travel sites to find flight and hotel bargains. > http://farechase.yahoo.com/promo-generic-14795097
I think there isn''t a good way to check all open files like you expected using dtrace.May you can write a simple module and search all existent process file table to get all open files.I believe "/proc" should use this way already.>From: Venkatesh <venkatesh_ch at yahoo.com> >To: Dan Mick <dan.mick at sun.com> >CC: James Carlson <james.d.carlson at sun.com>, Dave Marquardt<Dave.Marquardt at sun.com>, Zhou Aaron <aaron.zhou1018 at hotmail.com>, dtrace-discuss at opensolaris.org>Subject: Re: [dtrace-discuss] all open files >Date: Wed, 11 Jul 2007 17:59:46 -0700 (PDT) > > >Thanks so much Dan for explanation. > >I was thinking if there is some kind of walkers like mdb >(or) some other internal kernel sys call, that i could >probe using Dtrace to find all open files. > >/proc tools, is my answer then. > >Thanks again for all. > >Regards, >Venkat > >--- Dan Mick <dan.mick at sun.com> wrote: > > > I think you''re misunderstanding the purpose and use of > > dtrace. > > > > it''s about instrumenting code paths. If the code path > > was executed long ago, > > dtrace will be of little use. > > > > Sometimes it helps me to think of dtrace as "incredibly > > smart, output-rich, > > data-reducing breakpoints", but that''s just because I''m a > > debugger geek. > > > > In other words, what you''re looking for is more "parse a > > table recording past > > events in current state" than "wait for an event and do > > something when it happens". > > > > Venkatesh wrote: > > > Hi All, > > > > > > Thank you all for the responses. Many referred to > > > /proc/*/path and pfiles, which i am already aware of. > > > However i was wondering, if there is a way to get the > > same > > > info from "dtrace". > > > > > > We can find using "syscall::open*:entry" , however this > > > does not account for already open files. > > > > > > Is there any other way , using dtrace to find all the > > open > > > files. > > > > > > Regards, > > > Venkat > > > > > > > > > --- James Carlson <james.d.carlson at Sun.COM> wrote: > > > > > >> Dave Marquardt writes: > > >>> "Zhou" == Zhou Aaron <aaron.zhou1018 at hotmail.com> > > >> writes: > > >>> Zhou> Another question: In userland, is there any > > other > > >> way to open > > >>> Zhou> file except for the open()/creat() syscall? of > > >> course, in kernel > > >>> Zhou> area, don''t need to care open or not, just > > >> reference to > > >>> Zhou> vnode,then can do any operation for associated > > >> file. > > >>> Depends what you mean by "file". Are you interested > > in > > >> all the ways > > >>> you can get a file descriptor? If that''s the case, > > you > > >> need to add > > >>> dup/dup2 and socket. Oh, how about pipe? > > >> ... and accept() and descriptor passing and the > > various > > >> ioctls that > > >> can return open fds. > > >> > > >> -- > > >> James Carlson, Solaris Networking > > >> <james.d.carlson at sun.com> > > >> Sun Microsystems / 1 Network Drive 71.232W > > Vox > > >> +1 781 442 2084 > > >> MS UBUR02-212 / Burlington MA 01803-2757 42.496N > > Fax > > >> +1 781 442 1677 > > >> > > > > > > > > > > > > > > > > > >____________________________________________________________________________________> > > Finding fabulous fares is fun. > > > Let Yahoo! FareChase search your favorite travel sites > > to find flight and hotel bargains. > > > http://farechase.yahoo.com/promo-generic-14795097 > > > > > > > > >____________________________________________________________________________________>Choose the right car based on your needs. Check out Yahoo! Autos new CarFinder tool.>http://autos.yahoo.com/carfinder/_________________________________________________________________ ???? MSN Explorer: http://explorer.msn.com/lccn/
Zhou Aaron wrote (2007-07-12 12:08):> I think there isn''t a good way to check all open files like you expected > using dtrace.May you can write a simple module and [...]Or maybe just use the lsof-package from sunfreeware.com? -- * Origin: Fido over IP (2:240/2188.575)
Gerhard Strangar wrote:> Zhou Aaron wrote (2007-07-12 12:08): >> I think there isn''t a good way to check all open files like you expected >> using dtrace.May you can write a simple module and [...] > > Or maybe just use the lsof-package from sunfreeware.com?or, "ls", like Bart originally suggested...