Blame misc/lnstat.h

Packit d3f73b
/* SPDX-License-Identifier: GPL-2.0 */
Packit d3f73b
#ifndef _LNSTAT_H
Packit d3f73b
#define _LNSTAT_H
Packit d3f73b
Packit d3f73b
#include <limits.h>
Packit d3f73b
#include <sys/select.h>
Packit d3f73b
Packit d3f73b
#define LNSTAT_VERSION "0.02 041002"
Packit d3f73b
Packit d3f73b
#define PROC_NET_STAT	"/proc/net/stat"
Packit d3f73b
Packit d3f73b
#define LNSTAT_MAX_FILES			32
Packit d3f73b
#define LNSTAT_MAX_FIELDS_PER_LINE		32
Packit d3f73b
#define LNSTAT_MAX_FIELD_NAME_LEN		32
Packit d3f73b
Packit d3f73b
struct lnstat_file;
Packit d3f73b
Packit d3f73b
struct lnstat_field {
Packit d3f73b
	struct lnstat_file *file;
Packit d3f73b
	unsigned int num;			/* field number in line */
Packit d3f73b
	char name[LNSTAT_MAX_FIELD_NAME_LEN+1];
Packit d3f73b
	unsigned long values[2];		/* two buffers for values */
Packit d3f73b
	unsigned long result;
Packit d3f73b
};
Packit d3f73b
Packit d3f73b
struct lnstat_file {
Packit d3f73b
	struct lnstat_file *next;
Packit d3f73b
	char path[PATH_MAX+1];
Packit d3f73b
	char basename[NAME_MAX+1];
Packit d3f73b
	struct timeval last_read;		/* last time of read */
Packit d3f73b
	struct timeval interval;		/* interval */
Packit d3f73b
	int compat;				/* 1 == backwards compat mode */
Packit d3f73b
	FILE *fp;
Packit d3f73b
	unsigned int num_fields;		/* number of fields */
Packit d3f73b
	struct lnstat_field fields[LNSTAT_MAX_FIELDS_PER_LINE];
Packit d3f73b
};
Packit d3f73b
Packit d3f73b
Packit d3f73b
struct lnstat_file *lnstat_scan_dir(const char *path, const int num_req_files,
Packit d3f73b
				    const char **req_files);
Packit d3f73b
int lnstat_update(struct lnstat_file *lnstat_files);
Packit d3f73b
int lnstat_dump(FILE *outfd, struct lnstat_file *lnstat_files);
Packit d3f73b
struct lnstat_field *lnstat_find_field(struct lnstat_file *lnstat_files,
Packit d3f73b
				       const char *name);
Packit d3f73b
#endif /* _LNSTAT_H */