aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fs.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r--include/linux/fs.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 0180102dace1..e5a8db00df29 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -674,6 +674,7 @@ struct file_lock {
674 struct lock_manager_operations *fl_lmops; /* Callbacks for lockmanagers */ 674 struct lock_manager_operations *fl_lmops; /* Callbacks for lockmanagers */
675 union { 675 union {
676 struct nfs_lock_info nfs_fl; 676 struct nfs_lock_info nfs_fl;
677 struct nfs4_lock_info nfs4_fl;
677 } fl_u; 678 } fl_u;
678}; 679};
679 680
@@ -1657,6 +1658,52 @@ static inline void simple_transaction_set(struct file *file, size_t n)
1657 ar->size = n; 1658 ar->size = n;
1658} 1659}
1659 1660
1661/*
1662 * simple attribute files
1663 *
1664 * These attributes behave similar to those in sysfs:
1665 *
1666 * Writing to an attribute immediately sets a value, an open file can be
1667 * written to multiple times.
1668 *
1669 * Reading from an attribute creates a buffer from the value that might get
1670 * read with multiple read calls. When the attribute has been read
1671 * completely, no further read calls are possible until the file is opened
1672 * again.
1673 *
1674 * All attributes contain a text representation of a numeric value
1675 * that are accessed with the get() and set() functions.
1676 */
1677#define DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt) \
1678static int __fops ## _open(struct inode *inode, struct file *file) \
1679{ \
1680 __simple_attr_check_format(__fmt, 0ull); \
1681 return simple_attr_open(inode, file, __get, __set, __fmt); \
1682} \
1683static struct file_operations __fops = { \
1684 .owner = THIS_MODULE, \
1685 .open = __fops ## _open, \
1686 .release = simple_attr_close, \
1687 .read = simple_attr_read, \
1688 .write = simple_attr_write, \
1689};
1690
1691static inline void __attribute__((format(printf, 1, 2)))
1692__simple_attr_check_format(const char *fmt, ...)
1693{
1694 /* don't do anything, just let the compiler check the arguments; */
1695}
1696
1697int simple_attr_open(struct inode *inode, struct file *file,
1698 u64 (*get)(void *), void (*set)(void *, u64),
1699 const char *fmt);
1700int simple_attr_close(struct inode *inode, struct file *file);
1701ssize_t simple_attr_read(struct file *file, char __user *buf,
1702 size_t len, loff_t *ppos);
1703ssize_t simple_attr_write(struct file *file, const char __user *buf,
1704 size_t len, loff_t *ppos);
1705
1706
1660#ifdef CONFIG_SECURITY 1707#ifdef CONFIG_SECURITY
1661static inline char *alloc_secdata(void) 1708static inline char *alloc_secdata(void)
1662{ 1709{