All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] init-install*: /etc/mtab make a link rather than a copy
@ 2016-07-28  8:49 Awais Belal
  2016-07-28 17:01 ` Khem Raj
  2016-07-28 21:00 ` Andre McCurdy
  0 siblings, 2 replies; 6+ messages in thread
From: Awais Belal @ 2016-07-28  8:49 UTC (permalink / raw)
  To: openembedded-core

Using a copy would only make management of devices erroneous
and makes the system unstable in some scenarios as tools will
have to manipulate both files separately. A link ensures that
both files /proc/mounts and /etc/mtab will have the same
information at all times and this is how it is handled
on newer systems where there is such a need. Same is
suggested by busybox.

Signed-off-by: Awais Belal <awais_belal@mentor.com>
---
 meta/recipes-core/initrdscripts/files/init-install-efi.sh | 2 +-
 meta/recipes-core/initrdscripts/files/init-install.sh     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
index f564f4e..53f6508 100644
--- a/meta/recipes-core/initrdscripts/files/init-install-efi.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
@@ -123,7 +123,7 @@ mkdir -p /tmp
 
 # Create /etc/mtab if not present
 if [ ! -e /etc/mtab ]; then
-    cat /proc/mounts > /etc/mtab
+    ln -sf /etc/mtab /proc/mounts
 fi
 
 disk_size=$(parted ${device} unit mb print | grep '^Disk .*: .*MB' | cut -d" " -f 3 | sed -e "s/MB//")
diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh
index 72ce92b..21ae0a6 100644
--- a/meta/recipes-core/initrdscripts/files/init-install.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install.sh
@@ -119,7 +119,7 @@ fi
 
 mkdir -p /tmp
 if [ ! -L /etc/mtab ]; then
-    cat /proc/mounts > /etc/mtab
+    ln -sf /etc/mtab /proc/mounts
 fi
 
 disk_size=$(parted ${device} unit mb print | grep '^Disk .*: .*MB' | cut -d" " -f 3 | sed -e "s/MB//")
-- 
1.9.1



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

* Re: [PATCH] init-install*: /etc/mtab make a link rather than a copy
  2016-07-28  8:49 [PATCH] init-install*: /etc/mtab make a link rather than a copy Awais Belal
@ 2016-07-28 17:01 ` Khem Raj
  2016-07-29 10:17   ` Belal, Awais
  2016-07-28 21:00 ` Andre McCurdy
  1 sibling, 1 reply; 6+ messages in thread
From: Khem Raj @ 2016-07-28 17:01 UTC (permalink / raw)
  To: Awais Belal; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 2227 bytes --]


> On Jul 28, 2016, at 1:49 AM, Awais Belal <awais_belal@mentor.com> wrote:
> 
> Using a copy would only make management of devices erroneous
> and makes the system unstable in some scenarios as tools will
> have to manipulate both files separately. A link ensures that
> both files /proc/mounts and /etc/mtab will have the same
> information at all times and this is how it is handled
> on newer systems where there is such a need. Same is
> suggested by busybox.
> 
> Signed-off-by: Awais Belal <awais_belal@mentor.com>
> ---
> meta/recipes-core/initrdscripts/files/init-install-efi.sh | 2 +-
> meta/recipes-core/initrdscripts/files/init-install.sh     | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
> index f564f4e..53f6508 100644
> --- a/meta/recipes-core/initrdscripts/files/init-install-efi.sh
> +++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
> @@ -123,7 +123,7 @@ mkdir -p /tmp
> 
> # Create /etc/mtab if not present
> if [ ! -e /etc/mtab ]; then
> -    cat /proc/mounts > /etc/mtab
> +    ln -sf /etc/mtab /proc/mounts
> fi

I think this does not consider the case where procfs may be disabled in kernel. Is there such a possibility ?

> 
> disk_size=$(parted ${device} unit mb print | grep '^Disk .*: .*MB' | cut -d" " -f 3 | sed -e "s/MB//")
> diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh
> index 72ce92b..21ae0a6 100644
> --- a/meta/recipes-core/initrdscripts/files/init-install.sh
> +++ b/meta/recipes-core/initrdscripts/files/init-install.sh
> @@ -119,7 +119,7 @@ fi
> 
> mkdir -p /tmp
> if [ ! -L /etc/mtab ]; then
> -    cat /proc/mounts > /etc/mtab
> +    ln -sf /etc/mtab /proc/mounts
> fi
> 
> disk_size=$(parted ${device} unit mb print | grep '^Disk .*: .*MB' | cut -d" " -f 3 | sed -e "s/MB//")
> --
> 1.9.1
> 
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core


[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 211 bytes --]

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

* Re: [PATCH] init-install*: /etc/mtab make a link rather than a copy
  2016-07-28  8:49 [PATCH] init-install*: /etc/mtab make a link rather than a copy Awais Belal
  2016-07-28 17:01 ` Khem Raj
