# Syscall(mknod) is incorrectly successful on ppc systems

**URL:** <https://travis-ci.community/t/syscall-mknod-is-incorrectly-successful-on-ppc-systems/9713>\
**Category:** Multi CPU Architecture\
**Tags:** bug\
**Created:** [August 24, 2020, 8:26pm UTC](https://travis-ci.community/t/syscall-mknod-is-incorrectly-successful-on-ppc-systems/9713 "2020-08-24T20:26:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AkosUzonyi](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/akosuzonyi/32/5390_2.png) [@AkosUzonyi](https://travis-ci.community/u/AkosUzonyi)\
**Post date:** [August 24, 2020, 8:26pm UTC](https://travis-ci.community/t/syscall-mknod-is-incorrectly-successful-on-ppc-systems/9713/1 "2020-08-24T20:26:22Z")

</div>

On PowerPC systems the following short check fails:

```
errno = 0;

unsigned long dev = 0xfacefeed00000000ULL | makedev(1, 7);
syscall(__NR_mknod, "/", S_IFCHR | 0777, dev);

if (errno != EEXIST) {
	perror("mknod");
	exit(1);
}

```

(see github repository: [1])

On ppc mknod is successful, but it should fail with EEXISTS (as “/” exists). Other architectures are fine [2].

If 0xfacefeed00000000ULL magic is removed from dev, the check passes on pcc too. Although the choice of this dev value might seem irrational, this kind of or-ing is frequently used is strace tests, where mknod test started failing about a week ago [3].

[1] [https://github.com/AkosUzonyi/travis-ppc-bugreport](https://github.com/AkosUzonyi/travis-ppc-bugreport)  
[2] [https://travis-ci.org/github/AkosUzonyi/travis-ppc-bugreport/builds/720778638](https://travis-ci.org/github/AkosUzonyi/travis-ppc-bugreport/builds/720778638)  
[3] [https://travis-ci.com/github/strace/strace/builds](https://travis-ci.com/github/strace/strace/builds)

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [October 23, 2020, 11:45pm UTC](https://travis-ci.community/t/syscall-mknod-is-incorrectly-successful-on-ppc-systems/9713/2 "2020-10-23T23:45:27Z")

</div>

[WFM](https://travis-ci.com/github/native-api/test_travis/builds/192437124) with below code.

Setting `errno = 0` and not checking the return code of `syscall` looks like the problem.

```auto
#include <errno.h>
#include <stdio.h>
#include <sys/sysmacros.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>

int main(void)
{
	dev_t dev = 0xfacefeed00000000ULL | makedev(1, 7);

	if (syscall(__NR_mknod, "/", S_IFCHR | 0777, dev)) {
		perror("mknod");
		return 0;
	}

	return 1;
}

```

---

<div class="post-metadata">

**Author:** ![AkosUzonyi](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/akosuzonyi/32/5390_2.png) [@AkosUzonyi](https://travis-ci.community/u/AkosUzonyi)\
**Post date:** [October 24, 2020, 8:32am UTC](https://travis-ci.community/t/syscall-mknod-is-incorrectly-successful-on-ppc-systems/9713/3 "2020-10-24T08:32:40Z")

</div>

Thanks, but the problem is fixed now, so both version work 🙂 (although I didn’t check the return value in my code above, it was 0, so checking it wouldn’t have helped either).

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [October 24, 2020, 12:36pm UTC](https://travis-ci.community/t/syscall-mknod-is-incorrectly-successful-on-ppc-systems/9713/4 "2020-10-24T12:36:05Z")

</div>

The thing is, the original version didn’t work for me, even locally 🙂

---

<div class="post-metadata">

**Author:** ![AkosUzonyi](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/akosuzonyi/32/5390_2.png) [@AkosUzonyi](https://travis-ci.community/u/AkosUzonyi)\
**Post date:** [October 24, 2020, 1:59pm UTC](https://travis-ci.community/t/syscall-mknod-is-incorrectly-successful-on-ppc-systems/9713/5 "2020-10-24T13:59:18Z")

</div>

That’s interesting. I suspect it didn’t work because on your system errno isn’t set to EEXISTS as expected, but for example EPERM. That can be also a correct behaviour. However in the past on ppc travis systems errno was ESUCCESS which is clearly not acceptable.
