# example data
str = "some string abc xyz"
tokens = [ /abc/, /xyz/ ]
i = 0
# must be a better way?
token,match,mindex = tokens.inject([nil,nil,str.length]){ |memo, tkn|
s = str.index( tkn.start_pattern, i )
if s
s < memo[2] ? [tkn, $~, s] : memo
else
memo
end
}
In this case this should return a match to 'abc' (this case has not been
tested, but the core of this example has)
linux kernel understandings at: http://www.tldp.org/LDP/khg/HyperNews/get/fs/vfstour.html
The document says you can understand the filesystem by also reading the sources in the fs/ folder in your kernel sources. open.c
You need to be able to write good C code and understand much.
This is not possible on systems that has Unix semantics for file
permissions, because that would violate the security model.
Directories that prevent access to files below them are not supposed
to be possible to circumvent by guessing inode numbers.
The documents David Ross points at are for the kernel layer.
Eivind.
···
On Fri, 22 Oct 2004 22:08:38 +0900, MiG <mig@1984.cz> wrote:
Is it possible to open file if I know it's inode (on Linux)?
Of course, but it's not what i mean.
My program firstly scan the tree, but I don't want to cache names, just
inodes..
After the scan need to open some files.
jan molic
···
Dne 22/10/2004, napsal "nobu.nokada@softhome.net" <nobu.nokada@softhome.net>:
Hi,
At Fri, 22 Oct 2004 22:08:38 +0900,
MiG wrote in [ruby-talk:117351]:
Is it possible to open file if I know it's inode (on Linux)?
Although here is not ML for Linux, you could do it by searching
the corresponding file name from the root.
"MiG" <mig@1984.cz> schrieb im Newsbeitrag
news:XqdKn7tA.1098451120.1430970.mig@1984.cz...
Of course, but it's not what i mean.
My program firstly scan the tree, but I don't want to cache names, just
inodes..
Why is that? Memory?
After the scan need to open some files.
If you give a bit more information we might be able to come up with a
solution.
Kind regards
robert
···
jan molic
Dne 22/10/2004, napsal "nobu.nokada@softhome.net"
<nobu.nokada@softhome.net>:
>Hi,
>
>At Fri, 22 Oct 2004 22:08:38 +0900,
>MiG wrote in [ruby-talk:117351]:
>> Is it possible to open file if I know it's inode (on Linux)?
>
>Although here is not ML for Linux, you could do it by searching
>the corresponding file name from the root.
>
>--
>Nobu Nakada
>