projects
/
platform
/
upstream
/
bash.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Imported from ../bash-2.05b.tar.gz.
[platform/upstream/bash.git]
/
examples
/
loadables
/
finfo.c
diff --git
a/examples/loadables/finfo.c
b/examples/loadables/finfo.c
index
c0b0365
..
b633629
100644
(file)
--- a/
examples/loadables/finfo.c
+++ b/
examples/loadables/finfo.c
@@
-2,6
+2,10
@@
* finfo - print file info
*/
* finfo - print file info
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <sys/types.h>
#include "posixstat.h"
#include <stdio.h>
#include <sys/types.h>
#include "posixstat.h"
#include <stdio.h>
@@
-9,6
+13,7
@@
#include <grp.h>
#include <errno.h>
#include <grp.h>
#include <errno.h>
+#include "bashansi.h"
#include "shell.h"
#include "builtins.h"
#include "common.h"
#include "shell.h"
#include "builtins.h"
#include "common.h"
@@
-17,7
+22,6
@@
extern int errno;
#endif
extern int errno;
#endif
-extern char *strrchr();
extern char **make_builtin_argv ();
static int printst();
extern char **make_builtin_argv ();
static int printst();
@@
-127,17
+131,21
@@
char *f;
{
static struct stat st;
int fd, r;
{
static struct stat st;
int fd, r;
-
long
lfd;
+
intmax_t
lfd;
if (strncmp(f, "/dev/fd/", 8) == 0) {
if (strncmp(f, "/dev/fd/", 8) == 0) {
- if (
legal_number(f + 8, &lfd) == 0
) {
+ if (
(legal_number(f + 8, &lfd) == 0) || (int)lfd != lfd
) {
builtin_error("%s: invalid fd", f + 8);
return ((struct stat *)0);
}
fd = lfd;
r = fstat(fd, &st);
} else
builtin_error("%s: invalid fd", f + 8);
return ((struct stat *)0);
}
fd = lfd;
r = fstat(fd, &st);
} else
+#ifdef HAVE_LSTAT
+ r = lstat(f, &st);
+#else
r = stat(f, &st);
r = stat(f, &st);
+#endif
if (r < 0) {
builtin_error("%s: cannot stat: %s", f, strerror(errno));
return ((struct stat *)0);
if (r < 0) {
builtin_error("%s: cannot stat: %s", f, strerror(errno));
return ((struct stat *)0);
@@
-196,6
+204,13
@@
int m;
obits[i++] = 'x';
obits[i] = '\0';
obits[i++] = 'x';
obits[i] = '\0';
+ if (m & S_ISUID)
+ ubits[2] = (m & S_IXUSR) ? 's' : 'S';
+ if (m & S_ISGID)
+ gbits[2] = (m & S_IXGRP) ? 's' : 'S';
+ if (m & S_ISVTX)
+ obits[2] = (m & S_IXOTH) ? 't' : 'T';
+
printf ("u=%s,g=%s,o=%s", ubits, gbits, obits);
}
printf ("u=%s,g=%s,o=%s", ubits, gbits, obits);
}
@@
-217,6
+232,10
@@
int mode;
printf("S_IFLNK ");
if (S_ISSOCK(mode))
printf("S_IFSOCK ");
printf("S_IFLNK ");
if (S_ISSOCK(mode))
printf("S_IFSOCK ");
+#ifdef S_ISWHT
+ if (S_ISWHT(mode))
+ printf("S_ISWHT ");
+#endif
perms(getperm(mode));
printf("\n");
}
perms(getperm(mode));
printf("\n");
}
@@
-333,6
+352,7
@@
int flags;
}
#ifndef NOBUILTIN
}
#ifndef NOBUILTIN
+int
finfo_builtin(list)
WORD_LIST *list;
{
finfo_builtin(list)
WORD_LIST *list;
{