* Re: [PATCH v1] fs2dt: Refine kdump device_tree sort
@ 2014-06-17 6:01 ` Yang,Wei
0 siblings, 0 replies; 9+ messages in thread
From: Yang,Wei @ 2014-06-17 6:01 UTC (permalink / raw)
To: Wei.Yang, horms; +Cc: linux-kernel, linuxppc-dev, linux-arm-kernel
Hi Simon,
How about this patch?
Thanks
Wei
On 06/12/2014 01:16 PM, Wei.Yang@windriver.com wrote:
> From: Yang Wei <Wei.Yang@windriver.com>
>
> The commit b02d735bf was to rearrange the device-tree entries, and
> assumed that these entries are sorted in the ascending order. but
> acctually when I was validating kexec and kdump, the order of
> serial node still is changed. We should not only compare the length
> of directory name, but also compare the directory name, it would
> ensure that the order of device node is really in ascending order.
>
> Signed-off-by: Yang Wei <Wei.Yang@windriver.com>
> ---
> kexec/fs2dt.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> It is validated on Freescale t4240qds.
>
> diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
> index 1e5f074..0bffaf5 100644
> --- a/kexec/fs2dt.c
> +++ b/kexec/fs2dt.c
> @@ -479,6 +479,9 @@ static int comparefunc(const struct dirent **dentry1,
> {
> char *str1 = (*(struct dirent **)dentry1)->d_name;
> char *str2 = (*(struct dirent **)dentry2)->d_name;
> + char* ptr1 = strchr(str1, '@');
> + char* ptr2 = strchr(str2, '@');
> + int len1, len2;
>
> /*
> * strcmp scans from left to right and fails to idetify for some
> @@ -486,9 +489,13 @@ static int comparefunc(const struct dirent **dentry1,
> * Therefore, we get the wrong sorted order like memory@10000000 and
> * memory@f000000.
> */
> - if (strchr(str1, '@') && strchr(str2, '@') &&
> - (strlen(str1) > strlen(str2)))
> - return 1;
> + if (ptr1 && ptr2) {
> + len1 = ptr1 - str1;
> + len2 = ptr2 - str2;
> + if (!strncmp(str1, str2, len1 >len2 ? len1: len2) &&
> + (strlen(str1) > strlen(str2)))
> + return 1;
> + }
>
> return strcmp(str1, str2);
> }
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH v1] fs2dt: Refine kdump device_tree sort
@ 2014-06-17 6:01 ` Yang,Wei
0 siblings, 0 replies; 9+ messages in thread
From: Yang,Wei @ 2014-06-17 6:01 UTC (permalink / raw)
To: linux-arm-kernel
Hi Simon,
How about this patch?
Thanks
Wei
On 06/12/2014 01:16 PM, Wei.Yang at windriver.com wrote:
> From: Yang Wei <Wei.Yang@windriver.com>
>
> The commit b02d735bf was to rearrange the device-tree entries, and
> assumed that these entries are sorted in the ascending order. but
> acctually when I was validating kexec and kdump, the order of
> serial node still is changed. We should not only compare the length
> of directory name, but also compare the directory name, it would
> ensure that the order of device node is really in ascending order.
>
> Signed-off-by: Yang Wei <Wei.Yang@windriver.com>
> ---
> kexec/fs2dt.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> It is validated on Freescale t4240qds.
>
> diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
> index 1e5f074..0bffaf5 100644
> --- a/kexec/fs2dt.c
> +++ b/kexec/fs2dt.c
> @@ -479,6 +479,9 @@ static int comparefunc(const struct dirent **dentry1,
> {
> char *str1 = (*(struct dirent **)dentry1)->d_name;
> char *str2 = (*(struct dirent **)dentry2)->d_name;
> + char* ptr1 = strchr(str1, '@');
> + char* ptr2 = strchr(str2, '@');
> + int len1, len2;
>
> /*
> * strcmp scans from left to right and fails to idetify for some
> @@ -486,9 +489,13 @@ static int comparefunc(const struct dirent **dentry1,
> * Therefore, we get the wrong sorted order like memory at 10000000 and
> * memory at f000000.
> */
> - if (strchr(str1, '@') && strchr(str2, '@') &&
> - (strlen(str1) > strlen(str2)))
> - return 1;
> + if (ptr1 && ptr2) {
> + len1 = ptr1 - str1;
> + len2 = ptr2 - str2;
> + if (!strncmp(str1, str2, len1 >len2 ? len1: len2) &&
> + (strlen(str1) > strlen(str2)))
> + return 1;
> + }
>
> return strcmp(str1, str2);
> }
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v1] fs2dt: Refine kdump device_tree sort
2014-06-17 6:01 ` Yang,Wei
(?)
@ 2014-06-17 6:03 ` Yang,Wei
-1 siblings, 0 replies; 9+ messages in thread
From: Yang,Wei @ 2014-06-17 6:03 UTC (permalink / raw)
To: Yang,Wei, Wei.Yang, horms; +Cc: linuxppc-dev, linux-kernel, linux-arm-kernel
Simon, I missed "kexec" string in subject, so please ignore this
version. I would resend it with adding "kexec" in subject.
Thanks
Wei
On 06/17/2014 02:01 PM, Yang,Wei wrote:
> Hi Simon,
>
> How about this patch?
>
> Thanks
> Wei
> On 06/12/2014 01:16 PM, Wei.Yang@windriver.com wrote:
>> From: Yang Wei <Wei.Yang@windriver.com>
>>
>> The commit b02d735bf was to rearrange the device-tree entries, and
>> assumed that these entries are sorted in the ascending order. but
>> acctually when I was validating kexec and kdump, the order of
>> serial node still is changed. We should not only compare the length
>> of directory name, but also compare the directory name, it would
>> ensure that the order of device node is really in ascending order.
>>
>> Signed-off-by: Yang Wei <Wei.Yang@windriver.com>
>> ---
>> kexec/fs2dt.c | 13 ++++++++++---
>> 1 file changed, 10 insertions(+), 3 deletions(-)
>>
>> It is validated on Freescale t4240qds.
>>
>> diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
>> index 1e5f074..0bffaf5 100644
>> --- a/kexec/fs2dt.c
>> +++ b/kexec/fs2dt.c
>> @@ -479,6 +479,9 @@ static int comparefunc(const struct dirent
>> **dentry1,
>> {
>> char *str1 = (*(struct dirent **)dentry1)->d_name;
>> char *str2 = (*(struct dirent **)dentry2)->d_name;
>> + char* ptr1 = strchr(str1, '@');
>> + char* ptr2 = strchr(str2, '@');
>> + int len1, len2;
>> /*
>> * strcmp scans from left to right and fails to idetify for some
>> @@ -486,9 +489,13 @@ static int comparefunc(const struct dirent
>> **dentry1,
>> * Therefore, we get the wrong sorted order like
>> memory@10000000 and
>> * memory@f000000.
>> */
>> - if (strchr(str1, '@') && strchr(str2, '@') &&
>> - (strlen(str1) > strlen(str2)))
>> - return 1;
>> + if (ptr1 && ptr2) {
>> + len1 = ptr1 - str1;
>> + len2 = ptr2 - str2;
>> + if (!strncmp(str1, str2, len1 >len2 ? len1: len2) &&
>> + (strlen(str1) > strlen(str2)))
>> + return 1;
>> + }
>> return strcmp(str1, str2);
>> }
>
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v1] fs2dt: Refine kdump device_tree sort
@ 2014-06-17 6:03 ` Yang,Wei
0 siblings, 0 replies; 9+ messages in thread
From: Yang,Wei @ 2014-06-17 6:03 UTC (permalink / raw)
To: Yang,Wei, Wei.Yang, horms; +Cc: linux-kernel, linuxppc-dev, linux-arm-kernel
Simon, I missed "kexec" string in subject, so please ignore this
version. I would resend it with adding "kexec" in subject.
Thanks
Wei
On 06/17/2014 02:01 PM, Yang,Wei wrote:
> Hi Simon,
>
> How about this patch?
>
> Thanks
> Wei
> On 06/12/2014 01:16 PM, Wei.Yang@windriver.com wrote:
>> From: Yang Wei <Wei.Yang@windriver.com>
>>
>> The commit b02d735bf was to rearrange the device-tree entries, and
>> assumed that these entries are sorted in the ascending order. but
>> acctually when I was validating kexec and kdump, the order of
>> serial node still is changed. We should not only compare the length
>> of directory name, but also compare the directory name, it would
>> ensure that the order of device node is really in ascending order.
>>
>> Signed-off-by: Yang Wei <Wei.Yang@windriver.com>
>> ---
>> kexec/fs2dt.c | 13 ++++++++++---
>> 1 file changed, 10 insertions(+), 3 deletions(-)
>>
>> It is validated on Freescale t4240qds.
>>
>> diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
>> index 1e5f074..0bffaf5 100644
>> --- a/kexec/fs2dt.c
>> +++ b/kexec/fs2dt.c
>> @@ -479,6 +479,9 @@ static int comparefunc(const struct dirent
>> **dentry1,
>> {
>> char *str1 = (*(struct dirent **)dentry1)->d_name;
>> char *str2 = (*(struct dirent **)dentry2)->d_name;
>> + char* ptr1 = strchr(str1, '@');
>> + char* ptr2 = strchr(str2, '@');
>> + int len1, len2;
>> /*
>> * strcmp scans from left to right and fails to idetify for some
>> @@ -486,9 +489,13 @@ static int comparefunc(const struct dirent
>> **dentry1,
>> * Therefore, we get the wrong sorted order like
>> memory@10000000 and
>> * memory@f000000.
>> */
>> - if (strchr(str1, '@') && strchr(str2, '@') &&
>> - (strlen(str1) > strlen(str2)))
>> - return 1;
>> + if (ptr1 && ptr2) {
>> + len1 = ptr1 - str1;
>> + len2 = ptr2 - str2;
>> + if (!strncmp(str1, str2, len1 >len2 ? len1: len2) &&
>> + (strlen(str1) > strlen(str2)))
>> + return 1;
>> + }
>> return strcmp(str1, str2);
>> }
>
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH v1] fs2dt: Refine kdump device_tree sort
@ 2014-06-17 6:03 ` Yang,Wei
0 siblings, 0 replies; 9+ messages in thread
From: Yang,Wei @ 2014-06-17 6:03 UTC (permalink / raw)
To: linux-arm-kernel
Simon, I missed "kexec" string in subject, so please ignore this
version. I would resend it with adding "kexec" in subject.
Thanks
Wei
On 06/17/2014 02:01 PM, Yang,Wei wrote:
> Hi Simon,
>
> How about this patch?
>
> Thanks
> Wei
> On 06/12/2014 01:16 PM, Wei.Yang at windriver.com wrote:
>> From: Yang Wei <Wei.Yang@windriver.com>
>>
>> The commit b02d735bf was to rearrange the device-tree entries, and
>> assumed that these entries are sorted in the ascending order. but
>> acctually when I was validating kexec and kdump, the order of
>> serial node still is changed. We should not only compare the length
>> of directory name, but also compare the directory name, it would
>> ensure that the order of device node is really in ascending order.
>>
>> Signed-off-by: Yang Wei <Wei.Yang@windriver.com>
>> ---
>> kexec/fs2dt.c | 13 ++++++++++---
>> 1 file changed, 10 insertions(+), 3 deletions(-)
>>
>> It is validated on Freescale t4240qds.
>>
>> diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
>> index 1e5f074..0bffaf5 100644
>> --- a/kexec/fs2dt.c
>> +++ b/kexec/fs2dt.c
>> @@ -479,6 +479,9 @@ static int comparefunc(const struct dirent
>> **dentry1,
>> {
>> char *str1 = (*(struct dirent **)dentry1)->d_name;
>> char *str2 = (*(struct dirent **)dentry2)->d_name;
>> + char* ptr1 = strchr(str1, '@');
>> + char* ptr2 = strchr(str2, '@');
>> + int len1, len2;
>> /*
>> * strcmp scans from left to right and fails to idetify for some
>> @@ -486,9 +489,13 @@ static int comparefunc(const struct dirent
>> **dentry1,
>> * Therefore, we get the wrong sorted order like
>> memory at 10000000 and
>> * memory at f000000.
>> */
>> - if (strchr(str1, '@') && strchr(str2, '@') &&
>> - (strlen(str1) > strlen(str2)))
>> - return 1;
>> + if (ptr1 && ptr2) {
>> + len1 = ptr1 - str1;
>> + len2 = ptr2 - str2;
>> + if (!strncmp(str1, str2, len1 >len2 ? len1: len2) &&
>> + (strlen(str1) > strlen(str2)))
>> + return 1;
>> + }
>> return strcmp(str1, str2);
>> }
>
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread