]> www.infradead.org Git - mtd-utils.git/commitdiff
ubi-utils: use 'stat(2)' instead of 'lstat(2)'
authorEnrico Scholz <enrico.scholz@sigma-chemnitz.de>
Mon, 25 Aug 2008 09:21:48 +0000 (11:21 +0200)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Mon, 25 Aug 2008 11:38:02 +0000 (14:38 +0300)
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 <enrico.scholz@sigma-chemnitz.de>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
ubi-utils/new-utils/src/libubi.c
ubi-utils/src/libubi.c
ubi-utils/src/nand2bin.c

index 8f951083339ecbf8fd627caa3760496a7e6e78d1..10e3f2ab9c98a98ec96c7c1b458c3a1a8c48ac63 100644 (file)
@@ -365,7 +365,7 @@ static int vol_node2nums(struct libubi *lib, const char *node, int *dev_num,
        int i, fd, major, minor;
        char file[strlen(lib->ubi_vol) + 100];
 
-       if (lstat(node, &st))
+       if (stat(node, &st))
                return -1;
 
        if (!S_ISCHR(st.st_mode)) {
@@ -427,20 +427,20 @@ static int vol_node2nums(struct libubi *lib, const char *node, int *dev_num,
  */
 static int dev_node2num(struct libubi *lib, const char *node, int *dev_num)
 {
-       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 errmsg("\"%s\" is not a character device", node);
        }
 
-       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;
@@ -754,7 +754,7 @@ int ubi_node_type(libubi_t desc, const char *node)
        struct libubi *lib = (struct libubi *)desc;
        char file[strlen(lib->ubi_vol) + 100];
 
-       if (lstat(node, &st))
+       if (stat(node, &st))
                return -1;
 
        if (!S_ISCHR(st.st_mode)) {
index a028fc6dde7aca2e2464e34484fb0ebdb9d5379d..a536b471ec4c5035c704874d0acbdda1045376f0 100644 (file)
@@ -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;
index be62e3077193f3168def7269cda39cd92e89e652..93ba29f8e571d4611428f6de484757a4f8706235 100644 (file)
@@ -456,7 +456,7 @@ main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        }
 
-       if (lstat(myargs.arg1, &file_info) != 0) {
+       if (stat(myargs.arg1, &file_info) != 0) {
                perror("Cannot fetch file size from input file.\n");
                exit(EXIT_FAILURE);
        }