[uClibc]getcwd() on /coda

Ivan Popov pin at math.chalmers.se
Sun Oct 21 17:47:16 UTC 2001


Hello,

It looks like the test for non-slow search in getcwd.c passes under Linux,
but then it breaks on /coda as it has slightly different ideas about inode
numbers.

Setting it to always-slow fixes the problem. Anyway, it should be
probably a compile-time check (well, gcc hopefully optimizes it to a
constant, but some extra code still would be generated for no reason).

Proposal for patch:
-----------------------------------------------------------------------
*** uClibc/libc/unistd/getcwd.c.ori     Fri Apr  6 22:28:45 2001
--- uClibc/libc/unistd/getcwd.c Sun Oct 21 18:47:48 2001
***************
*** 78,90 ****
--- 78,95 ----
        char *ptr;
        int slen;

+ /* #undef FAST_DIR_SEARCH_POSSIBLE on Linux */
+ #ifdef FAST_DIR_SEARCH_POSSIBLE
        /* The test is for ELKS lib 0.0.9, this should be fixed in the
real kernel */
        int slow_search = (sizeof(ino_t) != sizeof(d->d_ino));
+ #endif

        if (stat(path_buf, &st) < 0)
                return 0;
+ #ifdef FAST_DIR_SEARCH_POSSIBLE
        if (this_dev != st.st_dev)
                slow_search = 1;
+ #endif

        slen = strlen(path_buf);
        ptr = path_buf + slen - 1;
***************
*** 103,109 ****
--- 108,116 ----
                return 0;

        while ((d = readdir(dp)) != 0) {
+ #ifdef FAST_DIR_SEARCH_POSSIBLE
                if (slow_search || this_ino == d->d_ino) {
+ #endif
                        if (slen + strlen(d->d_name) > path_size) {
                                __set_errno(ERANGE);
                                return 0;
***************
*** 115,121 ****
--- 122,130 ----
                                closedir(dp);
                                return path_buf;
                        }
+ #ifdef FAST_DIR_SEARCH_POSSIBLE
                }
+ #endif
        }

        closedir(dp);
-----------------------------------------------------------------------
Regards,
--
Ivan Popov <pin at math.chalmers.se>






More information about the uClibc mailing list