Skip to content

Commit 6143c30

Browse files
authored
Merge pull request #347 from neek78/small_changes
Add basic support for Darwin PROX_FDTYPE_NETPOLICY
2 parents 63c2646 + b241a94 commit 6143c30

5 files changed

Lines changed: 23 additions & 0 deletions

File tree

include/lsof.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ enum lsof_file_type {
212212
type */
213213
LSOF_FILE_SCO_SEMA, /**< SCO OpenServer Xenix semaphore file */
214214
LSOF_FILE_SCO_SHARED, /**< SCO OpenServer Xenix shared data file */
215+
LSOF_FILE_NPOLICY, /**< Darwin Netpolicy */
215216
LSOF_FILE_UNSUPPORTED, /**< unsupported file type */
216217

217218
/* types from struct vnode */

lib/dialects/darwin/dfile.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,20 @@ void process_fsevents(struct lsof_context *ctx, /* context */
273273
Lf->type = LSOF_FILE_FSEVENTS;
274274
}
275275

276+
/*
277+
*
278+
* process_fsevents() -- process a network policy file
279+
* see also -
280+
https://github.com/apple-opensource/lsof/blob/da09c8c6436286e5bd8c400b42e86b54404f12a7/lsof/dialects/darwin/libproc/dnetpolicy.c
281+
*/
282+
283+
void process_netpolicy(struct lsof_context *ctx, /* context */
284+
int pid, /* PID */
285+
int32_t fp) /* fd */
286+
{
287+
Lf->type = LSOF_FILE_NPOLICY;
288+
}
289+
276290
/*
277291
* process_kqueue() -- process a kernel queue file
278292
*/
@@ -612,3 +626,4 @@ void process_fileport_vnode(struct lsof_context *ctx, /* context */
612626
process_vnode_common(ctx, &vi);
613627
}
614628
#endif /* PROC_PIDLISTFILEPORTS */
629+

lib/dialects/darwin/dproc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ static void process_fds(struct lsof_context *ctx, /* context */
537537
case PROX_FDTYPE_VNODE:
538538
(void)process_vnode(ctx, pid, fdp->proc_fd);
539539
break;
540+
case PROX_FDTYPE_NETPOLICY:
541+
(void)process_netpolicy(ctx, pid, fdp->proc_fd);
542+
break;
540543
default:
541544
(void)snpf(Namech, Namechl - 1, "unknown file type: %d",
542545
fdp->proc_fdtype);

lib/dialects/darwin/dproto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ extern void process_psem(struct lsof_context *ctx, int pid, int32_t fd);
5252
extern void process_pshm(struct lsof_context *ctx, int pid, int32_t fd);
5353
extern void process_socket(struct lsof_context *ctx, int pid, int32_t fd);
5454
extern void process_vnode(struct lsof_context *ctx, int pid, int32_t fd);
55+
extern void process_netpolicy(struct lsof_context *ctx, int pid, int32_t fd);
5556
#if defined(PROC_PIDLISTFILEPORTS)
5657
extern void process_fileport_pipe(struct lsof_context *ctx, int pid,
5758
uint32_t fileport);

lib/print.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,9 @@ void file_type_to_string(enum lsof_file_type type,
394394
case LSOF_FILE_SCO_SHARED:
395395
(void)snpf(buf, buf_len, "XSD");
396396
break;
397+
case LSOF_FILE_NPOLICY:
398+
(void)snpf(buf, buf_len, "NPOLICY");
399+
break;
397400
case LSOF_FILE_UNSUPPORTED:
398401
(void)snpf(buf, buf_len, "UNSP");
399402
break;

0 commit comments

Comments
 (0)