symlink handling in resmgr

This is hopefully my last question about symlinks.
I’ve read the Unix98/Solo spec, and all it says about
processing symlinks is that they are “interpolated into”
the pathname. Nice $10 expression. :slight_smile:

I’m wondering if this is correct:

a) if the content of the symlink begins with a slash,
simply return the content of the symlink.
b) if the content of the symlink does not begin with
a slash, return the full current pathname up to but
not including the symlink, followed by the content
of the symlink.

I’m guessing that I should also append the rest of
the pathname after the symlink to the redirection, right?

So, just to make sure I have all the cases:

pathname “/ramdisk/a”, “a” → “/bin/vi”, return “/bin/vi”
pathname “/ramdisk/a/b”, “a/b” → “c”, return “/ramdisk/a/c”
pathanme “/ramdisk/dir/spud”, “spud” → “/tmp”, return “/tmp/spud”

(Above is interpreted as: given the pathname “xxx”, with a symlink
“yyy”, I should return “zzz” as the redirect out of the io_open).

Is this correct? :slight_smile:

Thanks in advance!

Cheers,
-RK

Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.

Robert Krten <nospam83@parse.com> wrote:

This is hopefully my last question about symlinks.
I’ve read the Unix98/Solo spec, and all it says about
processing symlinks is that they are “interpolated into”
the pathname. Nice $10 expression. > :slight_smile:

I’m wondering if this is correct:

a) if the content of the symlink begins with a slash,
simply return the content of the symlink.
b) if the content of the symlink does not begin with
a slash, return the full current pathname up to but
not including the symlink, followed by the content
of the symlink.

I’m guessing that I should also append the rest of
the pathname after the symlink to the redirection, right?

So, just to make sure I have all the cases:

pathname “/ramdisk/a”, “a” → “/bin/vi”, return “/bin/vi”
pathname “/ramdisk/a/b”, “a/b” → “c”, return “/ramdisk/a/c”
pathanme “/ramdisk/dir/spud”, “spud” → “/tmp”, return “/tmp/spud”

D’oh! For the last one, I meant to say:

pathanme “/ramdisk/dir/spud”, “dir” → “/tmp”, return “/tmp/spud”

Sigh.

(Above is interpreted as: given the pathname “xxx”, with a symlink
“yyy”, I should return “zzz” as the redirect out of the io_open).

Is this correct? > :slight_smile:

Thanks in advance!

Cheers,
-RK

Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at > www.parse.com> .
Email my initials at parse dot com.


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.

David Gibbs <dagibbs@qnx.com> wrote:

Robert Krten <> nospam83@parse.com> > wrote:
This is hopefully my last question about symlinks.
I’ve read the Unix98/Solo spec, and all it says about
processing symlinks is that they are “interpolated into”
the pathname. Nice $10 expression. > :slight_smile:

I’m wondering if this is correct:

a) if the content of the symlink begins with a slash,
simply return the content of the symlink.
b) if the content of the symlink does not begin with
a slash, return the full current pathname up to but
not including the symlink, followed by the content
of the symlink.

Missing two cases:

c) if the content of the symlink starts with a ./
treat like b

Ok (although technically, it is “b”, “does not begin with a slash” :slight_smile:)

d) if the content of the symlink starts with a …/
pre-pend the appropriate… and return it

Just to clarify, this is a “treat like b”, right? In that I
would simply return the content of the symlink, “…”?

Do you know about the “append rest of pathname after symlink part”
of the question? It seems that that’s the “correct” thing to
do, otherwise the rest of the pathname would get lost…

Thanks, Dave!
-RK


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.

Robert Krten <nospam83@parse.com> wrote:

This is hopefully my last question about symlinks.
I’ve read the Unix98/Solo spec, and all it says about
processing symlinks is that they are “interpolated into”
the pathname. Nice $10 expression. > :slight_smile:

I’m wondering if this is correct:

a) if the content of the symlink begins with a slash,
simply return the content of the symlink.
b) if the content of the symlink does not begin with
a slash, return the full current pathname up to but
not including the symlink, followed by the content
of the symlink.

Missing two cases:

c) if the content of the symlink starts with a ./
treat like b
d) if the content of the symlink starts with a …/
pre-pend the appropriate… and return it

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Robert Krten <nospam83@parse.com> wrote:

David Gibbs <> dagibbs@qnx.com> > wrote:
Robert Krten <> nospam83@parse.com> > wrote:
This is hopefully my last question about symlinks.
I’ve read the Unix98/Solo spec, and all it says about
processing symlinks is that they are “interpolated into”
the pathname. Nice $10 expression. > :slight_smile:

I’m wondering if this is correct:

a) if the content of the symlink begins with a slash,
simply return the content of the symlink.
b) if the content of the symlink does not begin with
a slash, return the full current pathname up to but
not including the symlink, followed by the content
of the symlink.

Missing two cases:

c) if the content of the symlink starts with a ./
treat like b

Ok (although technically, it is “b”, “does not begin with a slash” > :slight_smile:> )

True…but I guess both are really handled by b.


d) if the content of the symlink starts with a …/
pre-pend the appropriate… and return it

Just to clarify, this is a “treat like b”, right? In that I
would simply return the content of the symlink, “…”?

Hm… I’m not sure if you would return

/path1/path2/…/path3/blah

Or, whether it would be correct to return:

/path1/path3/blah

Do you know about the “append rest of pathname after symlink part”
of the question? It seems that that’s the “correct” thing to
do, otherwise the rest of the pathname would get lost…

It made sense, but I didn’t know the answer for sure, so didn’t
comment.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

David Gibbs <dagibbs@qnx.com> wrote:

Robert Krten <> nospam83@parse.com> > wrote:
David Gibbs <> dagibbs@qnx.com> > wrote:
Robert Krten <> nospam83@parse.com> > wrote:
This is hopefully my last question about symlinks.
I’ve read the Unix98/Solo spec, and all it says about
processing symlinks is that they are “interpolated into”
the pathname. Nice $10 expression. > :slight_smile:

I’m wondering if this is correct:

a) if the content of the symlink begins with a slash,
simply return the content of the symlink.
b) if the content of the symlink does not begin with
a slash, return the full current pathname up to but
not including the symlink, followed by the content
of the symlink.

Missing two cases:

c) if the content of the symlink starts with a ./
treat like b

Ok (although technically, it is “b”, “does not begin with a slash” > :slight_smile:> )

True…but I guess both are really handled by b.



d) if the content of the symlink starts with a …/
pre-pend the appropriate… and return it

Just to clarify, this is a “treat like b”, right? In that I
would simply return the content of the symlink, “…”?

Hm… I’m not sure if you would return

/path1/path2/…/path3/blah

Or, whether it would be correct to return:

/path1/path3/blah

That’s something I’ll have to play with – I’m leaning towards
the “just return the contents” and let someone else worry about
it, otherwise, you’d have to analyze the entire contents of the
symlink and do that for all “…” paths… which would be ugly.

Do you know about the “append rest of pathname after symlink part”
of the question? It seems that that’s the “correct” thing to
do, otherwise the rest of the pathname would get lost…

It made sense, but I didn’t know the answer for sure, so didn’t
comment.

'kay. I’ll play with that as well :slight_smile:

Thanks Dave!
-RK


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.

Xiaodan Tang <xtang@qnx.com> wrote:

My understanding is you always return contents if it start from /, or you
return
the part related the your mount point…

Say you take /ramdisk,

a → /bin/vi return “/bin/vi”
b → …/bin/ls return “…/bin/ls”
dir/c where dir → /tmp, return /tmp/c

The _connect_ctrl() will do the rest of the work for you, and it also ensure
that
if you are "chroot"ed, the b case won’t be able to go out.

-xtang

Thanks Xiaodan!

Cheers,
-RK


