zuzkins / mac-lsof-regular-files-only

This is version of LSOF utility shipped with Mac OS X, which does provide information about only regular files. All other information has been stripped.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Motivation

This version of lsof utility is based on same sources as the one shipped with Mac OS X by default. The difference is that we strip it of all the details we do not care about. This version only reports details about regular files. Every other entity (pipes, sockets, ...) is ignored and will be flagged as unknown file type: $code.

We do this because all we care about is to find out which of our regular files are still opened and we want this information fast:

$ time lsof -n > /dev/null
> 0,23s user 0,90s system 99% cpu 1,140 total

vs

$ time this-lsof > /dev/null
> 0,04s user 0,02s system 89% cpu 0,065 total

Building

To build this you will need Xcode installed and some MacOSX sdk. Also you should run it with the default make (GNU version installed via homebrew might fail).

  1. clone this repository: git clone https://github.com/zuzkins/mac-lsof-regular-files-only
  2. cd into it: cd mac-lsof-regular-files-only
  3. make LSOF_INCLUDE="`xcrun -sdk / --show-sdk-path`/usr/include"
  4. should produce /tmp/lsof/Build/lsof binary

About

This is version of LSOF utility shipped with Mac OS X, which does provide information about only regular files. All other information has been stripped.


Languages

Language:C 66.8%Language:Groff 16.7%Language:Shell 11.6%Language:Perl 3.1%Language:Makefile 1.2%Language:Awk 0.6%