@ 2016-07-28 21:00 ` Andre McCurdy
  2016-07-29 10:18   ` Belal, Awais
  1 sibling, 1 reply; 6+ messages in thread
From: Andre McCurdy @ 2016-07-28 21:00 UTC (permalink / raw)
  To: Awais Belal; +Cc: OE Core mailing list

On Thu, Jul 28, 2016 at 1:49 AM, Awais Belal <awais_belal@mentor.com> wrote:
> Using a copy would only make management of devices erroneous
> and makes the system unstable in some scenarios as tools will
> have to manipulate both files separately. A link ensures that
> both files /proc/mounts and /etc/mtab will have the same
> information at all times and this is how it is handled
> on newer systems where there is such a need. Same is
> suggested by busybox.
>
> Signed-off-by: Awais Belal <awais_belal@mentor.com>
> ---
>  meta/recipes-core/initrdscripts/files/init-install-efi.sh | 2 +-
>  meta/recipes-core/initrdscripts/files/init-install.sh     | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
> index f564f4e..53f6508 100644
> --- a/meta/recipes-core/initrdscripts/files/init-install-efi.sh
> +++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
> @@ -123,7 +123,7 @@ mkdir -p /tmp
>
>  # Create /etc/mtab if not present
>  if [ ! -e /etc/mtab ]; then
> -    cat /proc/mounts > /etc/mtab
> +    ln -sf /etc/mtab /proc/mounts

Did you mean:

  ln -sf /proc/mounts /etc/mtab

?

>  fi
>
>  disk_size=$(parted ${device} unit mb print | grep '^Disk .*: .*MB' | cut -d" " -f 3 | sed -e "s/MB//")
> diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh
> index 72ce92b..21ae0a6 100644
> --- a/meta/recipes-core/initrdscripts/files/init-install.sh
> +++ b/meta/recipes-core/initrdscripts/files/init-install.sh
> @@ -119,7 +119,7 @@ fi
>
>  mkdir -p /tmp
>  if [ ! -L /etc/mtab ]; then
> -    cat /proc/mounts > /etc/mtab
> +    ln -sf /etc/mtab /proc/mounts
>  fi
>
>  disk_size=$(parted ${device} unit mb print | grep '^Disk .*: .*MB' | cut -d" " -f 3 | sed -e "s/MB//")
> --
> 1.9.1
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core


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

