Skip to content
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

Library part5 #290

Merged
merged 34 commits into from
May 24, 2023
Merged

Library part5 #290

merged 34 commits into from
May 24, 2023

Conversation

jiegec
Copy link
Contributor

@jiegec jiegec commented May 12, 2023

Part 5 of pr #279

  • Move global variable to context
  • Add lsof APIs:
    • lsof_get_api_version
    • lsof_get_library_version
    • lsof_set_output_stream
    • lsof_avoid_blocking
    • lsof_avoid_forking
    • lsof_logic_and
    • lsof_select_process

Copy link

@BenBE BenBE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Some minor code style things re alignment of line continuations left.

lib/common.h Outdated Show resolved Hide resolved
Comment on lines +1329 to +1498
# define MntSup (ctx->mnt_sup_state)
# define MntSupP (ctx->mnt_sup_path)
/* nlink limit */
# define Nlink (ctx->nlink)
/* Time limit */
# define TmLimit (ctx->time_limit)
/* number of unselected PIDs */
# define Npuns (ctx->num_unsel_pid)
/* pid/uid/gid of current process */
# define Mypid (ctx->my_pid)
# define Myuid (ctx->my_uid)
# define Mygid (ctx->my_gid)
/* setgid state */
# define Setgid (ctx->setgid)
/* setuid-root state */
# define Setuidroot (ctx->setuid_root)
/* directory stack */
# define Dstk (ctx->dir_stack)
# define Dstkx (ctx->dir_stack_index)
# define Dstkn (ctx->dir_stack_size)
/* selection files */
# define Sfile (ctx->select_files)
/* fs to eliminate blocking syscalls */
# define Efsysl (ctx->elim_fs_list)
/* select uid */
# define Suid (ctx->sel_uid)
# define Nuid (ctx->sel_uid_size)
# define Nuidincl (ctx->num_uid_included)
# define Nuidexcl (ctx->num_uid_excluded)
# define Mxuid (ctx->sel_uid_cap)
/* select pid */
# define Spid (ctx->sel_pid)
# define Npid (ctx->sel_pid_size)
# define Npidi (ctx->sel_pid_incl_num)
# define Npidx (ctx->sel_pid_excl_num)
# define Mxpid (ctx->sel_pid_cap)
/* select pgid */
# define Spgid (ctx->sel_pgid)
# define Npgid (ctx->sel_pgid_size)
# define Npgidi (ctx->sel_pgid_incl_num)
# define Npgidx (ctx->sel_pgid_excl_num)
# define Mxpgid (ctx->sel_pgid_cap)
/* select all procs */
# define AllProc (ctx->sel_all_proc)
/* select command */
# define Cmdl (ctx->sel_cmds)
# define Cmdni (ctx->sel_cmd_incl)
# define Cmdnx (ctx->sel_cmd_excl)
# define CmdRx (ctx->cmd_regex)
# define NCmdRxU (ctx->cmd_regex_size)
/* select by network address */
# define Nwad (ctx->sel_net_addr)
/* device table pointer */
# define Devtp (ctx->dev_table)
# define Ndev (ctx->dev_table_size)
# define Sdev (ctx->dev_table_sorted)
/* block device table */
# define BDevtp (ctx->block_dev_table)
# define BNdev (ctx->block_dev_table_size)
# define BSdev (ctx->block_dev_table_sorted)
/* select selinux context */
# define CntxArg (ctx->sel_selinux_context)
/* device cache */
# define DCpath (ctx->dev_cache_paths)
# define DCpathArg (ctx->dev_cache_path_arg)
# define DCpathX (ctx->dev_cache_path_index)
# define DCcksum (ctx->dev_cache_checksum)
# define DCfd (ctx->dev_cache_fd)
# define DCfs (ctx->dev_cache_fp)
# define DCrebuilt (ctx->dev_cache_rebuilt)
# define DCstate (ctx->dev_cache_state)
# define DCunsafe (ctx->dev_cache_unsafe)
/* name list */
# define Nl (ctx->name_list)
# define Nll (ctx->name_list_size)
# define Nmlst (ctx->name_list_path)
# define Memory (ctx->core_file_path)
/* procfs */
# define Mtprocfs (ctx->procfs_mount)
# define Procsrch (ctx->procfs_search)
# define Procfsid (ctx->procfs_table)
# define Procfind (ctx->procfs_found)
/* name cache */
# define Fncache (ctx->name_cache_enable)
/* local mount info */
# define Lmi (ctx->local_mount_info)
# define Lmist (ctx->local_mount_info_valid)
/* hash buckets in hashSfile() */
# define HbyFdi (ctx->sfile_hash_file_dev_inode)
# define HbyFdiCt (ctx->sfile_hash_file_dev_inode_count)
# define HbyFrd (ctx->sfile_hash_file_raw_device)
# define HbyFrdCt (ctx->sfile_hash_file_raw_device_count)
# define HbyFsd (ctx->sfile_hash_file_system)
# define HbyFsdCt (ctx->sfile_hash_file_system_count)
# define HbyNm (ctx->sfile_hash_name)
# define HbyNmCt (ctx->sfile_hash_name_count)
# define HbyCd (ctx->sfile_hash_clone)
# define HbyCdCt (ctx->sfile_hash_clone_count)
/* solaris zone */
# define ZoneArg (ctx->sel_zone)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As there are quite a lot of these convenience macros they run the risk of overly polluting the namespace if not needed. Please split into a separate header (if publicly exposed).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a private header for liblsof. The public interface is lsof.h.

@jiegec jiegec merged commit cab786c into master May 24, 2023
@jiegec jiegec deleted the library-part5 branch May 24, 2023 10:55
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