lkml.org 
[lkml]   [2018]   [Nov]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3] driver-staging: vsoc.c: Add sysfs support for examining the permissions of regions.
On Wed, Nov 07, 2018 at 10:30:43AM +0800, Jerry Lin wrote:
> Add a attribute called permissions under vsoc device node for examining
> current granted permissions in vsoc_device.
>
> This file will display permissions in following format:
> begin_offset end_offset owner_offset owned_value
> %x %x %x %x
>

(I'm not totally an expert on sysfs rules).

Sysfs are supposed to be one value per file, so instead of doing this
you would create a directory with four files like
vsoc_device/begin_offset vsoc_device/end_offset etc. And each would
just hae a %x output.

> +static ssize_t permissions_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buffer)
> +{
> + struct fd_scoped_permission_node *node;
> + char *row;
> + int ret;
> + ssize_t written = 0;
> +
> + row = kzalloc(sizeof(char) * 128, GFP_KERNEL);
> + if (!row)
> + return 0;

Don't allocate this, just snprintf() directly into the buffer.

regards,
dan carpenter

\
 
 \ /
  Last update: 2018-11-09 18:16    [W:0.095 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site