/[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.203 Revision 1.204
1/* 1/*
2 * Copyright 2003-2007 Gentoo Foundation 2 * Copyright 2003-2007 Gentoo Foundation
3 * Distributed under the terms of the GNU General Public License v2 3 * Distributed under the terms of the GNU General Public License v2
4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.203 2008/12/30 12:39:53 vapier Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.204 2008/12/30 13:09:20 vapier Exp $
5 * 5 *
6 * Copyright 2003-2007 Ned Ludd - <solar@gentoo.org> 6 * Copyright 2003-2007 Ned Ludd - <solar@gentoo.org>
7 * Copyright 2004-2007 Mike Frysinger - <vapier@gentoo.org> 7 * Copyright 2004-2007 Mike Frysinger - <vapier@gentoo.org>
8 */ 8 */
9 9
10static const char *rcsid = "$Id: scanelf.c,v 1.203 2008/12/30 12:39:53 vapier Exp $"; 10static const char *rcsid = "$Id: scanelf.c,v 1.204 2008/12/30 13:09:20 vapier Exp $";
11const char * const argv0 = "scanelf"; 11const char * const argv0 = "scanelf";
12 12
13#include "paxinc.h" 13#include "paxinc.h"
14 14
15#define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+') 15#define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+')
76static size_t ldcache_size = 0; 76static size_t ldcache_size = 0;
77static unsigned long setpax = 0UL; 77static unsigned long setpax = 0UL;
78 78
79static int has_objdump = 0; 79static int has_objdump = 0;
80 80
81static char *getstr_perms(const char *fname);
82static char *getstr_perms(const char *fname) 81static const char *getstr_perms(const char *fname)
83{ 82{
84 struct stat st; 83 struct stat st;
85 static char buf[8]; 84 static char buf[8];
86 85
87 if ((stat(fname, &st)) == (-1)) 86 if (stat(fname, &st) == -1)
88 return (char *) ""; 87 return "";
89 88
90 snprintf(buf, sizeof(buf), "%o", st.st_mode); 89 snprintf(buf, sizeof(buf), "%o", st.st_mode);
91 90
92 return (char *) buf + 2; 91 return buf + 2;
93} 92}
94 93
95/* find the path to a file by name */ 94/* find the path to a file by name */
96static char *which(const char *fname) 95static char *which(const char *fname)
97{ 96{
106 while ((p = strrchr(path, ':')) != NULL) { 105 while ((p = strrchr(path, ':')) != NULL) {
107 snprintf(fullpath, sizeof(fullpath), "%s/%s", p + 1, fname); 106 snprintf(fullpath, sizeof(fullpath), "%s/%s", p + 1, fname);
108 *p = 0; 107 *p = 0;
109 if (access(fullpath, R_OK) != (-1)) { 108 if (access(fullpath, R_OK) != (-1)) {
110 free(path); 109 free(path);
111 return (char *) fullpath; 110 return fullpath;
112 } 111 }
113 } 112 }
114 free(path); 113 free(path);
115 return NULL; 114 return NULL;
116} 115}

Legend:
Removed from v.1.203  
changed lines
  Added in v.1.204

  ViewVC Help
Powered by ViewVC 1.1.20