Contents of /trunk/mkinitrd-magellan/busybox/libbb/isdirectory.c
Parent Directory | Revision Log
Revision 532 -
(show annotations)
(download)
Sat Sep 1 22:45:15 2007 UTC (17 years ago) by niro
File MIME type: text/plain
File size: 841 byte(s)
Sat Sep 1 22:45:15 2007 UTC (17 years ago) by niro
File MIME type: text/plain
File size: 841 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd
1 | /* vi: set sw=4 ts=4: */ |
2 | /* |
3 | * Utility routines. |
4 | * |
5 | * Based in part on code from sash, Copyright (c) 1999 by David I. Bell |
6 | * Permission has been granted to redistribute this code under the GPL. |
7 | * |
8 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
9 | */ |
10 | |
11 | #include <sys/stat.h> |
12 | #include "libbb.h" |
13 | |
14 | /* |
15 | * Return TRUE if a fileName is a directory. |
16 | * Nonexistent files return FALSE. |
17 | */ |
18 | int is_directory(const char *fileName, const int followLinks, struct stat *statBuf) |
19 | { |
20 | int status; |
21 | struct stat astatBuf; |
22 | |
23 | if (statBuf == NULL) { |
24 | /* set from auto stack buffer */ |
25 | statBuf = &astatBuf; |
26 | } |
27 | |
28 | if (followLinks) |
29 | status = stat(fileName, statBuf); |
30 | else |
31 | status = lstat(fileName, statBuf); |
32 | |
33 | if (status < 0 || !(S_ISDIR(statBuf->st_mode))) { |
34 | status = FALSE; |
35 | } |
36 | else status = TRUE; |
37 | |
38 | return status; |
39 | } |