Robert Krten <> nospam83@parse.com> > wrote in message
news:atnk8c$n68$> 1@inn.qnx.com> …
David Gibbs <> dagibbs@qnx.com> > wrote:
Robert Krten <> nospam83@parse.com> > wrote:
David Gibbs <> dagibbs@qnx.com> > wrote:
Robert Krten <> nospam83@parse.com> > wrote:
This is hopefully my last question about symlinks.
I’ve read the Unix98/Solo spec, and all it says about
processing symlinks is that they are “interpolated into”
the pathname. Nice $10 expression. > :slight_smile:

I’m wondering if this is correct:

a) if the content of the symlink begins with a slash,
simply return the content of the symlink.
b) if the content of the symlink does not begin with
a slash, return the full current pathname up to but
not including the symlink, followed by the content
of the symlink.

Missing two cases:

c) if the content of the symlink starts with a ./
treat like b

Ok (although technically, it is “b”, “does not begin with a slash”
:slight_smile:> )

True…but I guess both are really handled by b.


d) if the content of the symlink starts with a …/
pre-pend the appropriate… and return it

Just to clarify, this is a “treat like b”, right? In that I
would simply return the content of the symlink, “…”?

Hm… I’m not sure if you would return

/path1/path2/…/path3/blah

Or, whether it would be correct to return:

/path1/path3/blah

That’s something I’ll have to play with – I’m leaning towards
the “just return the contents” and let someone else worry about
it, otherwise, you’d have to analyze the entire contents of the
symlink and do that for all “…” paths… which would be ugly.

Do you know about the “append rest of pathname after symlink part”
of the question? It seems that that’s the “correct” thing to
do, otherwise the rest of the pathname would get lost…

It made sense, but I didn’t know the answer for sure, so didn’t
comment.

'kay. I’ll play with that as well > :slight_smile:

Thanks Dave!
-RK


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at > www.parse.com> .
Email my initials at parse dot com.


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.

My understanding is you always return contents if it start from /, or you
return
the part related the your mount point…

Say you take /ramdisk,

a → /bin/vi return “/bin/vi”
b → …/bin/ls return “…/bin/ls”
dir/c where dir → /tmp, return /tmp/c

The _connect_ctrl() will do the rest of the work for you, and it also ensure
that
if you are "chroot"ed, the b case won’t be able to go out.

-xtang

Robert Krten <nospam83@parse.com> wrote in message
news:atnk8c$n68$1@inn.qnx.com

David Gibbs <> dagibbs@qnx.com> > wrote:
Robert Krten <> nospam83@parse.com> > wrote:
David Gibbs <> dagibbs@qnx.com> > wrote:
Robert Krten <> nospam83@parse.com> > wrote:
This is hopefully my last question about symlinks.
I’ve read the Unix98/Solo spec, and all it says about
processing symlinks is that they are “interpolated into”
the pathname. Nice $10 expression. > :slight_smile:

I’m wondering if this is correct:

a) if the content of the symlink begins with a slash,
simply return the content of the symlink.
b) if the content of the symlink does not begin with
a slash, return the full current pathname up to but
not including the symlink, followed by the content
of the symlink.

Missing two cases:

c) if the content of the symlink starts with a ./
treat like b

Ok (although technically, it is “b”, “does not begin with a slash”
:slight_smile:> )

True…but I guess both are really handled by b.


d) if the content of the symlink starts with a …/
pre-pend the appropriate… and return it

Just to clarify, this is a “treat like b”, right? In that I
would simply return the content of the symlink, “…”?

Hm… I’m not sure if you would return

/path1/path2/…/path3/blah

Or, whether it would be correct to return:

/path1/path3/blah

That’s something I’ll have to play with – I’m leaning towards
the “just return the contents” and let someone else worry about
it, otherwise, you’d have to analyze the entire contents of the
symlink and do that for all “…” paths… which would be ugly.

Do you know about the “append rest of pathname after symlink part”
of the question? It seems that that’s the “correct” thing to
do, otherwise the rest of the pathname would get lost…

It made sense, but I didn’t know the answer for sure, so didn’t
comment.

'kay. I’ll play with that as well > :slight_smile:

Thanks Dave!
-RK


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at > www.parse.com> .
Email my initials at parse dot com.