[ndctl,1/2] libdaxctl: fix the system-ram capability check
diff mbox series

Message ID 20190904010819.11012-1-vishal.l.verma@intel.com
State New
Headers show
Series
  • [ndctl,1/2] libdaxctl: fix the system-ram capability check
Related show

Commit Message

Verma, Vishal L Sept. 4, 2019, 1:08 a.m. UTC
When checking a daxctl device for system-ram capability, we needn't look
at the symlink resolution for /sys/bus/dax.../driver/module since the
driver in question may not always have an associated module, and could
be builtin instead.

Change the symlink we resolve to simply '/sys/bus/dax.../driver' and
since that too resolves to '.../kmem' in the system-ram case, the
rest of the check remains unchanged.

This is a pre-requisite to making daxctl-reconfigure-device work
correctly when the target mode's driver might be builtin.

Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 daxctl/lib/libdaxctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dan Williams Sept. 4, 2019, 2:21 a.m. UTC | #1
On Tue, Sep 3, 2019 at 6:08 PM Vishal Verma <vishal.l.verma@intel.com> wrote:
>
> When checking a daxctl device for system-ram capability, we needn't look
> at the symlink resolution for /sys/bus/dax.../driver/module since the
> driver in question may not always have an associated module, and could
> be builtin instead.
>
> Change the symlink we resolve to simply '/sys/bus/dax.../driver' and
> since that too resolves to '.../kmem' in the system-ram case, the
> rest of the check remains unchanged.
>
> This is a pre-requisite to making daxctl-reconfigure-device work
> correctly when the target mode's driver might be builtin.
>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> ---
>  daxctl/lib/libdaxctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
> index c0a859c..d9f2c33 100644
> --- a/daxctl/lib/libdaxctl.c
> +++ b/daxctl/lib/libdaxctl.c
> @@ -406,7 +406,7 @@ static int dev_is_system_ram_capable(struct daxctl_dev *dev)
>         if (!daxctl_dev_is_enabled(dev))
>                 return false;
>
> -       if (snprintf(path, len, "%s/driver/module", dev->dev_path) >= len) {
> +       if (snprintf(path, len, "%s/driver", dev->dev_path) >= len) {

Nice catch.

Reviewed-by: Dan Williams <dan.j.williams@intel.com>

Patch
diff mbox series

diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
index c0a859c..d9f2c33 100644
--- a/daxctl/lib/libdaxctl.c
+++ b/daxctl/lib/libdaxctl.c
@@ -406,7 +406,7 @@  static int dev_is_system_ram_capable(struct daxctl_dev *dev)
 	if (!daxctl_dev_is_enabled(dev))
 		return false;
 
-	if (snprintf(path, len, "%s/driver/module", dev->dev_path) >= len) {
+	if (snprintf(path, len, "%s/driver", dev->dev_path) >= len) {
 		err(ctx, "%s: buffer too small!\n", devname);
 		return false;
 	}