All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Wei Gao <wegao@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] Add test for UI_GET_NAME ioctl
Date: Mon, 16 Oct 2023 17:49:34 +0200	[thread overview]
Message-ID: <ZS1bjvd84DVj9hUX@yuki> (raw)
In-Reply-To: <ZSoMsDNyf4Y+w8d3@wegao>

Hi!
> > > +static int check_ui_get_sysname_ioctl(int fd)
> > > +{
> > > +	char name[256];
> > > +
> > > +	SAFE_IOCTL(NULL, fd, UI_GET_SYSNAME(sizeof(name)), name, NULL);
> > > +
> > > +	DIR *test_dir;
> > > +
> > > +	struct dirent *ent;
> > > +
> > > +	test_dir = SAFE_OPENDIR(NULL, "/sys/devices/virtual/input/");
> > > +
> > > +	while ((ent = SAFE_READDIR(NULL, test_dir))) {
> > > +		if (!strcmp(ent->d_name, name))
> > > +			return 1;
> > > +		else
> > > +			continue;
> > > +	}
> > 
> > Why do we loop over the directory here? Can't we just directly check
> > that the path /sys/devices/virtual/input/$name/ exists?
> > 
> > I guess that we can as well read the
> > /sys/devices/virtual/input/$name/dev and match that against fstat() on
> > the fd.
> Seems no dev node can be found under /sys/devices/virtual/input/$name/.
> 
> ll /sys/devices/virtual/input/input13/
> total 0
> drwxr-xr-x 2 root root    0 Oct 13 21:32 capabilities
> drwxr-xr-x 3 root root    0 Oct 13 21:32 event8
> drwxr-xr-x 2 root root    0 Oct 13 21:32 id
> -rw-r--r-- 1 root root 4.0K Oct 13 21:33 inhibited
> -r--r--r-- 1 root root 4.0K Oct 13 21:33 modalias
> drwxr-xr-x 3 root root    0 Oct 13 21:32 mouse3
> -r--r--r-- 1 root root 4.0K Oct 13 21:32 name
> -r--r--r-- 1 root root 4.0K Oct 13 21:32 phys
> drwxr-xr-x 2 root root    0 Oct 13 21:33 power
> -r--r--r-- 1 root root 4.0K Oct 13 21:32 properties
> lrwxrwxrwx 1 root root    0 Oct 13 21:32 subsystem -> ../../../../class/input
> -rw-r--r-- 1 root root 4.0K Oct 13 21:32 uevent
> -r--r--r-- 1 root root 4.0K Oct 13 21:33 uniq

Ah, right, it's under the event8 directory in this case. I guess that we
can match name againts the VIRTUAL_DEVICE string instead.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2023-10-16 15:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12 11:13 [LTP] [PATCH v1] Add test for UI_GET_NAME ioctl Wei Gao via ltp
2023-10-12 11:25 ` [LTP] [PATCH v2] " Wei Gao via ltp
2023-10-12 14:05   ` Cyril Hrubis
2023-10-14  3:36     ` Wei Gao via ltp
2023-10-16 15:49       ` Cyril Hrubis [this message]
2023-10-16 23:52         ` Wei Gao via ltp
2023-10-14  3:31   ` [LTP] [PATCH v3] " Wei Gao via ltp
2023-10-17 11:08     ` Cyril Hrubis
2023-10-17 13:16     ` [LTP] [PATCH v4] " Wei Gao via ltp
2023-10-23 14:16       ` Cyril Hrubis
2023-10-24  9:10         ` [LTP] [CI FAILURE] " Petr Vorel
2023-10-24  9:33           ` Cyril Hrubis

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=ZS1bjvd84DVj9hUX@yuki \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=wegao@suse.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.