getcwd syscall fails on 3rd subfolder

Chris Johns chrisj at rtems.org
Wed Apr 9 01:06:24 UTC 2014


On 8/04/2014 10:22 pm, Hoefle Marco wrote:
> Hello,
> we use the Gaisler RTEMS Kernel 4-10-1.2.14 on a GR712RC board.

I have not used their version or hardware.

> The following function is used to  determine the current working
> directory on a fatfs:
>
>
> static NtsError fs_pwd_do( int argc, char **argv)
> {
>          char *ret = getcwd(NULL, 0);
>          if(ret) {
>                  nts_printf("%s\n", ret);
>                  free(ret);
>                  return NTS_OK;
>          }
>
>          nts_printf("getcwd failed, errno: %d, MAXPATHLEN: %d\n", errno,
> MAXPATHLEN);
>          return NTS_FAILURE;
> }
>
>
> The fatfs was generated using:
>          @dd if=/dev/zero of=$(NAME) bs=256 count=1024 > /dev/null
>          /sbin/mkfs.vfat -F 12 -S 512 -s 1 -r 512 -f 1 -v $(NAME)
>
>
> This is what happens:
>
> cassis> fs mount
> RAM Disk registered
> mount return: 0
> ram disk addr: 0x64000000

This would seem to be a root disk. Is this an IMFS disk or a RAM disk ?

> cassis> fs ls
> 3920 dev
> 16384 mnt
> cassis> fs pwd
> /
> cassis> fs cwd mnt
> changed to mnt
> cassis> fs pwd
> /mnt
> cassis> fs ls
> 512 template
> cassis> fs cwd template
> changed to template
> cassis> fs pwd
> /mnt/template
> cassis>
> cassis> fs ls
> 512 .
> 16384 ..
> 512 param
> 512 logs
> cassis> fs cwd logs
> changed to logs
> cassis> fs pwd
> getcwd failed, errno: 2, MAXPATHLEN: 1024

The getcwd code looks up the path to the parent until the root to build 
the path. There maybe something wrong here if the root is not IMFS.

Chris

> cassis>
>
>
> The folder logs is definitely existing:
> cassis> fs dump /mnt/template/logs/housekeeping/log0
> file size: 10
> 64 61 63 30 3a 20 31 30 30 0a
>
> A non existing file leeds to:
> cassis> fs dump /mnt/template/logs/housekeeping/log9
> file size: 10
> failure, ret: -1, errno: 2
>
> Has anybody an idea why getcwd() fails (errno 2 means not existent)?
>
> Cheers,
> Marco
>
>
>
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-users
>



More information about the users mailing list