Previous  |  Next  >  
Product: File System Manual Pages for Storage Foundation   
Manual: Library Functions (3)   

vxfs_inotopath

NAME

vxfs_inotopath, vxfs_inotopath_gen - return path names for a given inode number

SYNOPSIS


cc -I /opt/VRTSvxfs/include -L /opt/VRTSvxfs/lib
-l vxfsutil -ldld

int vxfs_inotopath(char *mount_point, uint64_t inode_number,
int all, char ***bufp int *inentries)

int vxfs_inotopath_gen(char *mnt_pt, uint64_t inode_number, unint32_t inode_generation, int all, char ***bufp, int *nentries)

AVAILABILITY

VRTSvxfs

DESCRIPTION

vxfs_inotopath() returns one or all path names associated with the given inode number of a specified VxFS file system. The all argument must be 0 to obtain a single path name or 1 to obtain all path names.

mount_point specifies the file system mount point. Upon successful return, bufp points to a two-dimensional character pointer containing the path names and nentries contains the number of entries. Each entry of the returned two-dimensional array is MAXPATHLEN in size and must be freed by the calling application.

To use this function, specify -l vxfsutil while linking.

The vxfs_inotopath_gen() function is identical to the vxfs_inotopath() function, except that it uses an additional parameter, inode_generation. The vxfs_inotopath_gen() function returns one or more path names associated with the given inode number, if the inode_generation passed matches the current generation of the inode number. If the generations differ, it returns with an error.

NOTES

This function is supported only on Version 6 and later disk layouts.

RETURN VALUES

vxfs_inotopath() returns zero on success, non-zero on failure.

ERRORS

EFAULT

One or more of the specified pointer arguments points to an illegal address.

EINTR

A signal was caught during the execution of the operation.

EINVAL

The function is being used incorrectly or the arguments to the function could not be validated. This can occur for any of the following reasons:

      • mount_point is not a valid VxFS file system
      • mount_point is not a root inode
      • The inode number is larger than a 32-bit integer
      • File system stat information was unavailable
      • EMFILE

        OPEN_MAX file descriptors are currently open in the calling process.

        ENFILE

        The maximum number of files are open on the system.

        ENOMEM

        Sufficient memory could not be allocated to hold path names.

        ENOENT

        The specified inode number does not exist.

        ENOTSUP

        The file system disk layout version does not support this feature.

EXAMPLES

The following C source code is similar to the vxlsino command that uses vxfs_inotopath() to obtain path names.


/*
 * (c)  VERITAS Software Corporation. All rights reserved.
 */
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <inttypes.h>
static void     usage(void);
char            *cmd;
extern int      optind;
extern char     *optarg;
int
main(
        int     argc,
        char    **argv)
{
        uint64_t                inode;
        int                     c;
        int                     error, nentries, all = 0, i;
        char                    **bufp, *mountpath;
        cmd = argv[0];
        while ((c = getopt(argc, argv, "a")) != -1) {
                switch (c)  {
                case 'a':
                        all = 1;
                        break;
                default:
                        break;
                }
        }
        if ((argc - optind) != 2) {
                usage();
        }
        argc -= optind;
        argv = &argv[optind];
        sscanf(argv[0], "%lld", &inode);
        mountpath = argv[1];
        if (error = vxfs_inotopath(mountpath, inode, all, &bufp, &nentries)) {
                fprintf(stderr, "vxfs_inotopath: %s\n", strerror(error));
                exit(1);
        }
        for (i = 0; i < nentries; i++) {
                printf("%s\n", bufp[i]);
        }
        for (i = 0; i < nentries; i++) {
                free(bufp[i]);
        }
        free(bufp);
        exit(0);
}
void
usage(
        void)
{
        fprintf(stderr, "usage: %s [-a] <inode#> <mountpoint>\n", cmd);
        exit(1);
}

The following C source checks to see if the generation count matches with the generation of the inode number. If it does match, it returns a path name of the inode. If there are no matches, it returns with an error.


/*
 * (c)  VERITAS Software Corporation. All rights reserved.
 */
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <inttypes.h>
int main(
        int     argc,
        char    **argv)
{
        vx_u64_t                ino64;
        vx_u32_t                gen;
        int                     ret, nentries;
        char                    **bufp;
        gen = atoi(argv[3]);
        sscanf(argv[2], "%lld", &ino64);
        ret = vxfs_inotopath_gen(argv[1], ino64, gen, 0, &bufp, &nentries);
        if (ret == 0) {
           printf("%s\n", bufp[0]);
        }
        exit(ret);
}

SEE ALSO

vxlsino (1M)
 ^ Return to Top Previous  |  Next  >  
Product: File System Manual Pages for Storage Foundation  
Manual: Library Functions (3)  
VERITAS Software Corporation
www.veritas.com