Skip to content

Conversation

@uptycs-rmack
Copy link
Contributor

@uptycs-rmack uptycs-rmack commented Oct 23, 2025

The AIX driver no longer compiled after the major refactor that moved global variables into a context structure passed to functions. This commit updates the AIX dialect to work with the new architecture. Only tested compilation with "aixgcc" configure target. I don't have access to the legacy AIX compilers.

In addition to the context library changes the include ordering needed to be adjusted to ensure the very first time sys/inttypes.h was included it was with _KERNEL and __KERNEL_64 defined. Without this fix ulong32int64_t was 8 bytes when it actually needs to be 4 bytes because the kernel structs still use 32 bit fields even on 64 bit kernels.

This has been tested in AIX 7.2, AIX 7.3, macOS Tahoe 26.0.1, and Ubuntu 24.04.

Changes:

  • Add dialect-specific fields to struct lsof_context_dialect in dlsof.h:

    • kd, km: kernel memory file descriptors
    • lvfs: local vfs structure table
    • mtab: local mount table
    • clone, clone_maj, clone_ptc: clone device information (AIX >= 4.1.4)
    • afs_vfsp: AFS vfs kernel pointer (when HAS_AFS is defined)
  • Add convenience macros (Kd, Km, Lvfs, Mtab, Clone, CloneMaj, ClonePtc, AFSVfsp) to access dialect context fields, allowing existing code to work with minimal changes

  • Remove global variable declarations from dlsof.h and definitions from dstore.c for variables now in context

  • Update initialize() in dproc.c to initialize all dialect context fields

  • Update kreadx() function signature to take context parameter and update all call sites in dproc.c

  • The isglocked() function returns enum lsof_lock_mode, not char. Update the prototype in dproto.h to match the implementation.

  • Fix signal handler lowpgsp() to not take context parameter Signal handlers can only take signal number, so use static context pointer

  • Fix machine.h include order issue causing incorrect kernel struct sizes

  • Add dnode2.c symlink to .gitignore

All other AIX source files (ddev.c, dfile.c, dnode.c, dnode1.c, dnode2.c, dsock.c) should work without changes due to the convenience macros that transparently access ctx->dialect fields.

This allows the AIX driver to compile with the refactored codebase while maintaining compatibility with the existing code structure.

The AIX driver no longer compiled after the major refactor that moved
global variables into a context structure passed to functions. This
commit updates the AIX dialect to work with the new architecture.

This has been tested in AIX 7.2 and AIX 7.3.

Changes:
- Add dialect-specific fields to struct lsof_context_dialect in dlsof.h:
  - kd, km: kernel memory file descriptors
  - lvfs: local vfs structure table
  - mtab: local mount table
  - clone, clone_maj, clone_ptc: clone device information (AIX >= 4.1.4)
  - afs_vfsp: AFS vfs kernel pointer (when HAS_AFS is defined)

- Add convenience macros (Kd, Km, Lvfs, Mtab, Clone, CloneMaj, ClonePtc,
  AFSVfsp) to access dialect context fields, allowing existing code to
  work with minimal changes

- Remove global variable declarations from dlsof.h and definitions from
  dstore.c for variables now in context

- Update initialize() in dproc.c to initialize all dialect context fields

- Update kreadx() function signature to take context parameter and update
  all call sites in dproc.c

- The isglocked() function returns enum lsof_lock_mode, not char.
  Update the prototype in dproto.h to match the implementation.

- Fix signal handler lowpgsp() to not take context parameter
  Signal handlers can only take signal number, so use static context pointer

- Work around GCC time() header conflict

- Fix machine.h include order issue causing incorrect kernel struct sizes

- Add dnode2.c symlink to .gitignore

All other AIX source files (ddev.c, dfile.c, dnode.c, dnode1.c, dnode2.c,
dsock.c) should work without changes due to the convenience macros that
transparently access ctx->dialect fields.

This allows the AIX driver to compile with the refactored codebase while
maintaining compatibility with the existing code structure.
@uptycs-rmack uptycs-rmack force-pushed the aix branch 2 times, most recently from 37c36be to 1c463a6 Compare October 23, 2025 17:04
@jiegec jiegec merged commit 98d72f1 into lsof-org:master Oct 24, 2025
15 of 17 checks passed
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