Skip to content

_getcwdux() return the cwd including the drive name when a buffer is passed #184

Description

@komh

Hi/2.

Describe the bug

_getcwdux() should return the cwd excluding the drive name all the time. However, it returns the cwd including the drive name when a buffer is passed. It works as expected when NULL is passed.

To Reproduce

See https://github.com/komh/klibctest/blob/master/io/_getcwdux-1.c

Expected behavior

_getcwdux() should return the cwd excluding the drive name even if a buffer is passed.

Here is the patch:

0001-_getcwdux-Fix-_getcwdux-return-the-cwd-including-the.patch

From 1a524944cb32b06d89782d8669ff17e1f708133b Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh78@gmail.com>
Date: Mon, 22 Jun 2026 20:02:44 +0900
Subject: [PATCH] _getcwdux: Fix _getcwdux() return the cwd including the drive
 name

_getcwdux() should always return the cwd excluding the drive name.
However, it returns the cwd including the drive name when a buffer is
passed. It works as expected when NULL is passed.
---
 src/emx/src/lib/misc/_getcwdux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/emx/src/lib/misc/_getcwdux.c b/src/emx/src/lib/misc/_getcwdux.c
index db3a7de..f259dce 100644
--- a/src/emx/src/lib/misc/_getcwdux.c
+++ b/src/emx/src/lib/misc/_getcwdux.c
@@ -104,7 +104,7 @@ char *_getcwdux(char *buf, size_t bufsize)
     }
     else
     {
-        rc = __libc_Back_fsDirCurrentGet(buf, bufsize, 0, 0);
+        rc = __libc_Back_fsDirCurrentGet(buf, bufsize, 0, __LIBC_BACK_FSCWD_NO_DRIVE);
         if (!rc)
         {
             /*
-- 
2.50.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions