8000 Fix remarks on `utmp` byte order and size by panhania · Pull Request #34 · libyal/dtformats · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix remarks on utmp byte order and size #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

panhania
Copy link

I have verified on a s390x (so, big-endian) Ubuntu 20.04 distribution (using Docker) that the byte order of utmp files is big-endian (at least of entries in /var/log/wtmp and /var/run/utmp). Thus, I think it is reasonable to conclude that these use native endianness.

I have samples of these files if needed for test_data but I am unable to figure out how tests in these repository work to write one myself.

@joachimmetz
Copy link
Member

Thanks for confirming, will have a closer look when time permits

Copy link
codecov bot commented Mar 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 52.38%. Comparing base (d14fb6b) to head (8422bd2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #34   +/-   ##
=======================================
  Coverage   52.38%   52.38%           
=======================================
  Files          41       41           
  Lines        7991     7991           
=======================================
  Hits         4186     4186           
  Misses       3805     3805           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@panhania panhania changed the title Fix remark on utmp byte order Fix remarks on utmp byte order and size May 6, 2025
@panhania
Copy link
Author
panhania commented May 6, 2025

While working on RRG builds for aarch64, I noticed that utmp is actually 400-bytes long, not 384 like the current version of the document suggests. Thus, I reworked the PR to also cover this aspect.

Here's the program I used on a aarch64 Debian 12 to gather the data:

#include <stddef.h>
#include <stdio.h>
#include <utmp.h>

int main()
{
	printf("sizeof(struct utmp) = %zu\n", sizeof(struct utmp));

	printf("\n");

	printf("offsetof(struct utmp, ut_session) = %zu\n", offsetof(struct utmp, ut_session));
	printf("offsetof(struct utmp, ut_tv) = %zu\n", offsetof(struct utmp, ut_tv));
	printf("offsetof(struct utmp, ut_addr_v6) = %zu\n", offsetof(struct utmp, ut_addr_v6));
	printf("offsetof(struct utmp, __glibc_reserved) = %zu\n", offsetof(struct utmp, __glibc_reserved));

	printf("\n");

	printf("sizeof(struct utmp.ut_session) = %zu\n", sizeof(((struct utmp){}).ut_session));
	printf("sizeof(struct utmp.ut_tv) = %zu\n", sizeof(((struct utmp){}).ut_tv));
	printf("sizeof(struct utmp.ut_addr_v6) = %zu\n", sizeof(((struct utmp){}).ut_addr_v6));
	printf("sizeof(struct utmp.__glibc_reserved) = %zu\n", sizeof(((struct utmp){}).__glibc_reserved));

	return 0;
}

... and here is its output:

sizeof(struct utmp) = 400

offsetof(struct utmp, ut_session) = 336
offsetof(struct utmp, ut_tv) = 344
offsetof(struct utmp, ut_addr_v6) = 360
offsetof(struct utmp, __glibc_reserved) = 376

sizeof(struct utmp.ut_session) = 8
sizeof(struct utmp.ut_tv) = 16
sizeof(struct utmp.ut_addr_v6) = 16
sizeof(struct utmp.__glibc_reserved) = 20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0