diff options
Diffstat (limited to 'e2fsprogs/ext2fs/get_pathname.c')
-rw-r--r-- | e2fsprogs/ext2fs/get_pathname.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/e2fsprogs/ext2fs/get_pathname.c b/e2fsprogs/ext2fs/get_pathname.c index 23f593f67..594090da0 100644 --- a/e2fsprogs/ext2fs/get_pathname.c +++ b/e2fsprogs/ext2fs/get_pathname.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * get_pathname.c --- do directry/inode -> name translation | 2 | * get_pathname.c --- do directry/inode -> name translation |
3 | * | 3 | * |
4 | * Copyright (C) 1993, 1994, 1995 Theodore Ts'o. | 4 | * Copyright (C) 1993, 1994, 1995 Theodore Ts'o. |
5 | * | 5 | * |
6 | * %Begin-Header% | 6 | * %Begin-Header% |
@@ -8,14 +8,14 @@ | |||
8 | * License. | 8 | * License. |
9 | * %End-Header% | 9 | * %End-Header% |
10 | * | 10 | * |
11 | * ext2fs_get_pathname(fs, dir, ino, name) | 11 | * ext2fs_get_pathname(fs, dir, ino, name) |
12 | * | ||
13 | * This function translates takes two inode numbers into a | ||
14 | * string, placing the result in <name>. <dir> is the containing | ||
15 | * directory inode, and <ino> is the inode number itself. If | ||
16 | * <ino> is zero, then ext2fs_get_pathname will return pathname | ||
17 | * of the the directory <dir>. | ||
12 | * | 18 | * |
13 | * This function translates takes two inode numbers into a | ||
14 | * string, placing the result in <name>. <dir> is the containing | ||
15 | * directory inode, and <ino> is the inode number itself. If | ||
16 | * <ino> is zero, then ext2fs_get_pathname will return pathname | ||
17 | * of the the directory <dir>. | ||
18 | * | ||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <stdio.h> | 21 | #include <stdio.h> |
@@ -65,8 +65,8 @@ static int get_pathname_proc(struct ext2_dir_entry *dirent, | |||
65 | return 0; | 65 | return 0; |
66 | } | 66 | } |
67 | 67 | ||
68 | static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir, | 68 | static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir, |
69 | ext2_ino_t ino, int maxdepth, | 69 | ext2_ino_t ino, int maxdepth, |
70 | char *buf, char **name) | 70 | char *buf, char **name) |
71 | { | 71 | { |
72 | struct get_pathname_struct gp; | 72 | struct get_pathname_struct gp; |
@@ -93,7 +93,7 @@ static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir, | |||
93 | gp.parent = 0; | 93 | gp.parent = 0; |
94 | gp.name = 0; | 94 | gp.name = 0; |
95 | gp.errcode = 0; | 95 | gp.errcode = 0; |
96 | 96 | ||
97 | retval = ext2fs_dir_iterate(fs, dir, 0, buf, get_pathname_proc, &gp); | 97 | retval = ext2fs_dir_iterate(fs, dir, 0, buf, get_pathname_proc, &gp); |
98 | if (retval) | 98 | if (retval) |
99 | goto cleanup; | 99 | goto cleanup; |
@@ -110,15 +110,15 @@ static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir, | |||
110 | *name = parent_name; | 110 | *name = parent_name; |
111 | return 0; | 111 | return 0; |
112 | } | 112 | } |
113 | 113 | ||
114 | if (gp.name) | 114 | if (gp.name) |
115 | retval = ext2fs_get_mem(strlen(parent_name)+strlen(gp.name)+2, | 115 | retval = ext2fs_get_mem(strlen(parent_name)+strlen(gp.name)+2, |
116 | &ret); | 116 | &ret); |
117 | else | 117 | else |
118 | retval = ext2fs_get_mem(strlen(parent_name)+5, &ret); | 118 | retval = ext2fs_get_mem(strlen(parent_name)+5, &ret); |
119 | if (retval) | 119 | if (retval) |
120 | goto cleanup; | 120 | goto cleanup; |
121 | 121 | ||
122 | ret[0] = 0; | 122 | ret[0] = 0; |
123 | if (parent_name[1]) | 123 | if (parent_name[1]) |
124 | strcat(ret, parent_name); | 124 | strcat(ret, parent_name); |
@@ -130,7 +130,7 @@ static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir, | |||
130 | *name = ret; | 130 | *name = ret; |
131 | ext2fs_free_mem(&parent_name); | 131 | ext2fs_free_mem(&parent_name); |
132 | retval = 0; | 132 | retval = 0; |
133 | 133 | ||
134 | cleanup: | 134 | cleanup: |
135 | if (gp.name) | 135 | if (gp.name) |
136 | ext2fs_free_mem(&gp.name); | 136 | ext2fs_free_mem(&gp.name); |
@@ -153,5 +153,5 @@ errcode_t ext2fs_get_pathname(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t ino, | |||
153 | retval = ext2fs_get_pathname_int(fs, dir, ino, 32, buf, name); | 153 | retval = ext2fs_get_pathname_int(fs, dir, ino, 32, buf, name); |
154 | ext2fs_free_mem(&buf); | 154 | ext2fs_free_mem(&buf); |
155 | return retval; | 155 | return retval; |
156 | 156 | ||
157 | } | 157 | } |