Sem_open sets ENAMETOOLONG for names less than 64 characters on Mac OS X 10.6.6 HFS +

in our college project, the following challenge is made:

sem_t * handle = sem_open ("/ 6770 :: BitCompressedVector :: allocate", 512, 420, 1);

As the name indicates, errno is set to ENAMETOOLONG, indicating that the first parameter (name) either exceeds PATH_MAX (1024 characters) or the path component exceeds NAME_MAX (255 characters).

The binary is executed over a long path 62 characters long. Reducing the path length to 14 characters did not help. When using "/ 6770 :: B :: a" everything is in order. But this is not a solution for us.

I am using Mac OS X 10.6.6 with an HFS + volume and Xcode 3.2.6 Developer Toolkit. On my MacBooks team (Mac OS X 10.6.x, HFS +) and our Ubuntu 10.10 ext4, the code works without errors.

What is the reason for the different behavior in my system? Is there a workaround that does not need to change the code?

+3
source share
1 answer

The Os X man page for sem_openstates:

Name

[ENAMETOOLONG] has exceeded SEM_NAME_LEN.

I don't have this OS, but google seems to indicate it SEM_NAME_LENwill be 31.

+2
source

All Articles