/[gentoo-projects]/pax-utils/scanelf.c
Gentoo

Diff of /pax-utils/scanelf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.6 Revision 1.7
1/* 1/*
2 * Copyright 2003 Ned Ludd <solar@gentoo.org> 2 * Copyright 2003 Ned Ludd <solar@gentoo.org>
3 * Copyright 1999-2003 Gentoo Technologies, Inc. 3 * Copyright 1999-2003 Gentoo Technologies, Inc.
4 * Distributed under the terms of the GNU General Public License v2 4 * Distributed under the terms of the GNU General Public License v2
5 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.6 2004/01/10 08:20:07 solar Exp $ 5 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.7 2004/10/19 16:54:48 solar Exp $
6 * 6 *
7 ******************************************************************** 7 ********************************************************************
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the 10 * published by the Free Software Foundation; either version 2 of the
31#include <getopt.h> 31#include <getopt.h>
32 32
33#include "paxelf.h" 33#include "paxelf.h"
34 34
35static const char *rcsid = 35static const char *rcsid =
36 "$Id: scanelf.c,v 1.6 2004/01/10 08:20:07 solar Exp $"; 36 "$Id: scanelf.c,v 1.7 2004/10/19 16:54:48 solar Exp $";
37 37
38#define PARSE_FLAGS "hvlp" 38#define PARSE_FLAGS "hvlp"
39static struct option const long_options[] = { 39static struct option const long_options[] = {
40 {"help", no_argument, 0, 'h'}, 40 {"help", no_argument, 0, 'h'},
41 {"version", no_argument, 0, 'v'}, 41 {"version", no_argument, 0, 'v'},
66/* scan a directory for ET_EXEC files and print when we find one */ 66/* scan a directory for ET_EXEC files and print when we find one */
67void scanelf(const char *path) 67void scanelf(const char *path)
68{ 68{
69 register DIR *dir; 69 register DIR *dir;
70 register struct dirent *dentry; 70 register struct dirent *dentry;
71 struct stat st;
71 char *p; 72 char *p;
72 int len = 0; 73 int len = 0;
73 74
74 if ((chdir(path) == 0) && ((dir = opendir(path)))) { 75 if ((chdir(path) == 0) && ((dir = opendir(path)))) {
75 while ((dentry = readdir(dir))) { 76 while ((dentry = readdir(dir))) {
76 len = (strlen(path) + 2 + strlen(dentry->d_name)); 77 len = (strlen(path) + 2 + strlen(dentry->d_name));
77 p = malloc(len); 78 p = malloc(len);
78 strncpy(p, path, len); 79 strncpy(p, path, len);
79 strncat(p, "/", len); 80 strncat(p, "/", len);
80 strncat(p, dentry->d_name, len); 81 strncat(p, dentry->d_name, len);
82 if (lstat(p, &st) != -1)
83 if (S_ISREG(st.st_mode))
81 scanelf_file(p); 84 scanelf_file(p);
82 free(p); 85 free(p);
83 } 86 }
84 closedir(dir); 87 closedir(dir);
85 } 88 }
86} 89}

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.20