* Re: [PATCH] init-install*: /etc/mtab make a link rather than a copy
  2016-07-28 17:01 ` Khem Raj
@ 2016-07-29 10:17   ` Belal, Awais
  2016-07-29 18:35     ` Khem Raj
  0 siblings, 1 reply; 6+ messages in thread
From: Belal, Awais @ 2016-07-29 10:17 UTC (permalink / raw)
  To: Khem Raj; +Cc: openembedded-core

>> On Jul 28, 2016, at 1:49 AM, Awais Belal <awais_belal@mentor.com> wrote:
>>
>> Using a copy would only make management of devices erroneous
>> and makes the system unstable in some scenarios as tools will
>> have to manipulate both files separately. A link ensures that
>> both files /proc/mounts and /etc/mtab will have the same
>> information at all times and this is how it is handled
>> on newer systems where there is such a need. Same is
>> suggested by busybox.
>>
>> Signed-off-by: Awais Belal <awais_belal@mentor.com>
>> ---
>> meta/recipes-core/initrdscripts/files/init-install-efi.sh | 2 +-
>> meta/recipes-core/initrdscripts/files/init-install.sh     | 2 +-
>> 2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
>> index f564f4e..53f6508 100644
>> --- a/meta/recipes-core/initrdscripts/files/init-install-efi.sh
>> +++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
>> @@ -123,7 +123,7 @@ mkdir -p /tmp
>>
>> # Create /etc/mtab if not present
>> if [ ! -e /etc/mtab ]; then
>> -    cat /proc/mounts > /etc/mtab
>> +    ln -sf /etc/mtab /proc/mounts
>> fi

> I think this does not consider the case where procfs may be disabled in kernel. Is there such a possibility ?

Well in such a case at least mtab should be available so the link won't be created.

>>
>> disk_size=$(parted ${device} unit mb print | grep '^Disk .*: .*MB' | cut -d" " -f 3 | sed -e "s/MB//")
>> diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh
>> index 72ce92b..21ae0a6 100644
>> --- a/meta/recipes-core/initrdscripts/files/init-install.sh
>> +++ b/meta/recipes-core/initrdscripts/files/init-install.sh
>> @@ -119,7 +119,7 @@ fi
>>
>> mkdir -p /tmp
>> if [ ! -L /etc/mtab ]; then
>> -    cat /proc/mounts > /etc/mtab
>> +    ln -sf /etc/mtab /proc/mounts
>> fi
>>
>> disk_size=$(parted ${device} unit mb print | grep '^Disk .*: .*MB' | cut -d" " -f 3 | sed -e "s/MB//")
>> --
>> 1.9.1
>>
>> --
>> _______________________________________________
>> Openembedded-core mailing list
>> Openembedded-core@lists.openembedded.org
>> http://lists.openembedded.org/mailman/listinfo/openembedded-core

BR,
Awais

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

* Re: [PATCH] init-install*: /etc/mtab make a link rather than a copy
  2016-07-28 21:00 ` Andre McCurdy
@ 2016-07-29 10:18   ` Belal, Awais
  0 siblings, 0 replies; 6+ messages in thread
From: Belal, Awais @ 2016-07-29 10:18 UTC (permalink / raw)
  To: Andre McCurdy; +Cc: OE Core mailing list

Good catch Andre... I did a local update but forgot to send the v2. I'll do so now.

BR,
Awais

________________________________________
From: Andre McCurdy [armccurdy@gmail.com]
Sent: Friday, July 29, 2016 2:00 AM
To: Belal, Awais
Cc: OE Core mailing list
Subject: Re: [OE-core] [PATCH] init-install*: /etc/mtab make a link rather than a copy

On Thu, Jul 28, 2016 at 1:49 AM, Awais Belal <awais_belal@mentor.com> wrote:
> Using a copy would only make management of devices erroneous
> and makes the system unstable in some scenarios as tools will
> have to manipulate both files separately. A link ensures that
> both files /proc/mounts and /etc/mtab will have the same
> information at all times and this is how it is handled
> on newer systems where there is such a need. Same is
> suggested by busybox.
>
> Signed-off-by: Awais Belal <awais_belal@mentor.com>
> ---
>  meta/recipes-core/initrdscripts/files/init-install-efi.sh | 2 +-
>  meta/recipes-core/initrdscripts/files/init-install.sh     | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
> index f564f4e..53f6508 100644
> --- a/meta/recipes-core/initrdscripts/files/init-install-efi.sh
> +++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
> @@ -123,7 +123,7 @@ mkdir -p /tmp
>
>  # Create /etc/mtab if not present
>  if [ ! -e /etc/mtab ]; then
> -    cat /proc/mounts > /etc/mtab
> +    ln -sf /etc/mtab /proc/mounts

Did you mean:

  ln -sf /proc/mounts /etc/mtab

?

>  fi
>
>  disk_size=$(parted ${device} unit mb print | grep '^Disk .*: .*MB' | cut -d" " -f 3 | sed -e "s/MB//")
> diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh
> index 72ce92b..21ae0a6 100644
> --- a/meta/recipes-core/initrdscripts/files/init-install.sh
> +++ b/meta/recipes-core/initrdscripts/files/init-install.sh
> @@ -119,7 +119,7 @@ fi
>
>  mkdir -p /tmp
>  if [ ! -L /etc/mtab ]; then
> -    cat /proc/mounts > /etc/mtab
> +    ln -sf /etc/mtab /proc/mounts
>  fi
>
>  disk_size=$(parted ${device} unit mb print | grep '^Disk .*: .*MB' | cut -d" " -f 3 | sed -e "s/MB//")
> --
> 1.9.1
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core


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

* Re: [PATCH] init-install*: /etc/mtab make a link rather than a copy
  2016-07-29 10:17   ` Belal, Awais
