Skip to content

Commit f824562

Browse files
authored
Merge pull request #212 from SHA2017-badge/basvs-chdir-fix
allow chdir to mountpoints ('/', '/sdcard' and '/bpp')
2 parents 09fed6f + fa5965c commit f824562

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

extmod/vfs_native.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,21 @@ int
3333
chdir(const char *path)
3434
{
3535
struct stat buf;
36+
37+
// root mount-point is special-case.
38+
if (strcmp(path, "/") == 0) {
39+
cwd[0] = 0;
40+
ESP_LOGD(TAG, "cwd set to '/'");
41+
return 0;
42+
}
43+
44+
// other mount-points are special as well.
45+
if (strcmp(path, "/sdcard") == 0 || strcmp(path, "/bpp") == 0) {
46+
strncpy(cwd, path, sizeof(cwd));
47+
ESP_LOGD(TAG, "cwd set to '%s'", cwd);
48+
return 0;
49+
}
50+
3651
int res = stat(path, &buf);
3752
if (res < 0) {
3853
return -1;

0 commit comments

Comments
 (0)