- License changed to GPL
- signames.h generated better (suggested by Grant Erickson)
- uses getopt() for better command line stuff
- - makes less assumptions about pcess name, closes Debian Bug #53337
+ - makes less assumptions about process name, closes Debian Bug #53337
+ - Doesn't use losetup for loop deivces in fuser.
Changes from version 18 to 19 (25-OCT-1999)
=============================
#include <signal.h>
#include <limits.h>
#include <netdb.h>
+#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <linux/major.h> /* for LOOP_MAJOR */
#include "comm.h"
+#include "loop.h" /* for loop_info */
#include "signals.h"
FILE *file;
struct stat st_dev, st_parent, st_mounted;
char line[MAX_LINE + 1], path[PATH_MAX + 1], mounted[PATH_MAX + 3];
- char tmp[MAX_LINE + 1];
char *end;
if (!(file = fopen (PROC_BASE "/mounts", "r")))
continue; /* might be NFS or such */
if (S_ISBLK (st_dev.st_mode) && MAJOR (st_dev.st_rdev) == LOOP_MAJOR)
{
- FILE *pipe;
-
- sprintf (tmp, "losetup %s", path);
- if (!(pipe = popen (tmp, "r")))
- fprintf (stderr, "popen(%s) failed\n", tmp);
- else
- {
- int dev, ino;
-
- if (fscanf (pipe, "%*s [%x]:%d", &dev, &ino) == 2)
- add_other (it_loop, dev, dev, ino, path);
- (void) fclose (pipe);
- }
+ struct loop_info loopinfo;
+ int fd;
+
+ if ((fd = open(path, O_RDWR)) > 0) {
+ if (ioctl(fd, LOOP_GET_STATUS, &loopinfo) >= 0) {
+ add_other(it_loop,loopinfo.lo_device,loopinfo.lo_device,loopinfo.lo_inode,path);
+ }
+ (void) close(fd);
+ }
}
if (stat (mounted, &st_mounted) < 0)
{