Hi Stefan,
On 2/4/26 2:21 AM, Stefan Berger wrote:
> So this file comes originally from swtpm here:
> https://github.com/stefanberger/swtpm/blob/master/include/swtpm/tpm_ioctl.h
>
> To keep them in sync as much as possible -- would this here work?
>
> #ifndef _WIN32
> #include <sys/uio.h>
> #include <sys/ioctl.h>
> #endif
>
> #ifdef HAVE_SYS_IOCCOM_H
> #include <sys/ioccom.h>
> #endif
>
> #ifdef __gnu_hurd__
> #include <mach/x86_64/ioccom.h>
> #endif
>
> and then keep this as-is?
>
> #if !defined(_WIN32)
> enum {
> PTM_GET_CAPABILITY = _IOR('P', 0, ptm_cap),
> PTM_INIT = _IOWR('P', 1, ptm_init),
> PTM_SHUTDOWN = _IOR('P', 2, ptm_res),
No, this wont work because the _IOT__IOTBASE_* symbols are missing for
the tpm structs on GNU platform:
In file included from /usr/include/x86_64-gnu/sys/ioctl.h:26,
from ../backends/tpm/tpm_ioctl.h:17,
from ../backends/tpm/tpm_emulator.c:39:
../backends/tpm/tpm_ioctl.h:290:30: error: ‘_IOT__IOTBASE_ptm_cap’
undeclared here (not in a function)
290 | PTM_GET_CAPABILITY = _IOR('P', 0, ptm_cap),
| ^~~~
../backends/tpm/tpm_ioctl.h:291:30: error: ‘_IOT__IOTBASE_ptm_init’
undeclared here (not in a function)
291 | PTM_INIT = _IOWR('P', 1, ptm_init),
| ^~~~~
../backends/tpm/tpm_ioctl.h:292:30: error: ‘_IOT__IOTBASE_ptm_res’
undeclared here (not in a function)
292 | PTM_SHUTDOWN = _IOR('P', 2, ptm_res),
| ^~~~
../backends/tpm/tpm_ioctl.h:293:30: error: ‘_IOT__IOTBASE_ptm_est’
undeclared here (not in a function)
293 | PTM_GET_TPMESTABLISHED = _IOR('P', 3, ptm_est),
| ^~~~
../backends/tpm/tpm_ioctl.h:294:30: error: ‘_IOT__IOTBASE_ptm_loc’
undeclared here (not in a function)
294 | PTM_SET_LOCALITY = _IOWR('P', 4, ptm_loc),
| ^~~~~
../backends/tpm/tpm_ioctl.h:296:30: error: ‘_IOT__IOTBASE_ptm_hdata’
undeclared here (not in a function)
296 | PTM_HASH_DATA = _IOWR('P', 6, ptm_hdata),
| ^~~~~
../backends/tpm/tpm_ioctl.h:300:32: error: ‘_IOT__IOTBASE_ptm_reset_est’
undeclared here (not in a function)
300 | PTM_RESET_TPMESTABLISHED = _IOWR('P', 10, ptm_reset_est),
| ^~~~~
../backends/tpm/tpm_ioctl.h:301:30: error: ‘_IOT__IOTBASE_ptm_getstate’
undeclared here (not in a function)
301 | PTM_GET_STATEBLOB = _IOWR('P', 11, ptm_getstate),
| ^~~~~
../backends/tpm/tpm_ioctl.h:302:30: error: ‘_IOT__IOTBASE_ptm_setstate’
undeclared here (not in a function)
302 | PTM_SET_STATEBLOB = _IOWR('P', 12, ptm_setstate),
| ^~~~~
../backends/tpm/tpm_ioctl.h:304:30: error: ‘_IOT__IOTBASE_ptm_getconfig’
undeclared here (not in a function)
304 | PTM_GET_CONFIG = _IOR('P', 14, ptm_getconfig),
| ^~~~
../backends/tpm/tpm_ioctl.h:306:30: error:
‘_IOT__IOTBASE_ptm_setbuffersize’ undeclared here (not in a function)
306 | PTM_SET_BUFFERSIZE = _IOWR('P', 16, ptm_setbuffersize),
| ^~~~~
../backends/tpm/tpm_ioctl.h:307:30: error: ‘_IOT__IOTBASE_ptm_getinfo’
undeclared here (not in a function)
307 | PTM_GET_INFO = _IOWR('P', 17, ptm_getinfo),
| ^~~~~
../backends/tpm/tpm_ioctl.h:308:30: error:
‘_IOT__IOTBASE_ptm_lockstorage’ undeclared here (not in a function)
308 | PTM_LOCK_STORAGE = _IOWR('P', 18, ptm_lockstorage),
If you want to preserve the enum, I am happy to put an ifdef instead of
removing it.
That would be exactly what we had in v3 3/4.
Damien