@ 2016-07-29 18:35     ` Khem Raj
  0 siblings, 0 replies; 6+ messages in thread
From: Khem Raj @ 2016-07-29 18:35 UTC (permalink / raw)
  To: Belal, Awais; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 2641 bytes --]


> On Jul 29, 2016, at 3:17 AM, Belal, Awais <Awais_Belal@mentor.com> wrote:
> 
>>> On Jul 28, 2016, at 1:49 AM, Awais Belal <awais_belal@mentor.com> wrote:
>>> 
>>> Using a copy would only make management of devices erroneous
>>> and makes the system unstable in some scenarios as tools will
>>> have to manipulate both files separately. A link ensures that
>>> both files /proc/mounts and /etc/mtab will have the same
>>> information at all times and this is how it is handled
>>> on newer systems where there is such a need. Same is
>>> suggested by busybox.
>>> 
>>> Signed-off-by: Awais Belal <awais_belal@mentor.com>
>>> ---
>>> meta/recipes-core/initrdscripts/files/init-install-efi.sh | 2 +-
>>> meta/recipes-core/initrdscripts/files/init-install.sh     | 2 +-
>>> 2 files changed, 2 insertions(+), 2 deletions(-)
>>> 
>>> diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
>>> index f564f4e..53f6508 100644
>>> --- a/meta/recipes-core/initrdscripts/files/init-install-efi.sh
>>> +++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
>>> @@ -123,7 +123,7 @@ mkdir -p /tmp
>>> 
>>> # Create /etc/mtab if not present
>>> if [ ! -e /etc/mtab ]; then
>>> -    cat /proc/mounts > /etc/mtab
>>> +    ln -sf /etc/mtab /proc/mounts
>>> fi
> 
>> I think this does not consider the case where procfs may be disabled in kernel. Is there such a possibility ?
> 
> Well in such a case at least mtab should be available so the link won't be created.

we are checking for /etc/mtab and not /proc/mtab so no.
Secondly, it seems the symlink needs to be reversed.

> 
>>> 
>>> disk_size=$(parted ${device} unit mb print | grep '^Disk .*: .*MB' | cut -d" " -f 3 | sed -e "s/MB//")
>>> diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh
>>> index 72ce92b..21ae0a6 100644
>>> --- a/meta/recipes-core/initrdscripts/files/init-install.sh
>>> +++ b/meta/recipes-core/initrdscripts/files/init-install.sh
>>> @@ -119,7 +119,7 @@ fi
>>> 
>>> mkdir -p /tmp
>>> if [ ! -L /etc/mtab ]; then
>>> -    cat /proc/mounts > /etc/mtab
>>> +    ln -sf /etc/mtab /proc/mounts
>>> fi
>>> 
>>> disk_size=$(parted ${device} unit mb print | grep '^Disk .*: .*MB' | cut -d" " -f 3 | sed -e "s/MB//")
>>> --
>>> 1.9.1
>>> 
>>> --
>>> _______________________________________________
>>> Openembedded-core mailing list
>>> Openembedded-core@lists.openembedded.org
>>> http://lists.openembedded.org/mailman/listinfo/openembedded-core
> 
> BR,
> Awais


[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 211 bytes --]

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

end of thread, other threads:[~2016-07-29 18:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-28  8:49 [PATCH] init-install*: /etc/mtab make a link rather than a copy Awais Belal
2016-07-28 17:01 ` Khem Raj
2016-07-29 10:17   ` Belal, Awais
2016-07-29 18:35     ` Khem Raj
2016-07-28 21:00 ` Andre McCurdy
2016-07-29 10:18   ` Belal, Awais

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.