All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zdenek Kabelac <zkabelac@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH] convert major/minor/makedev handling
Date: Wed, 20 Apr 2016 15:24:39 +0200	[thread overview]
Message-ID: <57178317.6040401@redhat.com> (raw)
In-Reply-To: <1461124442-31152-1-git-send-email-vapier@gentoo.org>

On 20.4.2016 05:54, Mike Frysinger wrote:
> Most of the files in here use MAJOR/MINOR/MKDEV macros, but a few
> missed it.  Update the defines in those files to match them.

Hi

Unfortunately - it's more tricky then it may look at the first sight, so ATM 
NACK  - as that needs some extra thinking.

Basic issue is -   glibc   major()/minor() is different then kernel MAJOR/MINOR.

lvm2/dm IOCTLS do work with kernel  MAJOR/MINOR, while glibc functions are 
operating with glibc logic - which is unfortunately not bit match for kernel 
logic.

Don't ask me what would have happened if there would be a mismatch ;), but the 
logic should be - whenever working with kernel parameters for ioctl - use 
MAJOR/MINOR, when dealing with outputs form  i.e. 'stat()' glibc calls - use 
major()/minor() lib functions.

All of this has different types and signs...
(glibc deploys unsigned long long)



> ---
>   daemons/cmirrord/functions.c                          | 16 ++++++++++++----
>   daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c | 12 ++++++++++--
>   lib/filters/filter-sysfs.c                            |  6 ++++--
>   3 files changed, 26 insertions(+), 8 deletions(-)
>
> diff --git a/daemons/cmirrord/functions.c b/daemons/cmirrord/functions.c
> index e9d3c09..5b3cb38 100644
> --- a/daemons/cmirrord/functions.c
> +++ b/daemons/cmirrord/functions.c
> @@ -20,6 +20,14 @@
>   #include <time.h>
>   #include <unistd.h>
>
> +#ifdef __linux__
> +#  include "kdev_t.h"
> +#else
> +#  define MAJOR(x) major((x))
> +#  define MINOR(x) minor((x))
> +#  define MKDEV(x,y) makedev((x),(y))
> +#endif
> +
>   #define BYTE_SHIFT 3
>
>   /*
> @@ -333,8 +341,8 @@ static int find_disk_path(char *major_minor_str, char *path_rtn, int *unlink_pat
>   			continue;
>   		}
>   		if (S_ISBLK(statbuf.st_mode) &&
> -		    (major(statbuf.st_rdev) == major) &&
> -		    (minor(statbuf.st_rdev) == minor)) {
> +		    (MAJOR(statbuf.st_rdev) == major) &&
> +		    (MINOR(statbuf.st_rdev) == minor)) {

i.e. dealing with  glibc output  ->  major()/minor()

Regards

Zdenek



      reply	other threads:[~2016-04-20 13:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-20  3:54 [PATCH] convert major/minor/makedev handling Mike Frysinger
2016-04-20 13:24 ` Zdenek Kabelac [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57178317.6040401@redhat.com \
    --to=zkabelac@redhat.com \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.