dirent on IRIX - d_type and d_fileno?
#1
dirent on IRIX - d_type and d_fileno?
Hey guys, 

Currently looking at porting NetBSD's patch and OpenBSD's diff to IRIX to replace its outdated GNU diff versions. 

One issue I'm running into is constant issues with IRIX's dirent implementation. In particular, its structs for it appear to lack certain members, namely:

d_type 
d_fileno 

For the first one, I found a stack overflow that suggested I try using stat instead:

https://stackoverflow.com/questions/3942...7#39430337

I have been studying that more. I wanted to get some clarification from others here on whether or not this is a good approach. The function using d_type and d_fileno is:

Code:
/*
* Do the actual diff by calling either diffreg() or diffdir().
*/
static void
diffit(struct dirent *dp, char *path1, size_t plen1, char *path2, size_t plen2,
    int flags)
{
        flags |= D_HEADER;
        strlcpy(path1 + plen1, dp->d_name, PATH_MAX - plen1);
        if (stat(path1, &stb1) != 0) {
                if (!(Nflag || Pflag) || errno != ENOENT) {
                        warn("%s", path1);
                        return;
                }
                flags |= D_EMPTY1;
                memset(&stb1, 0, sizeof(stb1));
        }

        strlcpy(path2 + plen2, dp->d_name, PATH_MAX - plen2);
        if (stat(path2, &stb2) != 0) {
                if (!Nflag || errno != ENOENT) {
                        warn("%s", path2);
                        return;
                }
                flags |= D_EMPTY2;
                memset(&stb2, 0, sizeof(stb2));
                stb2.st_mode = stb1.st_mode;
        }
        if (stb1.st_mode == 0)
                stb1.st_mode = stb2.st_mode;

        if (S_ISDIR(stb1.st_mode) && S_ISDIR(stb2.st_mode)) {
                if (rflag)
                        diffdir(path1, path2, flags);
                else
                        printf("Common subdirectories: %s and %s\n",
                            path1, path2);
                return;
        }
        if (!S_ISREG(stb1.st_mode) && !S_ISDIR(stb1.st_mode))
                dp->d_status = D_SKIPPED1;
        else if (!S_ISREG(stb2.st_mode) && !S_ISDIR(stb2.st_mode))
                dp->d_status = D_SKIPPED2;
        else
                dp->d_status = diffreg(path1, path2, flags);
        print_status(dp->d_status, path1, path2, "");
}

For those who want the complete file, it's here: https://raw.githubusercontent.com/openbs.../diffdir.c

I am trying to figure out a good way to translate this to IRIX. 

Other small things have been gathered that I'm working on, but this is the big one.

For those wondering why I chose OpenBSD's diff, it's small, simple and thus far has not required many major fixes to get it compiling.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,240
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
04-24-2021, 06:44 PM


Messages In This Thread
dirent on IRIX - d_type and d_fileno? - by Raion - 04-24-2021, 06:44 PM
RE: dirent on IRIX - d_type and d_fileno? - by vishnu - 04-25-2021, 03:30 AM
RE: dirent on IRIX - d_type and d_fileno? - by Raion - 04-25-2021, 03:52 AM
RE: dirent on IRIX - d_type and d_fileno? - by vishnu - 04-25-2021, 04:02 AM
RE: dirent on IRIX - d_type and d_fileno? - by Raion - 04-25-2021, 04:06 AM
RE: dirent on IRIX - d_type and d_fileno? - by vishnu - 04-25-2021, 04:26 AM
RE: dirent on IRIX - d_type and d_fileno? - by Raion - 04-25-2021, 04:31 AM
RE: dirent on IRIX - d_type and d_fileno? - by vishnu - 04-25-2021, 04:42 AM
RE: dirent on IRIX - d_type and d_fileno? - by Raion - 04-25-2021, 05:01 AM
RE: dirent on IRIX - d_type and d_fileno? - by vishnu - 04-25-2021, 05:07 AM
RE: dirent on IRIX - d_type and d_fileno? - by Raion - 04-25-2021, 02:03 PM
RE: dirent on IRIX - d_type and d_fileno? - by Raion - 04-25-2021, 04:05 PM
RE: dirent on IRIX - d_type and d_fileno? - by Raion - 04-25-2021, 04:32 PM
RE: dirent on IRIX - d_type and d_fileno? - by Raion - 04-25-2021, 05:30 PM
RE: dirent on IRIX - d_type and d_fileno? - by Raion - 04-26-2021, 05:01 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)