getpwent() home directory v/s getcwd()

Here's the story: I call getpwent() to get a user's home directory. I also have a list of path aliases in a file that I will use to replace paths I'm given. The paths in the path alias file and the home directory from getpwent() are logical paths, e.g. /home/dant. Now, in my code, I need to be able to recognize an aliased path when I see it. The problem is that the paths I'm being given are physical paths, e.g. /tmpmnt/home/dant.

The current solution is to chdir() to the home directory and use getcwd() to get the physical path for it. Then, if I see that physical path in a path I'm given, I can replace that part of the path with the logical home directory and then look the logical path up in the path alias list.

The problem with the current solution is that I have to chdir() to do it, which is not thread safe. Can anyone lend me any clever insight into how to solve this problem cleanly?

Comments:

use realpath(3C) or resolvepath(2)

Posted by guest on July 14, 2004 at 02:17 AM PDT #

Post a Comment:
Comments are closed for this entry.
About

templedf

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today