Cannonicalizing filenames in Unix (Get full name): What is the status?

Cannonicalizing filenames in Unix (Get full name): What is the status?

Post by Chris F.A. Johnso » Sun, 01 Jul 2001 01:52:44




Quote:> I know this is discussed frequently in this newsgroup - but I can't
> remember what the resolution was.  I have checked the FAQ (the one that is
> posted to the NG peridocally by Ted Timar) - searched for either "cannon" or
> "full.*name" - and did not find anything.

Search http://groups.google.com/groups?group=comp.unix.shell for:
How to get full path of file - universal method

There was a fairly lengthy discussion around the first half of May.

(And that's "canon" not "cannon" :)

Quote:> So, if I have a filename of, say "foo" or "foo/bar" (in a variable "fn")
> and I want to know its fullpath name from the root, the method I would use
> is something like:

>    1) Start with $PWD/$fn
>    2) Delete any "./"
>    3) Delete any "xxx/.." (for any xxx)

> Now, modulo symlinks, is there anything else to worry about?

> I'm sure this has been solved 1000s of times over the years, in full blown
> style - handling symlinks and whatever.  I also seem to remember that there
> is some built in utility on some OSs that does this - I'm thinking Solaris
> (*) - but I am not sure.

> (*) Which would be ideal, since I need this to run on Solaris (only).

--
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2001, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License
 
 
 

Cannonicalizing filenames in Unix (Get full name): What is the status?

Post by Kenny McCorma » Sun, 01 Jul 2001 01:40:22


I know this is discussed frequently in this newsgroup - but I can't
remember what the resolution was.  I have checked the FAQ (the one that is
posted to the NG peridocally by Ted Timar) - searched for either "cannon" or
"full.*name" - and did not find anything.

So, if I have a filename of, say "foo" or "foo/bar" (in a variable "fn")
and I want to know its fullpath name from the root, the method I would use
is something like:

        1) Start with $PWD/$fn
        2) Delete any "./"
        3) Delete any "xxx/.." (for any xxx)

Now, modulo symlinks, is there anything else to worry about?

I'm sure this has been solved 1000s of times over the years, in full blown
style - handling symlinks and whatever.  I also seem to remember that there
is some built in utility on some OSs that does this - I'm thinking Solaris
(*) - but I am not sure.

(*) Which would be ideal, since I need this to run on Solaris (only).

 
 
 

Cannonicalizing filenames in Unix (Get full name): What is the status?

Post by Kenny McCorma » Sun, 01 Jul 2001 08:09:04





>> I know this is discussed frequently in this newsgroup - but I can't
>> remember what the resolution was.  I have checked the FAQ (the one that is
>> posted to the NG peridocally by Ted Timar) - searched for either "cannon" or
>> "full.*name" - and did not find anything.

>Search http://groups.google.com/groups?group=comp.unix.shell for:
>How to get full path of file - universal method

>There was a fairly lengthy discussion around the first half of May.

I went back and checked in google - it only brought up 4 matches, and only
one of them (the one from Cyrille) had code.  I could not get that code to
run, and it was much too complex for me to (quickly) analyze/debug.

Any pointers to web sites/etc ?

 
 
 

Cannonicalizing filenames in Unix (Get full name): What is the status?

Post by Chris F.A. Johnso » Sun, 01 Jul 2001 08:41:04






> >> I know this is discussed frequently in this newsgroup - but I can't
> >> remember what the resolution was.  I have checked the FAQ (the one that is
> >> posted to the NG peridocally by Ted Timar) - searched for either "cannon" or
> >> "full.*name" - and did not find anything.

> >Search http://groups.google.com/groups?group=comp.unix.shell for:
> >How to get full path of file - universal method

> >There was a fairly lengthy discussion around the first half of May.

> I went back and checked in google - it only brought up 4 matches, and only
> one of them (the one from Cyrille) had code.  I could not get that code to
> run, and it was much too complex for me to (quickly) analyze/debug.

> Any pointers to web sites/etc ?

18 messages in this thread:
http://groups.google.com/groups?hl=en&ic=1&th=f6a48d7063d00c25,18

--
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2001, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License

 
 
 

1. Trouble getting full name inside C

I have a server I am writing and inside the server, I am trying to get
the full name of a user based on the user name.  I use the call
pw = getpwnam(username) where username contains the username I want to look
up to get the information, and pw is a ptr of the correct type.

I know that I am getting the right records, because pw_passwd, pw_uid,
pw_gid, pw_shell, pw_dir, are correct.  _BUT_ the pw_gecos and
pw_comment fields are empty strings when printf'd.

Is there something stupid I am doing wrong here?

BTW, this is the last part of this critter that needs to be finished so
the sooner this gets done the happier I will be.

(I am running SunOS 4.1.2 and our password file is obtained through NIS,
yellow pages.)

-Erik
(reply by mail or post as you think is most appropriate.)
--
--

   (DISCLAIMER: Opinions expressed are mine and not the college's.)

2. more nfs problems

3. I am looking for a full-time junior unix position

4. Anyone an expert on setserial and multiport cards?

5. Getting the full path name in an 'ls'

6. Urgent Help! Token Ring and Linux

7. Getting full name of a directory

8. Again, a question: | and shell scripts...

9. getting full domain name from Solaris 2.4

10. Getting rid of named status messages?

11. getting ls -l to give full path names

12. How to change Windows-compliant filenames to Unix filenames

13. What is the full name of UNIX?