From d5184fdeff3bb18e4d5c5fe00a91bd473e4ed26f Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Mon, 25 Aug 2008 11:21:48 +0200 Subject: ubi-utils: use 'stat(2)' instead of 'lstat(2)' The UBI tools refuse to work with symlinks like '/dev/ubi/bootloader -> ../ubi0_2' because they use 'lstat(2)' and get information about the symlink but not about the device. This is unwanted and fixed by this patch. This patch renames 'struct stat stat' variables to 'st' to avoid compilation errors. Signed-off-by: Enrico Scholz Signed-off-by: Artem Bityutskiy --- ubi-utils/src/libubi.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'ubi-utils/src/libubi.c') diff --git a/ubi-utils/src/libubi.c b/ubi-utils/src/libubi.c index a028fc6..a536b47 100644 --- a/ubi-utils/src/libubi.c +++ b/ubi-utils/src/libubi.c @@ -754,20 +754,20 @@ static char *mkpath(const char *path, const char *name) */ static int find_dev_num(struct libubi *lib, const char *node) { - struct stat stat; + struct stat st; struct ubi_info info; int i, major, minor; - if (lstat(node, &stat)) + if (stat(node, &st)) return -1; - if (!S_ISCHR(stat.st_mode)) { + if (!S_ISCHR(st.st_mode)) { errno = EINVAL; return -1; } - major = major(stat.st_rdev); - minor = minor(stat.st_rdev); + major = major(st.st_rdev); + minor = minor(st.st_rdev); if (minor != 0) { errno = -EINVAL; @@ -811,21 +811,21 @@ static int find_dev_num(struct libubi *lib, const char *node) */ static int find_dev_num_vol(struct libubi *lib, const char *node) { - struct stat stat; + struct stat st; struct ubi_info info; int i, major; - if (lstat(node, &stat)) + if (stat(node, &st)) return -1; - if (!S_ISCHR(stat.st_mode)) { + if (!S_ISCHR(st.st_mode)) { errno = EINVAL; return -1; } - major = major(stat.st_rdev); + major = major(st.st_rdev); - if (minor(stat.st_rdev) == 0) { + if (minor(st.st_rdev) == 0) { errno = -EINVAL; return -1; } @@ -868,20 +868,20 @@ static int find_dev_num_vol(struct libubi *lib, const char *node) */ static int find_vol_num(struct libubi *lib, int dev_num, const char *node) { - struct stat stat; + struct stat st; struct ubi_dev_info info; int i, major, minor; - if (lstat(node, &stat)) + if (stat(node, &st)) return -1; - if (!S_ISCHR(stat.st_mode)) { + if (!S_ISCHR(st.st_mode)) { errno = EINVAL; return -1; } - major = major(stat.st_rdev); - minor = minor(stat.st_rdev); + major = major(st.st_rdev); + minor = minor(st.st_rdev); if (minor == 0) { errno = -EINVAL; -- cgit v1.2.3