Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:AndreasSchwab:13.1
util-linux
util-linux-zero-fs-parent-id.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File util-linux-zero-fs-parent-id.patch of Package util-linux
From 6c373810f5b1d32824371e9dff6ee5a006388f98 Mon Sep 17 00:00:00 2001 From: Karel Zak <kzak@redhat.com> Date: Thu, 20 Feb 2014 16:59:11 +0100 Subject: [PATCH] libmount: FS id and parent ID could be zero MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It seems that linux 3.14 is able to produce things like: 19 0 8:3 / / rw,relatime - ext4 /dev/sda3 rw,data=ordered ^ Reported-by: Mantas Mikulėnas <grawity@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com> --- libmount/src/tab.c | 12 ++++-------- misc-utils/findmnt.c | 5 +++-- 2 files changed, 7 insertions(+), 10 deletions(-) Index: util-linux-2.23.2/libmount/src/tab.c =================================================================== --- util-linux-2.23.2.orig/libmount/src/tab.c +++ util-linux-2.23.2/libmount/src/tab.c @@ -47,6 +47,20 @@ #include "strutils.h" #include "loopdev.h" +static int is_mountinfo(struct libmnt_table *tb) +{ + struct libmnt_fs *fs; + + if (!tb) + return 0; + + fs = list_first_entry(&tb->ents, struct libmnt_fs, ents); + if (fs && mnt_fs_is_kernel(fs) && mnt_fs_get_root(fs)) + return 1; + + return 0; +} + /** * mnt_new_table: * @@ -233,7 +247,7 @@ int mnt_table_get_root_fs(struct libmnt_ assert(tb); assert(root); - if (!tb || !root) + if (!tb || !root || !is_mountinfo(tb)) return -EINVAL; DBG(TAB, mnt_debug_h(tb, "lookup root fs")); @@ -241,8 +255,6 @@ int mnt_table_get_root_fs(struct libmnt_ mnt_reset_iter(&itr, MNT_ITER_FORWARD); while(mnt_table_next_fs(tb, &itr, &fs) == 0) { int id = mnt_fs_get_parent_id(fs); - if (!id) - break; /* @tab is not mountinfo file? */ if (!*root || id < root_id) { *root = fs; @@ -250,7 +262,7 @@ int mnt_table_get_root_fs(struct libmnt_ } } - return root_id ? 0 : -EINVAL; + return *root ? 0 : -EINVAL; } /** @@ -271,15 +283,13 @@ int mnt_table_next_child_fs(struct libmn struct libmnt_fs *fs; int parent_id, lastchld_id = 0, chld_id = 0; - if (!tb || !itr || !parent) + if (!tb || !itr || !parent || !is_mountinfo(tb)) return -EINVAL; DBG(TAB, mnt_debug_h(tb, "lookup next child of '%s'", mnt_fs_get_target(parent))); parent_id = mnt_fs_get_id(parent); - if (!parent_id) - return -EINVAL; /* get ID of the previously returned child */ if (itr->head && itr->p != itr->head) { @@ -310,7 +320,7 @@ int mnt_table_next_child_fs(struct libmn } } - if (!chld_id) + if (!*chld) return 1; /* end of iterator */ /* set the iterator to the @chld for the next call */ @@ -934,20 +944,6 @@ err: return NULL; } -static int is_mountinfo(struct libmnt_table *tb) -{ - struct libmnt_fs *fs; - - if (!tb) - return 0; - - fs = list_first_entry(&tb->ents, struct libmnt_fs, ents); - if (fs && mnt_fs_is_kernel(fs) && mnt_fs_get_root(fs)) - return 1; - - return 0; -} - /** * mnt_table_is_mounted: * @tb: /proc/self/mountinfo file Index: util-linux-2.23.2/misc-utils/findmnt.c =================================================================== --- util-linux-2.23.2.orig/misc-utils/findmnt.c +++ util-linux-2.23.2/misc-utils/findmnt.c @@ -826,8 +826,9 @@ static int tab_is_tree(struct libmnt_tab if (!itr) return 0; - if (mnt_table_next_fs(tb, itr, &fs) == 0) - rc = mnt_fs_get_id(fs) > 0 && mnt_fs_get_parent_id(fs) > 0; + rc = (mnt_table_next_fs(tb, itr, &fs) == 0 && + mnt_fs_is_kernel(fs) && + mnt_fs_get_root(fs)); mnt_free_iter(itr); return rc;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor