Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 0/4] Fixes for makedevs
@ 2013-05-29 14:55 Peter Kjellerstedt
  2013-05-29 14:55 ` [PATCH 1/4] makedevs: Create blocks of devices with the correct uid/gid Peter Kjellerstedt
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Peter Kjellerstedt @ 2013-05-29 14:55 UTC (permalink / raw)
  To: openembedded-core

When I wanted to create devices from a package I stumbled upon a couple
of problems with the makedevs program. Most notable was that it failed
to set the correct uid/gid for devices created as part of a block (i.e.,
with a count > 0).

The following changes since commit efb8a460d2a977dbd481a0650fba8eb637c65bec:

  package.bbclass: Fix sources contents (2013-05-14 08:52:47 +0300)

are available in the git repository at:

  git://git.yoctoproject.org/poky-contrib pkj/makedevs
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=pkj/makedevs

Peter Kjellerstedt (4):
  makedevs: Create blocks of devices with the correct uid/gid
  makedevs: Correct the device number calculation for blocks of devices
  makedevs: Make the mode number readable in debug messages
  makedevs: Avoid unnecessary timestamp calculation

 .../recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

-- 
1.8.2.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] makedevs: Create blocks of devices with the correct uid/gid
  2013-05-29 14:55 [PATCH 0/4] Fixes for makedevs Peter Kjellerstedt
@ 2013-05-29 14:55 ` Peter Kjellerstedt
  2013-05-29 14:55 ` [PATCH 2/4] makedevs: Correct the device number calculation for blocks of devices Peter Kjellerstedt
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Peter Kjellerstedt @ 2013-05-29 14:55 UTC (permalink / raw)
  To: openembedded-core

When creating a block of devices (i.e., when count > 0), the wrong
path was used with the call to chown(), effectively trying to change
the owner of some (probably) non-existent file. Thus the created
device nodes were always owned by root.
---
 meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c b/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
index c7ad722..247d6c1 100644
--- a/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
+++ b/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
@@ -130,7 +130,7 @@ static void add_new_device(char *name, char *path, unsigned long uid,
 		timestamp = sb.st_mtime;
 	}
 
-	mknod(name, mode, rdev);
+	mknod(path, mode, rdev);
 	chown(path, uid, gid);
 //	printf("Device: %s %s  UID: %ld  GID: %ld  MODE: %ld  MAJOR: %d  MINOR: %d\n",
 //			path, name, uid, gid, mode, (short)(rdev >> 8), (short)(rdev & 0xff));
@@ -198,7 +198,7 @@ static int interpret_table_entry(char *line)
 		error_msg_and_die("Device table entries require absolute paths");
 	}
 	name = xstrdup(path + 1);
-	sprintf(path, "%s/%s\0", rootdir, name);
+	sprintf(path, "%s/%s", rootdir, name);
 
 	switch (type) {
 	case 'd':
@@ -223,6 +223,7 @@ static int interpret_table_entry(char *line)
 
 			for (i = start; i < count; i++) {
 				sprintf(buf, "%s%d", name, i);
+				sprintf(path, "%s/%s%d", rootdir, name, i);
 				/* FIXME:  MKDEV uses illicit insider knowledge of kernel 
 				 * major/minor representation...  */
 				rdev = MKDEV(major, minor + (i * increment - start));
-- 
1.8.2.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/4] makedevs: Correct the device number calculation for blocks of devices
  2013-05-29 14:55 [PATCH 0/4] Fixes for makedevs Peter Kjellerstedt
  2013-05-29 14:55 ` [PATCH 1/4] makedevs: Create blocks of devices with the correct uid/gid Peter Kjellerstedt
@ 2013-05-29 14:55 ` Peter Kjellerstedt
  2013-05-29 14:55 ` [PATCH 3/4] makedevs: Make the mode number readable in debug messages Peter Kjellerstedt
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Peter Kjellerstedt @ 2013-05-29 14:55 UTC (permalink / raw)
  To: openembedded-core

If the increment > 1 and the start > 0 then the calculation for the
minor device number was incorrect.
---
 meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c b/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
index 247d6c1..d58e891 100644
--- a/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
+++ b/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
@@ -226,7 +226,7 @@ static int interpret_table_entry(char *line)
 				sprintf(path, "%s/%s%d", rootdir, name, i);
 				/* FIXME:  MKDEV uses illicit insider knowledge of kernel 
 				 * major/minor representation...  */
-				rdev = MKDEV(major, minor + (i * increment - start));
+				rdev = MKDEV(major, minor + (i - start) * increment);
 				add_new_device(buf, path, uid, gid, mode, rdev);
 			}
 		} else {
-- 
1.8.2.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/4] makedevs: Make the mode number readable in debug messages
  2013-05-29 14:55 [PATCH 0/4] Fixes for makedevs Peter Kjellerstedt
  2013-05-29 14:55 ` [PATCH 1/4] makedevs: Create blocks of devices with the correct uid/gid Peter Kjellerstedt
  2013-05-29 14:55 ` [PATCH 2/4] makedevs: Correct the device number calculation for blocks of devices Peter Kjellerstedt
@ 2013-05-29 14:55 ` Peter Kjellerstedt
  2013-05-29 14:56 ` [PATCH 4/4] makedevs: Avoid unnecessary timestamp calculation Peter Kjellerstedt
  2013-05-29 21:40 ` [PATCH 0/4] Fixes for makedevs Richard Purdie
  4 siblings, 0 replies; 7+ messages in thread
From: Peter Kjellerstedt @ 2013-05-29 14:55 UTC (permalink / raw)
  To: openembedded-core

---
 meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c b/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
index d58e891..4cfb1d5 100644
--- a/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
+++ b/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
@@ -108,7 +108,7 @@ static void add_new_directory(char *name, char *path,
 {
 	mkdir(path, mode);
 	chown(path, uid, gid);
-//	printf("Directory: %s %s  UID: %ld  GID %ld  MODE: %ld\n", path, name, uid, gid, mode);
+//	printf("Directory: %s %s  UID: %ld  GID %ld  MODE: %04lo\n", path, name, uid, gid, mode);
 }
 
 static void add_new_device(char *name, char *path, unsigned long uid, 
@@ -132,7 +132,7 @@ static void add_new_device(char *name, char *path, unsigned long uid,
 
 	mknod(path, mode, rdev);
 	chown(path, uid, gid);
-//	printf("Device: %s %s  UID: %ld  GID: %ld  MODE: %ld  MAJOR: %d  MINOR: %d\n",
+//	printf("Device: %s %s  UID: %ld  GID: %ld  MODE: %04lo  MAJOR: %d  MINOR: %d\n",
 //			path, name, uid, gid, mode, (short)(rdev >> 8), (short)(rdev & 0xff));
 }
 
@@ -147,7 +147,7 @@ static void add_new_file(char *name, char *path, unsigned long uid,
 	} 
 	chmod(path, mode);
 	chown(path, uid, gid);
-//	printf("File: %s %s  UID: %ld  GID: %ld  MODE: %ld\n",
+//	printf("File: %s %s  UID: %ld  GID: %ld  MODE: %04lo\n",
 //			path, name, gid, uid, mode);
 }
 
@@ -158,7 +158,7 @@ static void add_new_fifo(char *name, char *path, unsigned long uid,
 	if (mknod(path, mode, 0))
 		error_msg_and_die("%s: file can not be created with mknod!", path);
 	chown(path, uid, gid);
-//	printf("File: %s %s  UID: %ld  GID: %ld  MODE: %ld\n",
+//	printf("File: %s %s  UID: %ld  GID: %ld  MODE: %04lo\n",
 //			path, name, gid, uid, mode);
 }
 
-- 
1.8.2.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/4] makedevs: Avoid unnecessary timestamp calculation
  2013-05-29 14:55 [PATCH 0/4] Fixes for makedevs Peter Kjellerstedt
                   ` (2 preceding siblings ...)
  2013-05-29 14:55 ` [PATCH 3/4] makedevs: Make the mode number readable in debug messages Peter Kjellerstedt
@ 2013-05-29 14:56 ` Peter Kjellerstedt
  2013-05-29 21:40 ` [PATCH 0/4] Fixes for makedevs Richard Purdie
  4 siblings, 0 replies; 7+ messages in thread
From: Peter Kjellerstedt @ 2013-05-29 14:56 UTC (permalink / raw)
  To: openembedded-core

---
 meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c b/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
index 4cfb1d5..4bb316b 100644
--- a/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
+++ b/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
@@ -116,7 +116,6 @@ static void add_new_device(char *name, char *path, unsigned long uid,
 {
 	int status;
 	struct stat sb;
-	time_t timestamp = time(NULL);
 
 	memset(&sb, 0, sizeof(struct stat));
 	status = lstat(path, &sb);
@@ -127,7 +126,6 @@ static void add_new_device(char *name, char *path, unsigned long uid,
 		 * better match the actual file or strange things will happen.... */
 		if ((mode & S_IFMT) != (sb.st_mode & S_IFMT))
 			error_msg_and_die("%s: file type does not match specified type!", path);
-		timestamp = sb.st_mtime;
 	}
 
 	mknod(path, mode, rdev);
-- 
1.8.2.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/4] Fixes for makedevs
  2013-05-29 14:55 [PATCH 0/4] Fixes for makedevs Peter Kjellerstedt
                   ` (3 preceding siblings ...)
  2013-05-29 14:56 ` [PATCH 4/4] makedevs: Avoid unnecessary timestamp calculation Peter Kjellerstedt
@ 2013-05-29 21:40 ` Richard Purdie
  2013-05-30  7:29   ` Peter Kjellerstedt
  4 siblings, 1 reply; 7+ messages in thread
From: Richard Purdie @ 2013-05-29 21:40 UTC (permalink / raw)
  To: Peter Kjellerstedt; +Cc: openembedded-core

On Wed, 2013-05-29 at 16:55 +0200, Peter Kjellerstedt wrote:
> When I wanted to create devices from a package I stumbled upon a couple
> of problems with the makedevs program. Most notable was that it failed
> to set the correct uid/gid for devices created as part of a block (i.e.,
> with a count > 0).
> 
> The following changes since commit efb8a460d2a977dbd481a0650fba8eb637c65bec:
> 
>   package.bbclass: Fix sources contents (2013-05-14 08:52:47 +0300)
> 
> are available in the git repository at:
> 
>   git://git.yoctoproject.org/poky-contrib pkj/makedevs
>   http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=pkj/makedevs
> 
> Peter Kjellerstedt (4):
>   makedevs: Create blocks of devices with the correct uid/gid
>   makedevs: Correct the device number calculation for blocks of devices
>   makedevs: Make the mode number readable in debug messages
>   makedevs: Avoid unnecessary timestamp calculation

These look good to me but could you push a branch with signed-off-by
lines in the commits please?

Cheers,

Richard



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/4] Fixes for makedevs
  2013-05-29 21:40 ` [PATCH 0/4] Fixes for makedevs Richard Purdie
@ 2013-05-30  7:29   ` Peter Kjellerstedt
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Kjellerstedt @ 2013-05-30  7:29 UTC (permalink / raw)
  To: Richard Purdie; +Cc: openembedded-core@lists.openembedded.org

> -----Original Message-----
> From: Richard Purdie [mailto:richard.purdie@linuxfoundation.org]
> Sent: den 29 maj 2013 23:40
> To: Peter Kjellerstedt
> Cc: openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core] [PATCH 0/4] Fixes for makedevs
> 
> On Wed, 2013-05-29 at 16:55 +0200, Peter Kjellerstedt wrote:
> > When I wanted to create devices from a package I stumbled upon a couple
> > of problems with the makedevs program. Most notable was that it failed
> > to set the correct uid/gid for devices created as part of a block (i.e.,
> > with a count > 0).
> >
> > The following changes since commit efb8a460d2a977dbd481a0650fba8eb637c65bec:
> >
> >   package.bbclass: Fix sources contents (2013-05-14 08:52:47 +0300)
> >
> > are available in the git repository at:
> >
> >   git://git.yoctoproject.org/poky-contrib pkj/makedevs
> >   http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=pkj/makedevs
> >
> > Peter Kjellerstedt (4):
> >   makedevs: Create blocks of devices with the correct uid/gid
> >   makedevs: Correct the device number calculation for blocks of devices
> >   makedevs: Make the mode number readable in debug messages
> >   makedevs: Avoid unnecessary timestamp calculation
> 
> These look good to me but could you push a branch with signed-off-by
> lines in the commits please?
> 
> Cheers,
> 
> Richard

I have sent an updated pull request that add Signed-off-by lines now.

//Peter


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-05-30  7:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-29 14:55 [PATCH 0/4] Fixes for makedevs Peter Kjellerstedt
2013-05-29 14:55 ` [PATCH 1/4] makedevs: Create blocks of devices with the correct uid/gid Peter Kjellerstedt
2013-05-29 14:55 ` [PATCH 2/4] makedevs: Correct the device number calculation for blocks of devices Peter Kjellerstedt
2013-05-29 14:55 ` [PATCH 3/4] makedevs: Make the mode number readable in debug messages Peter Kjellerstedt
2013-05-29 14:56 ` [PATCH 4/4] makedevs: Avoid unnecessary timestamp calculation Peter Kjellerstedt
2013-05-29 21:40 ` [PATCH 0/4] Fixes for makedevs Richard Purdie
2013-05-30  7:29   ` Peter Kjellerstedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox