]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - misc-utils/lsfd.h
2 * lsfd(1) - list file descriptors
4 * Copyright (C) 2021 Red Hat, Inc. All rights reserved.
5 * Written by Masatake YAMATO <yamato@redhat.com>
7 * Very generally based on lsof(8) by Victor A. Abell <abe@purdue.edu>
8 * It supports multiple OSes. lsfd specializes to Linux.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it would be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #ifndef UTIL_LINUX_LSFD_H
25 #define UTIL_LINUX_LSFD_H
97 COL_UID
, /* process */
99 COL_USER
, /* process */
101 COL_OWNER
, /* file */
102 LSFD_N_COLS
/* This must be at last. */
122 ASSOC_MEM
, /* private file mapping */
123 ASSOC_SHM
, /* shared file mapping */
129 struct proc
* leader
;
133 struct list_head procs
;
134 struct list_head files
;
135 unsigned int kthread
: 1;
138 struct proc
*get_proc(pid_t pid
);
144 struct list_head files
;
145 const struct file_class
*class;
156 unsigned int sys_flags
;
160 #define is_opened_file(_f) ((_f)->association >= 0)
161 #define is_mapped_file(_f) (is_association((_f), SHM) || is_association((_f), MEM))
162 #define is_association(_f, a) ((_f)->association < 0 && (_f)->association == -ASSOC_ ## a)
165 const struct file_class
*super
;
167 void (*initialize_class
)(void);
168 void (*finalize_class
)(void);
169 bool (*fill_column
)(struct proc
*proc
,
171 struct libscols_line
*ln
,
173 size_t column_index
);
174 int (*handle_fdinfo
)(struct file
*file
, const char *key
, const char* value
);
175 void (*attach_xinfo
)(struct file
*file
);
176 void (*initialize_content
)(struct file
*file
);
177 void (*free_content
)(struct file
*file
);
178 const struct ipc_class
*(*get_ipc_class
)(struct file
*file
);
181 extern const struct file_class file_class
, cdev_class
, bdev_class
, sock_class
, unkn_class
, fifo_class
,
188 const struct ipc_class
*class;
189 struct list_head endpoints
;
190 struct list_head ipcs
;
193 struct ipc_endpoint
{
195 struct list_head endpoints
;
199 unsigned int (*get_hash
)(struct file
*file
);
200 bool (*is_suitable_ipc
)(struct ipc
*ipc
, struct file
*file
);
201 void (*free
)(struct ipc
*ipc
);
204 struct ipc
*get_ipc(struct file
*file
);
205 void add_ipc(struct ipc
*ipc
, unsigned int hash
);
212 struct name_manager
*new_name_manager(void);
213 void free_name_manager(struct name_manager
*nm
);
214 const char *get_name(struct name_manager
*nm
, unsigned long id
);
215 unsigned long add_name(struct name_manager
*nm
, const char *name
);
217 const char *get_partition(dev_t dev
);
218 const char *get_blkdrv(unsigned long major
);
219 const char *get_chrdrv(unsigned long major
);
220 const char *get_miscdev(unsigned long minor
);
221 const char *get_nodev_filesystem(unsigned long minor
);
223 static inline void xstrappend(char **a
, const char *b
)
225 if (strappend(a
, b
) < 0)
226 err(XALLOC_EXIT_CODE
, _("failed to allocate memory for string"));
229 static inline void xstrputc(char **a
, char c
)
231 char b
[] = {c
, '\0'};
238 void load_sock_xinfo(struct path_cxt
*pc
, const char *name
, ino_t netns
);
239 bool is_nsfs_dev(dev_t dev
);
241 #endif /* UTIL_LINUX_LSFD_H */