chmod() is no longer implemented?
Posted: Thu Aug 08, 2024 10:54 am
I needed some additional functionality to what the framework implementation of lib linenoise offered. In my adaption I used a function call to chmod when storing the history file. All compiled well up to and including espidf 5.2. However, with espidf 5.3 I get linker errors:
Commenting out the call to chmod() results in clean linking. Why is this? How can I fix that and still use chmod as a call. The code in question is:
Code: Select all
Creating esp32s3 image...
Merged 2 ELF sections
Successfully created esp32s3 image.
Linking .pio/build/BCD-0o26-5KY/firmware.elf
/Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: .pio/build/BCD-0o26-5KY/esp-idf/ch405labs_linenoise/libch405labs_linenoise.a(ch405labs_linenoise.c.o):(.literal.ch405_labs_linenoiseHistorySave+0x1c): warning: chmod is not implemented and will always fail
/Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: .pio/build/BCD-0o26-5KY/esp-idf/mbedtls/mbedtls/library/libmbedx509.a(x509_crt.c.o):(.literal.mbedtls_x509_crt_parse_path+0x28): warning: readdir is not implemented and will always fail
/Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: .pio/build/BCD-0o26-5KY/esp-idf/mbedtls/mbedtls/library/libmbedx509.a(x509_crt.c.o):(.literal.mbedtls_x509_crt_parse_path+0x2c): warning: closedir is not implemented and will always fail
/Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: .pio/build/BCD-0o26-5KY/esp-idf/mbedtls/mbedtls/library/libmbedx509.a(x509_crt.c.o):(.literal.mbedtls_x509_crt_parse_path+0x10): warning: opendir is not implemented and will always fail
/Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: /Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/lib/esp32s3/libnosys.a(dir.o): in function `opendir':
/Users/brnomac003/.gitlab-runner/builds/qR2TxTby/0/idf/crosstool-NG/.build/xtensa-esp-elf/src/newlib/libgloss/libnosys/dir.c:16: multiple definition of `opendir'; .pio/build/BCD-0o26-5KY/esp-idf/vfs/libvfs.a(vfs.c.o):/Users/fschuetz/.platformio/packages/framework-espidf/components/vfs/vfs.c:733: first defined here
/Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: /Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/lib/esp32s3/libnosys.a(dir.o): in function `closedir':
/Users/brnomac003/.gitlab-runner/builds/qR2TxTby/0/idf/crosstool-NG/.build/src/newlib-git-7cdcb0b0/newlib/libc/include/dirent.h:76: multiple definition of `closedir'; .pio/build/BCD-0o26-5KY/esp-idf/vfs/libvfs.a(vfs.c.o):/Users/fschuetz/.platformio/packages/framework-espidf/components/vfs/vfs.c:805: first defined here
/Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: /Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/lib/esp32s3/libnosys.a(dir.o): in function `mkdir':
/Users/brnomac003/.gitlab-runner/builds/qR2TxTby/0/idf/crosstool-NG/.build/xtensa-esp-elf/src/newlib/libgloss/libnosys/dir.c:30: multiple definition of `mkdir'; .pio/build/BCD-0o26-5KY/esp-idf/vfs/libvfs.a(vfs.c.o):/Users/fschuetz/.platformio/packages/framework-espidf/components/vfs/vfs.c:818: first defined here
/Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: /Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/lib/esp32s3/libnosys.a(dir.o): in function `readdir':
/Users/brnomac003/.gitlab-runner/builds/qR2TxTby/0/idf/crosstool-NG/.build/src/newlib-git-7cdcb0b0/newlib/libc/include/dirent.h:56: multiple definition of `readdir'; .pio/build/BCD-0o26-5KY/esp-idf/vfs/libvfs.a(vfs.c.o):/Users/fschuetz/.platformio/packages/framework-espidf/components/vfs/vfs.c:750: first defined here
/Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: /Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/lib/esp32s3/libnosys.a(dir.o): in function `telldir':
/Users/brnomac003/.gitlab-runner/builds/qR2TxTby/0/idf/crosstool-NG/.build/src/newlib-git-7cdcb0b0/newlib/libc/include/dirent.h:73: multiple definition of `telldir'; .pio/build/BCD-0o26-5KY/esp-idf/vfs/libvfs.a(vfs.c.o):/Users/fschuetz/.platformio/packages/framework-espidf/components/vfs/vfs.c:776: first defined here
/Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: /Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/lib/esp32s3/libnosys.a(dir.o): in function `seekdir':
/Users/brnomac003/.gitlab-runner/builds/qR2TxTby/0/idf/crosstool-NG/.build/xtensa-esp-elf/src/newlib/libgloss/libnosys/dir.c:73: multiple definition of `seekdir'; .pio/build/BCD-0o26-5KY/esp-idf/vfs/libvfs.a(vfs.c.o):/Users/fschuetz/.platformio/packages/framework-espidf/components/vfs/vfs.c:789: first defined here
/Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: /Users/fschuetz/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/lib/esp32s3/libnosys.a(dir.o): in function `rewinddir':
/Users/brnomac003/.gitlab-runner/builds/qR2TxTby/0/idf/crosstool-NG/.build/xtensa-esp-elf/src/newlib/libgloss/libnosys/dir.c:101: multiple definition of `rewinddir'; .pio/build/BCD-0o26-5KY/esp-idf/vfs/libvfs.a(vfs.c.o):/Users/fschuetz/.platformio/packages/framework-espidf/components/vfs/vfs.c:800: first defined here
collect2: error: ld returned 1 exit status
*** [.pio/build/BCD-0o26-5KY/firmware.elf] Error 1
Code: Select all
/* Save the history in the specified file. On success 0 is returned
* otherwise -1 is returned. */
int ch405_labs_linenoiseHistorySave(const char *filename) {
mode_t old_umask = umask(S_IXUSR|S_IRWXG|S_IRWXO);
FILE *fp;
int j;
fp = fopen(filename,"w");
umask(old_umask);
if (fp == NULL) return -1;
chmod(filename,S_IRUSR|S_IWUSR);
for (j = 0; j < history_len; j++)
fprintf(fp,"%s\n",history[j]);
fclose(fp);
return 0;
}