1997-04-26 17:21:57 +04:00
|
|
|
/*
|
|
|
|
* namei.c --- ext2fs directory lookup operations
|
|
|
|
*
|
1997-04-29 20:17:09 +04:00
|
|
|
* Copyright (C) 1993, 1994, 1994, 1995 Theodore Ts'o.
|
|
|
|
*
|
|
|
|
* %Begin-Header%
|
|
|
|
* This file may be redistributed under the terms of the GNU Public
|
|
|
|
* License.
|
|
|
|
* %End-Header%
|
1997-04-26 17:21:57 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
1997-08-11 03:07:40 +04:00
|
|
|
#if HAVE_UNISTD_H
|
1997-04-26 17:21:57 +04:00
|
|
|
#include <unistd.h>
|
1997-08-11 03:07:40 +04:00
|
|
|
#endif
|
1997-04-26 17:34:30 +04:00
|
|
|
|
1997-04-29 18:53:37 +04:00
|
|
|
/* #define NAMEI_DEBUG */
|
|
|
|
|
Many files:
inode.c (ext2fs_open_inode_scan): Initialize the group variables
so that we don't need to call get_next_blockgroup() the first
time around. Saves a bit of time, and prevents us from
needing to assign -1 to current_group (which is an unsigned
value).
icount.c (insert_icount_el): Cast the estimated number of inodes
from a float to an ino_t.
alloc.c, alloc_tables.c, badlbocks.c, bb_compat.c, bb_inode.c,
bitmaps.c, bitops.c, block.c, bmap.c, bmove.c, brel_ma.c,
check_desc.c, closefs.c, cmp_bitmaps.c, dblist.c,
dblist_dir.c, dir_iterate.c, dirblock.c, dupfs.c, expanddir.c,
ext2fs.h, fileio.c, freefs.c, get_pathname.c, getsize.c,
icount.c, initialize.c, inline.c, inode.c, irel_ma.c,
ismounted.c, link.c, lookup.c, mkdir.c, namei.c, native.c,
newdir.c, openfs.c, read_bb.c, read_bb_file.c, rs_bitmap.c,
rw_bitmaps.c, swapfs.c, test_io.c, tst_badblocks.c,
tst_getsize.c, tst_iscan.c, unix_io.c, unlink.c, valid_blk.c,
version.c: If EXT2_FLAT_INCLUDES is defined, then assume all
of the ext2-specific header files are in a flat directory.
block.c, bmove.c, dirblock.c, fileio.c: Explicitly cast
all assignments from void * to be compatible with C++.
closefs.c (ext2fs_flush): Add a call to io_channel_flush() to
make sure the contents of the disk are flushed to disk.
dblist.c (ext2fs_add_dir_block): Change new to be new_entry to
avoid C++ namespace clash.
bitmaps.c (ext2fs_copy_bitmap): Change new to be new_map to
avoid C++ namespace clash.
ext2fs.h, bb_inode.c, block.c, bmove.c, brel.h, brel_ma.c,
irel.h, irel_ma.c, dblist.c, dblist_dir.c, dir_iterate.c,
ext2fsP.h, expanddir.c, get_pathname.c, inode.c, link.c,
unlink.c: Change private to be priv_data (to avoid C++
namespace clash)
1998-01-19 17:47:53 +03:00
|
|
|
#include "ext2_fs.h"
|
1997-04-26 17:21:57 +04:00
|
|
|
#include "ext2fs.h"
|
|
|
|
|
Many files:
alloc.c, bb_inode.c, bitmaps.c, bitops.h, block.c, bmap.c, bmove.c,
brel.h, cmp_bitmaps.c, dblist.c, dblist_dir.c, dir_iterate.c,
expanddir.c, ext2fs.h, ext2fsP.h, fileio.c, finddev.c, get_pathname.c,
icount.c, inode.c, irel.h, irel_ma.c, ismounted.c, link.c, lookup.c,
mkdir.c, mkjournal.c, namei.c, newdir.c, read_bb_file.c, test_io.c,
tst_iscan.c, unix_io.c, unlink.c: Change use of ino_t to ext2_ino_t,
to protect applications that attempt to compile
-D_FILE_OFFSET_BITS=64, since this inexplicably changes ino_t(!?). So
we use ext2_ino_t to avoid an unexpected ABI change.
2001-01-11 07:54:39 +03:00
|
|
|
static errcode_t open_namei(ext2_filsys fs, ext2_ino_t root, ext2_ino_t base,
|
Many files:
dosio.c: New file to do DOS/BIOS disk accesses.
namei.c (open_namei): Make pathlen be of type size_t.
llseek.c: Always #include stdlib.h since it's need to define
size_t.
io.h: Use errcode_t for magic numbers.
icount.c (get_icount_el), dupfs.c (ext2fs_dup_handle), dblist.c
(dir_block_cmp): Use size_t where appropriate.
read_bb.c (ext2fs_read_bb_inode), cmp_bitmaps.c
(ext2fs_compare_inode_bitmap): Use blk_t, ino_t and size_t
where appropriate.
closefs.c (ext2fs_flush): Use dgrp_t instead of int where
appropriate.
openfs.c (ext2fs_open), check_desc.c (ext2fs_check_desc): Use blk_t
instead of int where appropriate.
rw_bitmaps.c (read_bitmaps), irel_ma.c, inode.c (ext2fs_write_inode),
initialize.c (ext2fs_initialize): brel_ma.c: Fix to make be
16-bit safe.
link.c (ext2fs_link), unlink.c (ext2fs_unlink), lookup.c (lookup_proc),
ismounted.c (ext2fs_check_if_mounted), block.c (xlate_func):
Add #pragma argsused for Turbo C.
1997-08-12 00:29:22 +04:00
|
|
|
const char *pathname, size_t pathlen, int follow,
|
Many files:
alloc.c, bb_inode.c, bitmaps.c, bitops.h, block.c, bmap.c, bmove.c,
brel.h, cmp_bitmaps.c, dblist.c, dblist_dir.c, dir_iterate.c,
expanddir.c, ext2fs.h, ext2fsP.h, fileio.c, finddev.c, get_pathname.c,
icount.c, inode.c, irel.h, irel_ma.c, ismounted.c, link.c, lookup.c,
mkdir.c, mkjournal.c, namei.c, newdir.c, read_bb_file.c, test_io.c,
tst_iscan.c, unix_io.c, unlink.c: Change use of ino_t to ext2_ino_t,
to protect applications that attempt to compile
-D_FILE_OFFSET_BITS=64, since this inexplicably changes ino_t(!?). So
we use ext2_ino_t to avoid an unexpected ABI change.
2001-01-11 07:54:39 +03:00
|
|
|
int link_count, char *buf, ext2_ino_t *res_inode);
|
1997-04-29 18:53:37 +04:00
|
|
|
|
Many files:
alloc.c, bb_inode.c, bitmaps.c, bitops.h, block.c, bmap.c, bmove.c,
brel.h, cmp_bitmaps.c, dblist.c, dblist_dir.c, dir_iterate.c,
expanddir.c, ext2fs.h, ext2fsP.h, fileio.c, finddev.c, get_pathname.c,
icount.c, inode.c, irel.h, irel_ma.c, ismounted.c, link.c, lookup.c,
mkdir.c, mkjournal.c, namei.c, newdir.c, read_bb_file.c, test_io.c,
tst_iscan.c, unix_io.c, unlink.c: Change use of ino_t to ext2_ino_t,
to protect applications that attempt to compile
-D_FILE_OFFSET_BITS=64, since this inexplicably changes ino_t(!?). So
we use ext2_ino_t to avoid an unexpected ABI change.
2001-01-11 07:54:39 +03:00
|
|
|
static errcode_t follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t dir,
|
|
|
|
ext2_ino_t inode, int link_count,
|
|
|
|
char *buf, ext2_ino_t *res_inode)
|
1997-04-26 17:21:57 +04:00
|
|
|
{
|
1997-04-29 18:53:37 +04:00
|
|
|
char *pathname;
|
|
|
|
char *buffer = 0;
|
|
|
|
errcode_t retval;
|
|
|
|
struct ext2_inode ei;
|
1997-04-26 17:21:57 +04:00
|
|
|
|
1997-04-29 18:53:37 +04:00
|
|
|
#ifdef NAMEI_DEBUG
|
|
|
|
printf("follow_link: root=%lu, dir=%lu, inode=%lu, lc=%d\n",
|
|
|
|
root, dir, inode, link_count);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
retval = ext2fs_read_inode (fs, inode, &ei);
|
|
|
|
if (retval) return retval;
|
|
|
|
if (!LINUX_S_ISLNK (ei.i_mode)) {
|
|
|
|
*res_inode = inode;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (link_count++ > 5) {
|
|
|
|
return EXT2_ET_SYMLINK_LOOP;
|
|
|
|
}
|
2004-02-22 04:54:31 +03:00
|
|
|
if (ext2fs_inode_data_blocks(fs,&ei)) {
|
2003-08-01 17:41:07 +04:00
|
|
|
retval = ext2fs_get_mem(fs->blocksize, &buffer);
|
1997-10-26 06:41:24 +03:00
|
|
|
if (retval)
|
|
|
|
return retval;
|
1997-04-29 18:53:37 +04:00
|
|
|
retval = io_channel_read_blk(fs->io, ei.i_block[0], 1, buffer);
|
|
|
|
if (retval) {
|
2003-08-01 17:41:07 +04:00
|
|
|
ext2fs_free_mem(&buffer);
|
1997-04-29 18:53:37 +04:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
pathname = buffer;
|
|
|
|
} else
|
|
|
|
pathname = (char *)&(ei.i_block[0]);
|
|
|
|
retval = open_namei(fs, root, dir, pathname, ei.i_size, 1,
|
|
|
|
link_count, buf, res_inode);
|
|
|
|
if (buffer)
|
2003-08-01 17:41:07 +04:00
|
|
|
ext2fs_free_mem(&buffer);
|
1997-04-29 18:53:37 +04:00
|
|
|
return retval;
|
|
|
|
}
|
1997-04-26 17:34:30 +04:00
|
|
|
|
1997-04-29 18:53:37 +04:00
|
|
|
/*
|
|
|
|
* This routine interprets a pathname in the context of the current
|
|
|
|
* directory and the root directory, and returns the inode of the
|
|
|
|
* containing directory, and a pointer to the filename of the file
|
|
|
|
* (pointing into the pathname) and the length of the filename.
|
|
|
|
*/
|
Many files:
alloc.c, bb_inode.c, bitmaps.c, bitops.h, block.c, bmap.c, bmove.c,
brel.h, cmp_bitmaps.c, dblist.c, dblist_dir.c, dir_iterate.c,
expanddir.c, ext2fs.h, ext2fsP.h, fileio.c, finddev.c, get_pathname.c,
icount.c, inode.c, irel.h, irel_ma.c, ismounted.c, link.c, lookup.c,
mkdir.c, mkjournal.c, namei.c, newdir.c, read_bb_file.c, test_io.c,
tst_iscan.c, unix_io.c, unlink.c: Change use of ino_t to ext2_ino_t,
to protect applications that attempt to compile
-D_FILE_OFFSET_BITS=64, since this inexplicably changes ino_t(!?). So
we use ext2_ino_t to avoid an unexpected ABI change.
2001-01-11 07:54:39 +03:00
|
|
|
static errcode_t dir_namei(ext2_filsys fs, ext2_ino_t root, ext2_ino_t dir,
|
1997-04-29 18:53:37 +04:00
|
|
|
const char *pathname, int pathlen,
|
|
|
|
int link_count, char *buf,
|
Many files:
alloc.c, bb_inode.c, bitmaps.c, bitops.h, block.c, bmap.c, bmove.c,
brel.h, cmp_bitmaps.c, dblist.c, dblist_dir.c, dir_iterate.c,
expanddir.c, ext2fs.h, ext2fsP.h, fileio.c, finddev.c, get_pathname.c,
icount.c, inode.c, irel.h, irel_ma.c, ismounted.c, link.c, lookup.c,
mkdir.c, mkjournal.c, namei.c, newdir.c, read_bb_file.c, test_io.c,
tst_iscan.c, unix_io.c, unlink.c: Change use of ino_t to ext2_ino_t,
to protect applications that attempt to compile
-D_FILE_OFFSET_BITS=64, since this inexplicably changes ino_t(!?). So
we use ext2_ino_t to avoid an unexpected ABI change.
2001-01-11 07:54:39 +03:00
|
|
|
const char **name, int *namelen,
|
|
|
|
ext2_ino_t *res_inode)
|
1997-04-29 18:53:37 +04:00
|
|
|
{
|
|
|
|
char c;
|
|
|
|
const char *thisname;
|
|
|
|
int len;
|
Many files:
alloc.c, bb_inode.c, bitmaps.c, bitops.h, block.c, bmap.c, bmove.c,
brel.h, cmp_bitmaps.c, dblist.c, dblist_dir.c, dir_iterate.c,
expanddir.c, ext2fs.h, ext2fsP.h, fileio.c, finddev.c, get_pathname.c,
icount.c, inode.c, irel.h, irel_ma.c, ismounted.c, link.c, lookup.c,
mkdir.c, mkjournal.c, namei.c, newdir.c, read_bb_file.c, test_io.c,
tst_iscan.c, unix_io.c, unlink.c: Change use of ino_t to ext2_ino_t,
to protect applications that attempt to compile
-D_FILE_OFFSET_BITS=64, since this inexplicably changes ino_t(!?). So
we use ext2_ino_t to avoid an unexpected ABI change.
2001-01-11 07:54:39 +03:00
|
|
|
ext2_ino_t inode;
|
1997-04-29 18:53:37 +04:00
|
|
|
errcode_t retval;
|
|
|
|
|
|
|
|
if ((c = *pathname) == '/') {
|
|
|
|
dir = root;
|
|
|
|
pathname++;
|
|
|
|
pathlen--;
|
1997-04-26 17:21:57 +04:00
|
|
|
}
|
1997-04-29 18:53:37 +04:00
|
|
|
while (1) {
|
|
|
|
thisname = pathname;
|
|
|
|
for (len=0; --pathlen >= 0;len++) {
|
|
|
|
c = *(pathname++);
|
|
|
|
if (c == '/')
|
|
|
|
break;
|
1997-04-26 17:21:57 +04:00
|
|
|
}
|
1997-04-29 18:53:37 +04:00
|
|
|
if (pathlen < 0)
|
1997-04-26 17:21:57 +04:00
|
|
|
break;
|
1997-04-29 18:53:37 +04:00
|
|
|
retval = ext2fs_lookup (fs, dir, thisname, len, buf, &inode);
|
|
|
|
if (retval) return retval;
|
|
|
|
retval = follow_link (fs, root, dir, inode,
|
|
|
|
link_count, buf, &dir);
|
|
|
|
if (retval) return retval;
|
|
|
|
}
|
|
|
|
*name = thisname;
|
|
|
|
*namelen = len;
|
|
|
|
*res_inode = dir;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Many files:
alloc.c, bb_inode.c, bitmaps.c, bitops.h, block.c, bmap.c, bmove.c,
brel.h, cmp_bitmaps.c, dblist.c, dblist_dir.c, dir_iterate.c,
expanddir.c, ext2fs.h, ext2fsP.h, fileio.c, finddev.c, get_pathname.c,
icount.c, inode.c, irel.h, irel_ma.c, ismounted.c, link.c, lookup.c,
mkdir.c, mkjournal.c, namei.c, newdir.c, read_bb_file.c, test_io.c,
tst_iscan.c, unix_io.c, unlink.c: Change use of ino_t to ext2_ino_t,
to protect applications that attempt to compile
-D_FILE_OFFSET_BITS=64, since this inexplicably changes ino_t(!?). So
we use ext2_ino_t to avoid an unexpected ABI change.
2001-01-11 07:54:39 +03:00
|
|
|
static errcode_t open_namei(ext2_filsys fs, ext2_ino_t root, ext2_ino_t base,
|
Many files:
dosio.c: New file to do DOS/BIOS disk accesses.
namei.c (open_namei): Make pathlen be of type size_t.
llseek.c: Always #include stdlib.h since it's need to define
size_t.
io.h: Use errcode_t for magic numbers.
icount.c (get_icount_el), dupfs.c (ext2fs_dup_handle), dblist.c
(dir_block_cmp): Use size_t where appropriate.
read_bb.c (ext2fs_read_bb_inode), cmp_bitmaps.c
(ext2fs_compare_inode_bitmap): Use blk_t, ino_t and size_t
where appropriate.
closefs.c (ext2fs_flush): Use dgrp_t instead of int where
appropriate.
openfs.c (ext2fs_open), check_desc.c (ext2fs_check_desc): Use blk_t
instead of int where appropriate.
rw_bitmaps.c (read_bitmaps), irel_ma.c, inode.c (ext2fs_write_inode),
initialize.c (ext2fs_initialize): brel_ma.c: Fix to make be
16-bit safe.
link.c (ext2fs_link), unlink.c (ext2fs_unlink), lookup.c (lookup_proc),
ismounted.c (ext2fs_check_if_mounted), block.c (xlate_func):
Add #pragma argsused for Turbo C.
1997-08-12 00:29:22 +04:00
|
|
|
const char *pathname, size_t pathlen, int follow,
|
Many files:
alloc.c, bb_inode.c, bitmaps.c, bitops.h, block.c, bmap.c, bmove.c,
brel.h, cmp_bitmaps.c, dblist.c, dblist_dir.c, dir_iterate.c,
expanddir.c, ext2fs.h, ext2fsP.h, fileio.c, finddev.c, get_pathname.c,
icount.c, inode.c, irel.h, irel_ma.c, ismounted.c, link.c, lookup.c,
mkdir.c, mkjournal.c, namei.c, newdir.c, read_bb_file.c, test_io.c,
tst_iscan.c, unix_io.c, unlink.c: Change use of ino_t to ext2_ino_t,
to protect applications that attempt to compile
-D_FILE_OFFSET_BITS=64, since this inexplicably changes ino_t(!?). So
we use ext2_ino_t to avoid an unexpected ABI change.
2001-01-11 07:54:39 +03:00
|
|
|
int link_count, char *buf, ext2_ino_t *res_inode)
|
1997-04-29 18:53:37 +04:00
|
|
|
{
|
|
|
|
const char *basename;
|
|
|
|
int namelen;
|
Many files:
alloc.c, bb_inode.c, bitmaps.c, bitops.h, block.c, bmap.c, bmove.c,
brel.h, cmp_bitmaps.c, dblist.c, dblist_dir.c, dir_iterate.c,
expanddir.c, ext2fs.h, ext2fsP.h, fileio.c, finddev.c, get_pathname.c,
icount.c, inode.c, irel.h, irel_ma.c, ismounted.c, link.c, lookup.c,
mkdir.c, mkjournal.c, namei.c, newdir.c, read_bb_file.c, test_io.c,
tst_iscan.c, unix_io.c, unlink.c: Change use of ino_t to ext2_ino_t,
to protect applications that attempt to compile
-D_FILE_OFFSET_BITS=64, since this inexplicably changes ino_t(!?). So
we use ext2_ino_t to avoid an unexpected ABI change.
2001-01-11 07:54:39 +03:00
|
|
|
ext2_ino_t dir, inode;
|
1997-04-29 18:53:37 +04:00
|
|
|
errcode_t retval;
|
|
|
|
|
|
|
|
#ifdef NAMEI_DEBUG
|
|
|
|
printf("open_namei: root=%lu, dir=%lu, path=%*s, lc=%d\n",
|
|
|
|
root, base, pathlen, pathname, link_count);
|
|
|
|
#endif
|
|
|
|
retval = dir_namei(fs, root, base, pathname, pathlen,
|
|
|
|
link_count, buf, &basename, &namelen, &dir);
|
|
|
|
if (retval) return retval;
|
|
|
|
if (!namelen) { /* special case: '/usr/' etc */
|
|
|
|
*res_inode=dir;
|
|
|
|
return 0;
|
1997-04-26 17:21:57 +04:00
|
|
|
}
|
1997-04-29 18:53:37 +04:00
|
|
|
retval = ext2fs_lookup (fs, dir, basename, namelen, buf, &inode);
|
|
|
|
if (retval)
|
|
|
|
return retval;
|
|
|
|
if (follow) {
|
|
|
|
retval = follow_link(fs, root, dir, inode, link_count,
|
|
|
|
buf, &inode);
|
|
|
|
if (retval)
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
#ifdef NAMEI_DEBUG
|
|
|
|
printf("open_namei: (link_count=%d) returns %lu\n",
|
|
|
|
link_count, inode);
|
|
|
|
#endif
|
|
|
|
*res_inode = inode;
|
1997-04-26 17:21:57 +04:00
|
|
|
return 0;
|
|
|
|
}
|
1997-04-29 18:53:37 +04:00
|
|
|
|
Many files:
alloc.c, bb_inode.c, bitmaps.c, bitops.h, block.c, bmap.c, bmove.c,
brel.h, cmp_bitmaps.c, dblist.c, dblist_dir.c, dir_iterate.c,
expanddir.c, ext2fs.h, ext2fsP.h, fileio.c, finddev.c, get_pathname.c,
icount.c, inode.c, irel.h, irel_ma.c, ismounted.c, link.c, lookup.c,
mkdir.c, mkjournal.c, namei.c, newdir.c, read_bb_file.c, test_io.c,
tst_iscan.c, unix_io.c, unlink.c: Change use of ino_t to ext2_ino_t,
to protect applications that attempt to compile
-D_FILE_OFFSET_BITS=64, since this inexplicably changes ino_t(!?). So
we use ext2_ino_t to avoid an unexpected ABI change.
2001-01-11 07:54:39 +03:00
|
|
|
errcode_t ext2fs_namei(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd,
|
|
|
|
const char *name, ext2_ino_t *inode)
|
1997-04-29 18:53:37 +04:00
|
|
|
{
|
|
|
|
char *buf;
|
|
|
|
errcode_t retval;
|
|
|
|
|
|
|
|
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
|
|
|
|
|
2003-08-01 17:41:07 +04:00
|
|
|
retval = ext2fs_get_mem(fs->blocksize, &buf);
|
1997-10-26 06:41:24 +03:00
|
|
|
if (retval)
|
|
|
|
return retval;
|
1997-04-29 18:53:37 +04:00
|
|
|
|
|
|
|
retval = open_namei(fs, root, cwd, name, strlen(name), 0, 0,
|
|
|
|
buf, inode);
|
|
|
|
|
2003-08-01 17:41:07 +04:00
|
|
|
ext2fs_free_mem(&buf);
|
1997-04-29 18:53:37 +04:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
Many files:
alloc.c, bb_inode.c, bitmaps.c, bitops.h, block.c, bmap.c, bmove.c,
brel.h, cmp_bitmaps.c, dblist.c, dblist_dir.c, dir_iterate.c,
expanddir.c, ext2fs.h, ext2fsP.h, fileio.c, finddev.c, get_pathname.c,
icount.c, inode.c, irel.h, irel_ma.c, ismounted.c, link.c, lookup.c,
mkdir.c, mkjournal.c, namei.c, newdir.c, read_bb_file.c, test_io.c,
tst_iscan.c, unix_io.c, unlink.c: Change use of ino_t to ext2_ino_t,
to protect applications that attempt to compile
-D_FILE_OFFSET_BITS=64, since this inexplicably changes ino_t(!?). So
we use ext2_ino_t to avoid an unexpected ABI change.
2001-01-11 07:54:39 +03:00
|
|
|
errcode_t ext2fs_namei_follow(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd,
|
|
|
|
const char *name, ext2_ino_t *inode)
|
1997-04-29 18:53:37 +04:00
|
|
|
{
|
|
|
|
char *buf;
|
|
|
|
errcode_t retval;
|
|
|
|
|
|
|
|
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
|
|
|
|
|
2003-08-01 17:41:07 +04:00
|
|
|
retval = ext2fs_get_mem(fs->blocksize, &buf);
|
1997-10-26 06:41:24 +03:00
|
|
|
if (retval)
|
|
|
|
return retval;
|
1997-04-29 18:53:37 +04:00
|
|
|
|
|
|
|
retval = open_namei(fs, root, cwd, name, strlen(name), 1, 0,
|
|
|
|
buf, inode);
|
|
|
|
|
2003-08-01 17:41:07 +04:00
|
|
|
ext2fs_free_mem(&buf);
|
1997-04-29 18:53:37 +04:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
Many files:
alloc.c, bb_inode.c, bitmaps.c, bitops.h, block.c, bmap.c, bmove.c,
brel.h, cmp_bitmaps.c, dblist.c, dblist_dir.c, dir_iterate.c,
expanddir.c, ext2fs.h, ext2fsP.h, fileio.c, finddev.c, get_pathname.c,
icount.c, inode.c, irel.h, irel_ma.c, ismounted.c, link.c, lookup.c,
mkdir.c, mkjournal.c, namei.c, newdir.c, read_bb_file.c, test_io.c,
tst_iscan.c, unix_io.c, unlink.c: Change use of ino_t to ext2_ino_t,
to protect applications that attempt to compile
-D_FILE_OFFSET_BITS=64, since this inexplicably changes ino_t(!?). So
we use ext2_ino_t to avoid an unexpected ABI change.
2001-01-11 07:54:39 +03:00
|
|
|
errcode_t ext2fs_follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd,
|
|
|
|
ext2_ino_t inode, ext2_ino_t *res_inode)
|
1997-04-29 18:53:37 +04:00
|
|
|
{
|
|
|
|
char *buf;
|
|
|
|
errcode_t retval;
|
|
|
|
|
|
|
|
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
|
|
|
|
|
2003-08-01 17:41:07 +04:00
|
|
|
retval = ext2fs_get_mem(fs->blocksize, &buf);
|
1997-10-26 06:41:24 +03:00
|
|
|
if (retval)
|
|
|
|
return retval;
|
|
|
|
|
1997-04-29 18:53:37 +04:00
|
|
|
retval = follow_link(fs, root, cwd, inode, 0, buf, res_inode);
|
|
|
|
|
2003-08-01 17:41:07 +04:00
|
|
|
ext2fs_free_mem(&buf);
|
1997-04-29 18:53:37 +04:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|