lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20080211184257.GA16773@enneenne.com>
Date:	Mon, 11 Feb 2008 19:42:57 +0100
From:	Rodolfo Giometti <giometti@...eenne.com>
To:	Greg KH <greg@...ah.com>
Cc:	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	David Woodhouse <dwmw2@...radead.org>,
	Dave Jones <davej@...hat.com>
Subject: Re: [PATCH 1/8] LinuxPPS core support.

On Mon, Feb 11, 2008 at 07:31:53PM +0100, Rodolfo Giometti wrote:
> Do you think is better create these files anyway and in case report a
> NULL string?

Is that ok?

/*
 * Attribute functions
 */

static ssize_t pps_show_assert(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	struct pps_device *pps = dev_get_drvdata(dev);

	if (!(pps->info.mode & PPS_CAPTUREASSERT))
		return 0;

	return sprintf(buf, "%lld.%09d#%d\n",
			pps->assert_tu.sec, pps->assert_tu.nsec,
			pps->assert_sequence);
}
DEVICE_ATTR(assert, S_IRUGO, pps_show_assert, NULL);

static ssize_t pps_show_clear(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	struct pps_device *pps = dev_get_drvdata(dev);

	if (!(pps->info.mode & PPS_CAPTURECLEAR))
		return 0;

	return sprintf(buf, "%lld.%09d#%d\n",
			pps->clear_tu.sec, pps->clear_tu.nsec,
			pps->clear_sequence);
}
DEVICE_ATTR(clear, S_IRUGO, pps_show_clear, NULL);

static ssize_t pps_show_mode(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	struct pps_device *pps = dev_get_drvdata(dev);

	return sprintf(buf, "%4x\n", pps->info.mode);
}
DEVICE_ATTR(mode, S_IRUGO, pps_show_mode, NULL);

...

static struct attribute *pps_attrs[] = {
	&dev_attr_mode.attr,
	&dev_attr_echo.attr,
	&dev_attr_name.attr,
	&dev_attr_path.attr,
	&dev_attr_assert.attr,
	&dev_attr_clear.attr,
	NULL
};

static struct attribute_group pps_group = {
	.attrs = pps_attrs,
};

/*
 * Public functions
 */

void pps_sysfs_remove_source_entry(struct pps_device *pps)
{
	/* Delete info files */
	sysfs_remove_group(&pps->dev->kobj, &pps_group);
}

int pps_sysfs_create_source_entry(struct pps_device *pps)
{
	int ret;

	/* Create info files */
	ret = sysfs_create_group(&pps->dev->kobj, &pps_group);
	if (ret)
		dev_err(pps->dev, "unable to create default sysfs entries");

	return 0;
}

Ciao,

Rodolfo

-- 

GNU/Linux Solutions                  e-mail:    giometti@...eenne.com
Linux Device Driver                             giometti@...dd.com
Embedded Systems                     		giometti@...ux.it
UNIX programming                     phone:     +39 349 2432127
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