* [RESEND PATCH] selftests/overlayfs: fix compilation error in overlayfs
@ 2024-02-27 7:42 Meng Li
2024-02-27 16:41 ` Shuah Khan
0 siblings, 1 reply; 5+ messages in thread
From: Meng Li @ 2024-02-27 7:42 UTC (permalink / raw)
To: Shuah Khan, Andrei Vagin, Huang Rui, linux-pm
Cc: Nathan Fontenot, Deepak Sharma, Alex Deucher, Mario Limonciello,
Perry Yuan, Xiaojian Du, Viresh Kumar, Borislav Petkov,
linux-kernel, Meng Li
make -C tools/testing/selftests, compiling dev_in_maps fail.
In file included from dev_in_maps.c:10:
/usr/include/x86_64-linux-gnu/sys/mount.h:35:3: error: expected identifier before numeric constant
35 | MS_RDONLY = 1, /* Mount read-only. */
| ^~~~~~~~~
That sys/mount.h has to be included before linux/mount.h.
Signed-off-by: Meng Li <li.meng@amd.com>
---
tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
index e19ab0e85709..871a0923c06e 100644
--- a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
+++ b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
@@ -7,11 +7,11 @@
#include <linux/unistd.h>
#include <linux/types.h>
-#include <linux/mount.h>
#include <sys/syscall.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <sys/mman.h>
+#include <linux/mount.h>
#include <sched.h>
#include <fcntl.h>
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [RESEND PATCH] selftests/overlayfs: fix compilation error in overlayfs
2024-02-27 7:42 [RESEND PATCH] selftests/overlayfs: fix compilation error in overlayfs Meng Li
@ 2024-02-27 16:41 ` Shuah Khan
2024-02-27 21:20 ` Andrei Vagin
0 siblings, 1 reply; 5+ messages in thread
From: Shuah Khan @ 2024-02-27 16:41 UTC (permalink / raw)
To: Meng Li, Andrei Vagin, Huang Rui, linux-pm
Cc: Nathan Fontenot, Deepak Sharma, Alex Deucher, Mario Limonciello,
Perry Yuan, Xiaojian Du, Viresh Kumar, Borislav Petkov,
linux-kernel, open list:KERNEL SELFTEST FRAMEWORK
On 2/27/24 00:42, Meng Li wrote:
> make -C tools/testing/selftests, compiling dev_in_maps fail.
> In file included from dev_in_maps.c:10:
> /usr/include/x86_64-linux-gnu/sys/mount.h:35:3: error: expected identifier before numeric constant
> 35 | MS_RDONLY = 1, /* Mount read-only. */
> | ^~~~~~~~~
>
> That sys/mount.h has to be included before linux/mount.h.
>
> Signed-off-by: Meng Li <li.meng@amd.com>
> ---
> tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
I don't see this problem when I build it on my system when
I run:
make -C tools/testing/selftests
or
make -C tools/testing/selftests/filesystems/overlayfs
Are you running this after doing headers_install?
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RESEND PATCH] selftests/overlayfs: fix compilation error in overlayfs
2024-02-27 16:41 ` Shuah Khan
@ 2024-02-27 21:20 ` Andrei Vagin
2024-02-27 21:28 ` Shuah Khan
0 siblings, 1 reply; 5+ messages in thread
From: Andrei Vagin @ 2024-02-27 21:20 UTC (permalink / raw)
To: Shuah Khan
Cc: Meng Li, Huang Rui, linux-pm, Nathan Fontenot, Deepak Sharma,
Alex Deucher, Mario Limonciello, Perry Yuan, Xiaojian Du,
Viresh Kumar, Borislav Petkov, linux-kernel,
open list:KERNEL SELFTEST FRAMEWORK
On Tue, Feb 27, 2024 at 8:41 AM Shuah Khan <skhan@linuxfoundation.org> wrote:
>
> On 2/27/24 00:42, Meng Li wrote:
> > make -C tools/testing/selftests, compiling dev_in_maps fail.
> > In file included from dev_in_maps.c:10:
> > /usr/include/x86_64-linux-gnu/sys/mount.h:35:3: error: expected identifier before numeric constant
> > 35 | MS_RDONLY = 1, /* Mount read-only. */
> > | ^~~~~~~~~
> >
> > That sys/mount.h has to be included before linux/mount.h.
> >
> > Signed-off-by: Meng Li <li.meng@amd.com>
> > ---
> > tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
>
> I don't see this problem when I build it on my system when
> I run:
>
> make -C tools/testing/selftests
> or
> make -C tools/testing/selftests/filesystems/overlayfs
>
> Are you running this after doing headers_install?
It depends on libc headers. It can work with one libc and doesn't work
with another one. I have seen many times when linux headers conflicted
with libc headers. The only reliable way to avoid this sort of issues is
to include just one linux or libc header.
In this case, we can do something like this:
diff --git a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
index e19ab0e85709..f1ba82e52192 100644
--- a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
+++ b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
@@ -10,7 +10,6 @@
#include <linux/mount.h>
#include <sys/syscall.h>
#include <sys/stat.h>
-#include <sys/mount.h>
#include <sys/mman.h>
#include <sched.h>
#include <fcntl.h>
@@ -40,6 +39,14 @@ static int sys_move_mount(int from_dfd, const char
*from_pathname,
return syscall(__NR_move_mount, from_dfd, from_pathname,
to_dfd, to_pathname, flags);
}
+static int sys_mount(const char *source, const char *target,
+ const char *filesystemtype, unsigned long mountflags,
+ const void *data)
+{
+ return syscall(__NR_mount, source, target, filesystemtype,
mountflags, data);
+}
+
+
static long get_file_dev_and_inode(void *addr, struct statx *stx)
{
char buf[4096];
@@ -167,7 +174,7 @@ int main(int argc, char **argv)
return 1;
}
- if (mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) == -1) {
+ if (sys_mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) == -1) {
pr_perror("mount");
return 1;
}
Thanks,
Andrei
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [RESEND PATCH] selftests/overlayfs: fix compilation error in overlayfs
2024-02-27 21:20 ` Andrei Vagin
@ 2024-02-27 21:28 ` Shuah Khan
0 siblings, 0 replies; 5+ messages in thread
From: Shuah Khan @ 2024-02-27 21:28 UTC (permalink / raw)
To: Andrei Vagin
Cc: Meng Li, Huang Rui, linux-pm, Nathan Fontenot, Deepak Sharma,
Alex Deucher, Mario Limonciello, Perry Yuan, Xiaojian Du,
Viresh Kumar, Borislav Petkov, linux-kernel,
open list:KERNEL SELFTEST FRAMEWORK, Shuah Khan
On 2/27/24 14:20, Andrei Vagin wrote:
> On Tue, Feb 27, 2024 at 8:41 AM Shuah Khan <skhan@linuxfoundation.org> wrote:
>>
>> On 2/27/24 00:42, Meng Li wrote:
>>> make -C tools/testing/selftests, compiling dev_in_maps fail.
>>> In file included from dev_in_maps.c:10:
>>> /usr/include/x86_64-linux-gnu/sys/mount.h:35:3: error: expected identifier before numeric constant
>>> 35 | MS_RDONLY = 1, /* Mount read-only. */
>>> | ^~~~~~~~~
>>>
>>> That sys/mount.h has to be included before linux/mount.h.
>>>
>>> Signed-off-by: Meng Li <li.meng@amd.com>
>>> ---
>>> tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>
>> I don't see this problem when I build it on my system when
>> I run:
>>
>> make -C tools/testing/selftests
>> or
>> make -C tools/testing/selftests/filesystems/overlayfs
>>
>> Are you running this after doing headers_install?
>
> It depends on libc headers. It can work with one libc and doesn't work
> with another one. I have seen many times when linux headers conflicted
> with libc headers. The only reliable way to avoid this sort of issues is
> to include just one linux or libc header.
>
> In this case, we can do something like this:
>
> diff --git a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
> b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
> index e19ab0e85709..f1ba82e52192 100644
> --- a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
> +++ b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
> @@ -10,7 +10,6 @@
> #include <linux/mount.h>
> #include <sys/syscall.h>
> #include <sys/stat.h>
> -#include <sys/mount.h>
> #include <sys/mman.h>
> #include <sched.h>
> #include <fcntl.h>
> @@ -40,6 +39,14 @@ static int sys_move_mount(int from_dfd, const char
> *from_pathname,
> return syscall(__NR_move_mount, from_dfd, from_pathname,
> to_dfd, to_pathname, flags);
> }
>
> +static int sys_mount(const char *source, const char *target,
> + const char *filesystemtype, unsigned long mountflags,
> + const void *data)
> +{
> + return syscall(__NR_mount, source, target, filesystemtype,
> mountflags, data);
> +}
> +
> +
> static long get_file_dev_and_inode(void *addr, struct statx *stx)
> {
> char buf[4096];
> @@ -167,7 +174,7 @@ int main(int argc, char **argv)
> return 1;
> }
>
> - if (mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) == -1) {
> + if (sys_mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) == -1) {
> pr_perror("mount");
> return 1;
> }
>
This is definitely better solution to this problem than reordering
the includes only find another problem down the road.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 5+ messages in thread
* [RESEND PATCH] selftests/overlayfs: fix compilation error in overlayfs
@ 2024-02-20 5:59 Meng Li
0 siblings, 0 replies; 5+ messages in thread
From: Meng Li @ 2024-02-20 5:59 UTC (permalink / raw)
To: Rafael J . Wysocki, Huang Rui
Cc: linux-pm, linux-kernel, x86, linux-acpi, Shuah Khan,
linux-kselftest, Nathan Fontenot, Deepak Sharma, Alex Deucher,
Mario Limonciello, Shimmer Huang, Perry Yuan, Xiaojian Du,
Viresh Kumar, Borislav Petkov, Meng Li
make -C tools/testing/selftests, compiling dev_in_maps fail.
In file included from dev_in_maps.c:10:
/usr/include/x86_64-linux-gnu/sys/mount.h:35:3: error: expected identifier before numeric constant
35 | MS_RDONLY = 1, /* Mount read-only. */
| ^~~~~~~~~
That sys/mount.h has to be included before linux/mount.h.
Signed-off-by: Meng Li <li.meng@amd.com>
---
tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
index e19ab0e85709..871a0923c06e 100644
--- a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
+++ b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
@@ -7,11 +7,11 @@
#include <linux/unistd.h>
#include <linux/types.h>
-#include <linux/mount.h>
#include <sys/syscall.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <sys/mman.h>
+#include <linux/mount.h>
#include <sched.h>
#include <fcntl.h>
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-27 21:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-27 7:42 [RESEND PATCH] selftests/overlayfs: fix compilation error in overlayfs Meng Li
2024-02-27 16:41 ` Shuah Khan
2024-02-27 21:20 ` Andrei Vagin
2024-02-27 21:28 ` Shuah Khan
-- strict thread matches above, loose matches on Subject: below --
2024-02-20 5:59 Meng Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).