-
Notifications
You must be signed in to change notification settings - Fork 107
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
[WIP] Expose functionality as a re-usable library #279
Conversation
Add initial library interface with Doxygen. Move global and static variables to lsof context. Fix LTbasic test by locating real lsof binary. Don't check Foffset/Fsize in dialect, only check them in print.c. Convert string-based fd column to enum + int. Rewrite LTbasic with liblsof.
NB: @jiegec Quick question as I don't seem to see it in the changes, but kinda expected to: Will there be some configuration file(s) for |
Okay, I will add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be more careful with your changes.
lib/dialects/sun/ddev.c
Outdated
static void make_devtp (struct lsof_context * ctx, struct stat *s, char *p); | ||
static int rmdupdev (struct lsof_context * ctx, struct l_dev ***dp, int n, int ty); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not remove the whitespace after the function name?
@@ -39,7 +39,7 @@ static char copyright[] = | |||
* Local static definitions | |||
*/ | |||
|
|||
_PROTOTYPE(static char *getmntdev, (char *o, int l, struct stat *s, char *f)); | |||
static char *getmntdev, (char *o, int l, struct stat *s char *f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stray comma after function name.
lib/dialects/osr/dproc.c
Outdated
_PROTOTYPE(static int LNC_enter, | ||
(struct lnch * le, char *nm, int nl, char *fs)); | ||
_PROTOTYPE(static void LNC_nosp, (int len)); | ||
static int LNC_enter (struct lnch * le, char *nm, int nl, char *fs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe remove the whitespace after the name …
@@ -987,29 +987,28 @@ static struct lnch *LNC_nc = (struct lnch *)NULL; | |||
* Local function prototypes | |||
*/ | |||
|
|||
_PROTOTYPE(static struct lnch *DIN_addr, (dev_t * d, unsigned long i)); | |||
static struct lnch *DIN_addr, (dev_t * d unsigned long i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray comma after function name
lib/dialects/osr/dnode.c
Outdated
@@ -35,8 +35,7 @@ static char copyright[] = | |||
|
|||
#include "common.h" | |||
|
|||
_PROTOTYPE(static struct l_dev *finddev, | |||
(dev_t * dev, dev_t *rdev, int stream)); | |||
static struct l_dev *finddev (dev_t * dev, dev_t *rdev, int stream); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the whitespace?
tests/LTlock.c
Outdated
_PROTOTYPE(static char *unlkfile, (int ty)); | ||
static void cleanup (void); | ||
static char *lkfile (int ty); | ||
static char *tstwlsof, (char *opt char *xlk); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray comma
tests/LTnfs.c
Outdated
_PROTOTYPE(static void cleanup, (void)); | ||
_PROTOTYPE(static char *FindNFSfile, (int *ff, char *szbuf)); | ||
static void cleanup (void); | ||
static char *FindNFSfile, (int *ff char *szbuf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray comma
tests/LTnlink.c
Outdated
_PROTOTYPE(static char *FindFile, (char *opt, int *ff, int ie, LTdev_t *tfdc, | ||
char *ibuf, char *xlnk, char *szbuf)); | ||
static void cleanup (void); | ||
static char *FindFile, (char *opt, int *ff, int ie, LTdev_t *tfdc char *ibuf, char *xlnk, char *szbuf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray comma
tests/LTszoff.c
Outdated
_PROTOTYPE(static void cleanup, (void)); | ||
_PROTOTYPE(static char *testlsof, (int tt, char *opt, char *xval)); | ||
static void cleanup (void); | ||
static char *testlsof, (int tt, char *opt char *xval); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray comma
tests/LsofTest.h
Outdated
extern char *CanRdKmem (void); | ||
extern char *ConvStatDev, (dev_t * dev LTdev_t *ldev); | ||
extern char *ConvLsofDev, (char *dev LTdev_t *ldev); | ||
extern char *ExecLsof (char **opt); | ||
extern char *IsLsofExec (void); | ||
extern void LTlibClean (void); | ||
extern char *MkStrCpy, (char *src int *len); | ||
extern LTfldo_t *RdFrLsof, (int *nf char **em); | ||
extern void PrtMsg, (char *mp char *pn); | ||
extern void PrtMsgX, (char *mp, char *pn, void (*f)() int xv); | ||
extern int ScanArg, (int ac, char *av[], char *opt char *pn); | ||
extern void StopLsof (void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray comma
Thanks, I was removing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are some function signatures reverted back to K&R style?
int read_vxnode(v, vfs, dev, devs, rdev, rdevs) | ||
struct vnode *v; /* local containing vnode */ | ||
struct l_vfs *vfs; /* local vfs structure */ | ||
dev_t *dev; /* device number receiver */ | ||
int *devs; /* device status receiver */ | ||
dev_t *rdev; /* raw device number receiver */ | ||
int *rdevs; /* raw device status receiver */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not rewrite this to more modern C like with so many other function declarations?
The master branch was merged via |
NB: Ah, k. Maybe have a look at |
@jiegec Any further open aspects/items for this feature? AFAICS the bullet list in the first post has not been checked off completely. |
This pr implements #268 by splitting code into two parts: liblsof(the library) and lsof(the cli). The pr is unfinished, but is half way done. It is a VERY BIG pull request and I try my best to maintain the lsof cli behavior. I am opening this pr to request for more comments. Progress:
struct lsof_file
, e.g. network address, TCP state.Allow liblsof to read info when running as non-root on NetBSD and Solaris by switching to /proc-based.Postponed to future prMigrate more options from cli to liblsof until cli only uses public interface of liblsof.Options are already migrated, but it is hard to remove access of private structures while maintaining compatibility.I'd love to see more comments on the API interface (You can find some at #268).