Changes in 4.19.89
rsi: release skb if rsi_prepare_beacon fails
arm64: tegra: Fix 'active-low' warning for Jetson TX1 regulator
sparc64: implement ioremap_uc
lp: fix sparc64 LPSETTIMEOUT ioctl
usb: gadget: u_serial: add missing port entry locking
tty: serial: fsl_lpuart: use the sg count from dma_map_sg
tty: serial: msm_serial: Fix flow control
serial: pl011: Fix DMA ->flush_buffer()
serial: serial_core: Perform NULL checks for break_ctl ops
serial: ifx6x60: add missed pm_runtime_disable
autofs: fix a leak in autofs_expire_indirect()
RDMA/hns: Correct the value of HNS_ROCE_HEM_CHUNK_LEN
iwlwifi: pcie: don't consider IV len in A-MSDU
exportfs_decode_fh(): negative pinned may become positive without the parent locked
audit_get_nd(): don't unlock parent too early
NFC: nxp-nci: Fix NULL pointer dereference after I2C communication error
xfrm: release device reference for invalid state
Input: cyttsp4_core - fix use after free bug
sched/core: Avoid spurious lock dependencies
perf/core: Consistently fail fork on allocation failures
ALSA: pcm: Fix stream lock usage in snd_pcm_period_elapsed()
drm/sun4i: tcon: Set min division of TCON0_DCLK to 1.
selftests: kvm: fix build with glibc >= 2.30
rsxx: add missed destroy_workqueue calls in remove
net: ep93xx_eth: fix mismatch of request_mem_region in remove
i2c: core: fix use after free in of_i2c_notify
serial: core: Allow processing sysrq at port unlock time
cxgb4vf: fix memleak in mac_hlist initialization
iwlwifi: mvm: synchronize TID queue removal
iwlwifi: trans: Clear persistence bit when starting the FW
iwlwifi: mvm: Send non offchannel traffic via AP sta
ARM: 8813/1: Make aligned 2-byte getuser()/putuser() atomic on ARMv6+
audit: Embed key into chunk
netfilter: nf_tables: don't use position attribute on rule replacement
ARC: IOC: panic if kernel was started with previously enabled IOC
net/mlx5: Release resource on error flow
clk: sunxi-ng: a64: Fix gate bit of DSI DPHY
ice: Fix NVM mask defines
dlm: fix possible call to kfree() for non-initialized pointer
ARM: dts: exynos: Fix LDO13 min values on Odroid XU3/XU4/HC1
extcon: max8997: Fix lack of path setting in USB device mode
net: ethernet: ti: cpts: correct debug for expired txq skb
rtc: s3c-rtc: Avoid using broken ALMYEAR register
rtc: max77686: Fix the returned value in case of error in 'max77686_rtc_read_time()'
i40e: don't restart nway if autoneg not supported
virtchnl: Fix off by one error
clk: rockchip: fix rk3188 sclk_smc gate data
clk: rockchip: fix rk3188 sclk_mac_lbtest parameter ordering
ARM: dts: rockchip: Fix rk3288-rock2 vcc_flash name
dlm: fix missing idr_destroy for recover_idr
MIPS: SiByte: Enable ZONE_DMA32 for LittleSur
net: dsa: mv88e6xxx: Work around mv886e6161 SERDES missing MII_PHYSID2
scsi: zfcp: update kernel message for invalid FCP_CMND length, it's not the CDB
scsi: zfcp: drop default switch case which might paper over missing case
drivers: soc: Allow building the amlogic drivers without ARCH_MESON
bus: ti-sysc: Fix getting optional clocks in clock_roles
ARM: dts: imx6: RDU2: fix eGalax touchscreen node
crypto: ecc - check for invalid values in the key verification test
crypto: bcm - fix normal/non key hash algorithm failure
arm64: dts: zynqmp: Fix node names which contain "_"
pinctrl: qcom: ssbi-gpio: fix gpio-hog related boot issues
Staging: iio: adt7316: Fix i2c data reading, set the data field
firmware: raspberrypi: Fix firmware calls with large buffers
mm/vmstat.c: fix NUMA statistics updates
clk: rockchip: fix I2S1 clock gate register for rk3328
clk: rockchip: fix ID of 8ch clock of I2S1 for rk3328
sctp: count sk_wmem_alloc by skb truesize in sctp_packet_transmit
regulator: Fix return value of _set_load() stub
USB: serial: f81534: fix reading old/new IC config
xfs: extent shifting doesn't fully invalidate page cache
net-next/hinic:fix a bug in set mac address
net-next/hinic: fix a bug in rx data flow
ice: Fix return value from NAPI poll
ice: Fix possible NULL pointer de-reference
iomap: FUA is wrong for DIO O_DSYNC writes into unwritten extents
iomap: sub-block dio needs to zeroout beyond EOF
iomap: dio data corruption and spurious errors when pipes fill
iomap: readpages doesn't zero page tail beyond EOF
iw_cxgb4: only reconnect with MPAv1 if the peer aborts
MIPS: OCTEON: octeon-platform: fix typing
net/smc: use after free fix in smc_wr_tx_put_slot()
math-emu/soft-fp.h: (_FP_ROUND_ZERO) cast 0 to void to fix warning
nds32: Fix the items of hwcap_str ordering issue.
rtc: max8997: Fix the returned value in case of error in 'max8997_rtc_read_alarm()'
rtc: dt-binding: abx80x: fix resistance scale
ARM: dts: exynos: Use Samsung SoC specific compatible for DWC2 module
media: coda: fix memory corruption in case more than 32 instances are opened
media: pulse8-cec: return 0 when invalidating the logical address
media: cec: report Vendor ID after initialization
iwlwifi: fix cfg structs for 22000 with different RF modules
ravb: Clean up duplex handling
net/ipv6: re-do dad when interface has IFF_NOARP flag change
dmaengine: coh901318: Fix a double-lock bug
dmaengine: coh901318: Remove unused variable
dmaengine: dw-dmac: implement dma protection control setting
net: qualcomm: rmnet: move null check on dev before dereferecing it
selftests/powerpc: Allocate base registers
selftests/powerpc: Skip test instead of failing
usb: dwc3: debugfs: Properly print/set link state for HS
usb: dwc3: don't log probe deferrals; but do log other error codes
ACPI: fix acpi_find_child_device() invocation in acpi_preset_companion()
f2fs: fix to account preflush command for noflush_merge mode
f2fs: fix count of seg_freed to make sec_freed correct
f2fs: change segment to section in f2fs_ioc_gc_range
ARM: dts: rockchip: Fix the PMU interrupt number for rv1108
ARM: dts: rockchip: Assign the proper GPIO clocks for rv1108
f2fs: fix to allow node segment for GC by ioctl path
sparc: Fix JIT fused branch convergance.
sparc: Correct ctx->saw_frame_pointer logic.
nvme: Free ctrl device name on init failure
dma-mapping: fix return type of dma_set_max_seg_size()
slimbus: ngd: Fix build error on x86
altera-stapl: check for a null key before strcasecmp'ing it
serial: imx: fix error handling in console_setup
i2c: imx: don't print error message on probe defer
clk: meson: Fix GXL HDMI PLL fractional bits width
gpu: host1x: Fix syncpoint ID field size on Tegra186
lockd: fix decoding of TEST results
sctp: increase sk_wmem_alloc when head->truesize is increased
iommu/amd: Fix line-break in error log reporting
ASoC: rsnd: tidyup registering method for rsnd_kctrl_new()
ARM: dts: sun4i: Fix gpio-keys warning
ARM: dts: sun4i: Fix HDMI output DTC warning
ARM: dts: sun5i: a10s: Fix HDMI output DTC warning
ARM: dts: r8a779[01]: Disable unconnected LVDS encoders
ARM: dts: sun7i: Fix HDMI output DTC warning
ARM: dts: sun8i: a23/a33: Fix OPP DTC warnings
ARM: dts: sun8i: v3s: Change pinctrl nodes to avoid warning
dlm: NULL check before kmem_cache_destroy is not needed
ARM: debug: enable UART1 for socfpga Cyclone5
can: xilinx: fix return type of ndo_start_xmit function
nfsd: fix a warning in __cld_pipe_upcall()
bpf: btf: implement btf_name_valid_identifier()
bpf: btf: check name validity for various types
tools: bpftool: fix a bitfield pretty print issue
ASoC: au8540: use 64-bit arithmetic instead of 32-bit
ARM: OMAP1/2: fix SoC name printing
arm64: dts: meson-gxl-libretech-cc: fix GPIO lines names
arm64: dts: meson-gxbb-nanopi-k2: fix GPIO lines names
arm64: dts: meson-gxbb-odroidc2: fix GPIO lines names
arm64: dts: meson-gxl-khadas-vim: fix GPIO lines names
net/x25: fix called/calling length calculation in x25_parse_address_block
net/x25: fix null_x25_address handling
tools/bpf: make libbpf _GNU_SOURCE friendly
clk: mediatek: Drop __init from mtk_clk_register_cpumuxes()
clk: mediatek: Drop more __init markings for driver probe
soc: renesas: r8a77970-sysc: Correct names of A2DP/A2CN power domains
soc: renesas: r8a77980-sysc: Correct names of A2DP[01] power domains
soc: renesas: r8a77980-sysc: Correct A3VIP[012] power domain hierarchy
kbuild: disable dtc simple_bus_reg warnings by default
tcp: make tcp_space() aware of socket backlog
ARM: dts: mmp2: fix the gpio interrupt cell number
ARM: dts: realview-pbx: Fix duplicate regulator nodes
tcp: fix off-by-one bug on aborting window-probing socket
tcp: fix SNMP under-estimation on failed retransmission
tcp: fix SNMP TCP timeout under-estimation
modpost: skip ELF local symbols during section mismatch check
kbuild: fix single target build for external module
mtd: fix mtd_oobavail() incoherent returned value
ARM: dts: pxa: clean up USB controller nodes
clk: meson: meson8b: fix the offset of vid_pll_dco's N value
clk: sunxi-ng: h3/h5: Fix CSI_MCLK parent
clk: qcom: Fix MSM8998 resets
media: cxd2880-spi: fix probe when dvb_attach fails
ARM: dts: realview: Fix some more duplicate regulator nodes
dlm: fix invalid cluster name warning
net/mlx4_core: Fix return codes of unsupported operations
pstore/ram: Avoid NULL deref in ftrace merging failure path
powerpc/math-emu: Update macros from GCC
clk: renesas: r8a77990: Correct parent clock of DU
clk: renesas: r8a77995: Correct parent clock of DU
MIPS: OCTEON: cvmx_pko_mem_debug8: use oldest forward compatible definition
nfsd: Return EPERM, not EACCES, in some SETATTR cases
media: uvcvideo: Abstract streaming object lifetime
tty: serial: qcom_geni_serial: Fix softlock
ARM: dts: sun8i: h3: Fix the system-control register range
tty: Don't block on IO when ldisc change is pending
media: stkwebcam: Bugfix for wrong return values
firmware: qcom: scm: fix compilation error when disabled
clk: qcom: gcc-msm8998: Disable halt check of UFS clocks
sctp: frag_point sanity check
soc: renesas: r8a77990-sysc: Fix initialization order of 3DG-{A,B}
mlxsw: spectrum_router: Relax GRE decap matching check
IB/hfi1: Ignore LNI errors before DC8051 transitions to Polling state
IB/hfi1: Close VNIC sdma_progress sleep window
mlx4: Use snprintf instead of complicated strcpy
usb: mtu3: fix dbginfo in qmu_tx_zlp_error_handler
clk: renesas: rcar-gen3: Set state when registering SD clocks
ASoC: max9867: Fix power management
ARM: dts: sunxi: Fix PMU compatible strings
ARM: dts: am335x-pdu001: Fix polarity of card detection input
media: vimc: fix start stream when link is disabled
net: aquantia: fix RSS table and key sizes
sched/fair: Scale bandwidth quota and period without losing quota/period ratio precision
fuse: verify nlink
fuse: verify attributes
ALSA: hda/realtek - Enable internal speaker of ASUS UX431FLC
ALSA: hda/realtek - Enable the headset-mic on a Xiaomi's laptop
ALSA: hda/realtek - Dell headphone has noise on unmute for ALC236
ALSA: pcm: oss: Avoid potential buffer overflows
ALSA: hda - Add mute led support for HP ProBook 645 G4
Input: synaptics - switch another X1 Carbon 6 to RMI/SMbus
Input: synaptics-rmi4 - re-enable IRQs in f34v7_do_reflash
Input: synaptics-rmi4 - don't increment rmiaddr for SMBus transfers
Input: goodix - add upside-down quirk for Teclast X89 tablet
coresight: etm4x: Fix input validation for sysfs.
Input: Fix memory leak in psxpad_spi_probe
x86/mm/32: Sync only to VMALLOC_END in vmalloc_sync_all()
x86/PCI: Avoid AMD FCH XHCI USB PME# from D0 defect
xfrm interface: fix memory leak on creation
xfrm interface: avoid corruption on changelink
xfrm interface: fix list corruption for x-netns
xfrm interface: fix management of phydev
CIFS: Fix NULL-pointer dereference in smb2_push_mandatory_locks
CIFS: Fix SMB2 oplock break processing
tty: vt: keyboard: reject invalid keycodes
can: slcan: Fix use-after-free Read in slcan_open
kernfs: fix ino wrap-around detection
jbd2: Fix possible overflow in jbd2_log_space_left()
drm/msm: fix memleak on release
drm/i810: Prevent underflow in ioctl
arm64: dts: exynos: Revert "Remove unneeded address space mapping for soc node"
KVM: arm/arm64: vgic: Don't rely on the wrong pending table
KVM: x86: do not modify masked bits of shared MSRs
KVM: x86: fix presentation of TSX feature in ARCH_CAPABILITIES
KVM: x86: Grab KVM's srcu lock when setting nested state
crypto: crypto4xx - fix double-free in crypto4xx_destroy_sdr
crypto: atmel-aes - Fix IV handling when req->nbytes < ivsize
crypto: af_alg - cast ki_complete ternary op to int
crypto: ccp - fix uninitialized list head
crypto: ecdh - fix big endian bug in ECC library
crypto: user - fix memory leak in crypto_report
spi: atmel: Fix CS high support
mwifiex: update set_mac_address logic
can: ucan: fix non-atomic allocation in completion handler
RDMA/qib: Validate ->show()/store() callbacks before calling them
iomap: Fix pipe page leakage during splicing
thermal: Fix deadlock in thermal thermal_zone_device_check
vcs: prevent write access to vcsu devices
binder: Fix race between mmap() and binder_alloc_print_pages()
binder: Handle start==NULL in binder_update_page_range()
ALSA: hda - Fix pending unsol events at shutdown
md/raid0: Fix an error message in raid0_make_request()
watchdog: aspeed: Fix clock behaviour for ast2600
perf script: Fix invalid LBR/binary mismatch error
splice: don't read more than available pipe space
iomap: partially revert 4721a601099 (simulated directio short read on EFAULT)
xfs: add missing error check in xfs_prepare_shift()
ASoC: rsnd: fixup MIX kctrl registration
KVM: x86: fix out-of-bounds write in KVM_GET_EMULATED_CPUID (CVE-2019-19332)
net: qrtr: fix memort leak in qrtr_tun_write_iter
appletalk: Fix potential NULL pointer dereference in unregister_snap_client
appletalk: Set error code if register_snap_client failed
Linux 4.19.89
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ib03743db658afb561f36bf513e38754eed704fef
565 lines
17 KiB
C
565 lines
17 KiB
C
/*
|
|
* kernfs.h - pseudo filesystem decoupled from vfs locking
|
|
*
|
|
* This file is released under the GPLv2.
|
|
*/
|
|
|
|
#ifndef __LINUX_KERNFS_H
|
|
#define __LINUX_KERNFS_H
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/err.h>
|
|
#include <linux/list.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/idr.h>
|
|
#include <linux/lockdep.h>
|
|
#include <linux/rbtree.h>
|
|
#include <linux/atomic.h>
|
|
#include <linux/uidgid.h>
|
|
#include <linux/wait.h>
|
|
|
|
struct file;
|
|
struct dentry;
|
|
struct iattr;
|
|
struct seq_file;
|
|
struct vm_area_struct;
|
|
struct super_block;
|
|
struct file_system_type;
|
|
struct poll_table_struct;
|
|
|
|
struct kernfs_open_node;
|
|
struct kernfs_iattrs;
|
|
|
|
enum kernfs_node_type {
|
|
KERNFS_DIR = 0x0001,
|
|
KERNFS_FILE = 0x0002,
|
|
KERNFS_LINK = 0x0004,
|
|
};
|
|
|
|
#define KERNFS_TYPE_MASK 0x000f
|
|
#define KERNFS_FLAG_MASK ~KERNFS_TYPE_MASK
|
|
|
|
enum kernfs_node_flag {
|
|
KERNFS_ACTIVATED = 0x0010,
|
|
KERNFS_NS = 0x0020,
|
|
KERNFS_HAS_SEQ_SHOW = 0x0040,
|
|
KERNFS_HAS_MMAP = 0x0080,
|
|
KERNFS_LOCKDEP = 0x0100,
|
|
KERNFS_SUICIDAL = 0x0400,
|
|
KERNFS_SUICIDED = 0x0800,
|
|
KERNFS_EMPTY_DIR = 0x1000,
|
|
KERNFS_HAS_RELEASE = 0x2000,
|
|
};
|
|
|
|
/* @flags for kernfs_create_root() */
|
|
enum kernfs_root_flag {
|
|
/*
|
|
* kernfs_nodes are created in the deactivated state and invisible.
|
|
* They require explicit kernfs_activate() to become visible. This
|
|
* can be used to make related nodes become visible atomically
|
|
* after all nodes are created successfully.
|
|
*/
|
|
KERNFS_ROOT_CREATE_DEACTIVATED = 0x0001,
|
|
|
|
/*
|
|
* For regular flies, if the opener has CAP_DAC_OVERRIDE, open(2)
|
|
* succeeds regardless of the RW permissions. sysfs had an extra
|
|
* layer of enforcement where open(2) fails with -EACCES regardless
|
|
* of CAP_DAC_OVERRIDE if the permission doesn't have the
|
|
* respective read or write access at all (none of S_IRUGO or
|
|
* S_IWUGO) or the respective operation isn't implemented. The
|
|
* following flag enables that behavior.
|
|
*/
|
|
KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK = 0x0002,
|
|
|
|
/*
|
|
* The filesystem supports exportfs operation, so userspace can use
|
|
* fhandle to access nodes of the fs.
|
|
*/
|
|
KERNFS_ROOT_SUPPORT_EXPORTOP = 0x0004,
|
|
};
|
|
|
|
/* type-specific structures for kernfs_node union members */
|
|
struct kernfs_elem_dir {
|
|
unsigned long subdirs;
|
|
/* children rbtree starts here and goes through kn->rb */
|
|
struct rb_root children;
|
|
|
|
/*
|
|
* The kernfs hierarchy this directory belongs to. This fits
|
|
* better directly in kernfs_node but is here to save space.
|
|
*/
|
|
struct kernfs_root *root;
|
|
};
|
|
|
|
struct kernfs_elem_symlink {
|
|
struct kernfs_node *target_kn;
|
|
};
|
|
|
|
struct kernfs_elem_attr {
|
|
const struct kernfs_ops *ops;
|
|
struct kernfs_open_node *open;
|
|
loff_t size;
|
|
struct kernfs_node *notify_next; /* for kernfs_notify() */
|
|
};
|
|
|
|
/* represent a kernfs node */
|
|
union kernfs_node_id {
|
|
struct {
|
|
/*
|
|
* blktrace will export this struct as a simplified 'struct
|
|
* fid' (which is a big data struction), so userspace can use
|
|
* it to find kernfs node. The layout must match the first two
|
|
* fields of 'struct fid' exactly.
|
|
*/
|
|
u32 ino;
|
|
u32 generation;
|
|
};
|
|
u64 id;
|
|
};
|
|
|
|
/*
|
|
* kernfs_node - the building block of kernfs hierarchy. Each and every
|
|
* kernfs node is represented by single kernfs_node. Most fields are
|
|
* private to kernfs and shouldn't be accessed directly by kernfs users.
|
|
*
|
|
* As long as s_count reference is held, the kernfs_node itself is
|
|
* accessible. Dereferencing elem or any other outer entity requires
|
|
* active reference.
|
|
*/
|
|
struct kernfs_node {
|
|
atomic_t count;
|
|
atomic_t active;
|
|
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
|
struct lockdep_map dep_map;
|
|
#endif
|
|
/*
|
|
* Use kernfs_get_parent() and kernfs_name/path() instead of
|
|
* accessing the following two fields directly. If the node is
|
|
* never moved to a different parent, it is safe to access the
|
|
* parent directly.
|
|
*/
|
|
struct kernfs_node *parent;
|
|
const char *name;
|
|
|
|
struct rb_node rb;
|
|
|
|
const void *ns; /* namespace tag */
|
|
unsigned int hash; /* ns + name hash */
|
|
union {
|
|
struct kernfs_elem_dir dir;
|
|
struct kernfs_elem_symlink symlink;
|
|
struct kernfs_elem_attr attr;
|
|
};
|
|
|
|
void *priv;
|
|
|
|
union kernfs_node_id id;
|
|
unsigned short flags;
|
|
umode_t mode;
|
|
struct kernfs_iattrs *iattr;
|
|
};
|
|
|
|
/*
|
|
* kernfs_syscall_ops may be specified on kernfs_create_root() to support
|
|
* syscalls. These optional callbacks are invoked on the matching syscalls
|
|
* and can perform any kernfs operations which don't necessarily have to be
|
|
* the exact operation requested. An active reference is held for each
|
|
* kernfs_node parameter.
|
|
*/
|
|
struct kernfs_syscall_ops {
|
|
int (*remount_fs)(struct kernfs_root *root, int *flags, char *data);
|
|
int (*show_options)(struct seq_file *sf, struct kernfs_root *root);
|
|
|
|
int (*mkdir)(struct kernfs_node *parent, const char *name,
|
|
umode_t mode);
|
|
int (*rmdir)(struct kernfs_node *kn);
|
|
int (*rename)(struct kernfs_node *kn, struct kernfs_node *new_parent,
|
|
const char *new_name);
|
|
int (*show_path)(struct seq_file *sf, struct kernfs_node *kn,
|
|
struct kernfs_root *root);
|
|
};
|
|
|
|
struct kernfs_root {
|
|
/* published fields */
|
|
struct kernfs_node *kn;
|
|
unsigned int flags; /* KERNFS_ROOT_* flags */
|
|
|
|
/* private fields, do not use outside kernfs proper */
|
|
struct idr ino_idr;
|
|
u32 last_ino;
|
|
u32 next_generation;
|
|
struct kernfs_syscall_ops *syscall_ops;
|
|
|
|
/* list of kernfs_super_info of this root, protected by kernfs_mutex */
|
|
struct list_head supers;
|
|
|
|
wait_queue_head_t deactivate_waitq;
|
|
};
|
|
|
|
struct kernfs_open_file {
|
|
/* published fields */
|
|
struct kernfs_node *kn;
|
|
struct file *file;
|
|
struct seq_file *seq_file;
|
|
void *priv;
|
|
|
|
/* private fields, do not use outside kernfs proper */
|
|
struct mutex mutex;
|
|
struct mutex prealloc_mutex;
|
|
int event;
|
|
struct list_head list;
|
|
char *prealloc_buf;
|
|
|
|
size_t atomic_write_len;
|
|
bool mmapped:1;
|
|
bool released:1;
|
|
const struct vm_operations_struct *vm_ops;
|
|
};
|
|
|
|
struct kernfs_ops {
|
|
/*
|
|
* Optional open/release methods. Both are called with
|
|
* @of->seq_file populated.
|
|
*/
|
|
int (*open)(struct kernfs_open_file *of);
|
|
void (*release)(struct kernfs_open_file *of);
|
|
|
|
/*
|
|
* Read is handled by either seq_file or raw_read().
|
|
*
|
|
* If seq_show() is present, seq_file path is active. Other seq
|
|
* operations are optional and if not implemented, the behavior is
|
|
* equivalent to single_open(). @sf->private points to the
|
|
* associated kernfs_open_file.
|
|
*
|
|
* read() is bounced through kernel buffer and a read larger than
|
|
* PAGE_SIZE results in partial operation of PAGE_SIZE.
|
|
*/
|
|
int (*seq_show)(struct seq_file *sf, void *v);
|
|
|
|
void *(*seq_start)(struct seq_file *sf, loff_t *ppos);
|
|
void *(*seq_next)(struct seq_file *sf, void *v, loff_t *ppos);
|
|
void (*seq_stop)(struct seq_file *sf, void *v);
|
|
|
|
ssize_t (*read)(struct kernfs_open_file *of, char *buf, size_t bytes,
|
|
loff_t off);
|
|
|
|
/*
|
|
* write() is bounced through kernel buffer. If atomic_write_len
|
|
* is not set, a write larger than PAGE_SIZE results in partial
|
|
* operations of PAGE_SIZE chunks. If atomic_write_len is set,
|
|
* writes upto the specified size are executed atomically but
|
|
* larger ones are rejected with -E2BIG.
|
|
*/
|
|
size_t atomic_write_len;
|
|
/*
|
|
* "prealloc" causes a buffer to be allocated at open for
|
|
* all read/write requests. As ->seq_show uses seq_read()
|
|
* which does its own allocation, it is incompatible with
|
|
* ->prealloc. Provide ->read and ->write with ->prealloc.
|
|
*/
|
|
bool prealloc;
|
|
ssize_t (*write)(struct kernfs_open_file *of, char *buf, size_t bytes,
|
|
loff_t off);
|
|
|
|
__poll_t (*poll)(struct kernfs_open_file *of,
|
|
struct poll_table_struct *pt);
|
|
|
|
int (*mmap)(struct kernfs_open_file *of, struct vm_area_struct *vma);
|
|
|
|
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
|
struct lock_class_key lockdep_key;
|
|
#endif
|
|
};
|
|
|
|
#ifdef CONFIG_KERNFS
|
|
|
|
static inline enum kernfs_node_type kernfs_type(struct kernfs_node *kn)
|
|
{
|
|
return kn->flags & KERNFS_TYPE_MASK;
|
|
}
|
|
|
|
/**
|
|
* kernfs_enable_ns - enable namespace under a directory
|
|
* @kn: directory of interest, should be empty
|
|
*
|
|
* This is to be called right after @kn is created to enable namespace
|
|
* under it. All children of @kn must have non-NULL namespace tags and
|
|
* only the ones which match the super_block's tag will be visible.
|
|
*/
|
|
static inline void kernfs_enable_ns(struct kernfs_node *kn)
|
|
{
|
|
WARN_ON_ONCE(kernfs_type(kn) != KERNFS_DIR);
|
|
WARN_ON_ONCE(!RB_EMPTY_ROOT(&kn->dir.children));
|
|
kn->flags |= KERNFS_NS;
|
|
}
|
|
|
|
/**
|
|
* kernfs_ns_enabled - test whether namespace is enabled
|
|
* @kn: the node to test
|
|
*
|
|
* Test whether namespace filtering is enabled for the children of @ns.
|
|
*/
|
|
static inline bool kernfs_ns_enabled(struct kernfs_node *kn)
|
|
{
|
|
return kn->flags & KERNFS_NS;
|
|
}
|
|
|
|
int kernfs_name(struct kernfs_node *kn, char *buf, size_t buflen);
|
|
int kernfs_path_from_node(struct kernfs_node *root_kn, struct kernfs_node *kn,
|
|
char *buf, size_t buflen);
|
|
void pr_cont_kernfs_name(struct kernfs_node *kn);
|
|
void pr_cont_kernfs_path(struct kernfs_node *kn);
|
|
struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn);
|
|
struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent,
|
|
const char *name, const void *ns);
|
|
struct kernfs_node *kernfs_walk_and_get_ns(struct kernfs_node *parent,
|
|
const char *path, const void *ns);
|
|
void kernfs_get(struct kernfs_node *kn);
|
|
void kernfs_put(struct kernfs_node *kn);
|
|
|
|
struct kernfs_node *kernfs_node_from_dentry(struct dentry *dentry);
|
|
struct kernfs_root *kernfs_root_from_sb(struct super_block *sb);
|
|
struct inode *kernfs_get_inode(struct super_block *sb, struct kernfs_node *kn);
|
|
|
|
struct dentry *kernfs_node_dentry(struct kernfs_node *kn,
|
|
struct super_block *sb);
|
|
struct kernfs_root *kernfs_create_root(struct kernfs_syscall_ops *scops,
|
|
unsigned int flags, void *priv);
|
|
void kernfs_destroy_root(struct kernfs_root *root);
|
|
|
|
struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent,
|
|
const char *name, umode_t mode,
|
|
kuid_t uid, kgid_t gid,
|
|
void *priv, const void *ns);
|
|
struct kernfs_node *kernfs_create_empty_dir(struct kernfs_node *parent,
|
|
const char *name);
|
|
struct kernfs_node *__kernfs_create_file(struct kernfs_node *parent,
|
|
const char *name, umode_t mode,
|
|
kuid_t uid, kgid_t gid,
|
|
loff_t size,
|
|
const struct kernfs_ops *ops,
|
|
void *priv, const void *ns,
|
|
struct lock_class_key *key);
|
|
struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,
|
|
const char *name,
|
|
struct kernfs_node *target);
|
|
void kernfs_activate(struct kernfs_node *kn);
|
|
void kernfs_remove(struct kernfs_node *kn);
|
|
void kernfs_break_active_protection(struct kernfs_node *kn);
|
|
void kernfs_unbreak_active_protection(struct kernfs_node *kn);
|
|
bool kernfs_remove_self(struct kernfs_node *kn);
|
|
int kernfs_remove_by_name_ns(struct kernfs_node *parent, const char *name,
|
|
const void *ns);
|
|
int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
|
|
const char *new_name, const void *new_ns);
|
|
int kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr);
|
|
__poll_t kernfs_generic_poll(struct kernfs_open_file *of,
|
|
struct poll_table_struct *pt);
|
|
void kernfs_notify(struct kernfs_node *kn);
|
|
|
|
const void *kernfs_super_ns(struct super_block *sb);
|
|
struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags,
|
|
struct kernfs_root *root, unsigned long magic,
|
|
bool *new_sb_created, const void *ns);
|
|
void kernfs_kill_sb(struct super_block *sb);
|
|
struct super_block *kernfs_pin_sb(struct kernfs_root *root, const void *ns);
|
|
|
|
void kernfs_init(void);
|
|
|
|
struct kernfs_node *kernfs_get_node_by_id(struct kernfs_root *root,
|
|
const union kernfs_node_id *id);
|
|
#else /* CONFIG_KERNFS */
|
|
|
|
static inline enum kernfs_node_type kernfs_type(struct kernfs_node *kn)
|
|
{ return 0; } /* whatever */
|
|
|
|
static inline void kernfs_enable_ns(struct kernfs_node *kn) { }
|
|
|
|
static inline bool kernfs_ns_enabled(struct kernfs_node *kn)
|
|
{ return false; }
|
|
|
|
static inline int kernfs_name(struct kernfs_node *kn, char *buf, size_t buflen)
|
|
{ return -ENOSYS; }
|
|
|
|
static inline int kernfs_path_from_node(struct kernfs_node *root_kn,
|
|
struct kernfs_node *kn,
|
|
char *buf, size_t buflen)
|
|
{ return -ENOSYS; }
|
|
|
|
static inline void pr_cont_kernfs_name(struct kernfs_node *kn) { }
|
|
static inline void pr_cont_kernfs_path(struct kernfs_node *kn) { }
|
|
|
|
static inline struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn)
|
|
{ return NULL; }
|
|
|
|
static inline struct kernfs_node *
|
|
kernfs_find_and_get_ns(struct kernfs_node *parent, const char *name,
|
|
const void *ns)
|
|
{ return NULL; }
|
|
static inline struct kernfs_node *
|
|
kernfs_walk_and_get_ns(struct kernfs_node *parent, const char *path,
|
|
const void *ns)
|
|
{ return NULL; }
|
|
|
|
static inline void kernfs_get(struct kernfs_node *kn) { }
|
|
static inline void kernfs_put(struct kernfs_node *kn) { }
|
|
|
|
static inline struct kernfs_node *kernfs_node_from_dentry(struct dentry *dentry)
|
|
{ return NULL; }
|
|
|
|
static inline struct kernfs_root *kernfs_root_from_sb(struct super_block *sb)
|
|
{ return NULL; }
|
|
|
|
static inline struct inode *
|
|
kernfs_get_inode(struct super_block *sb, struct kernfs_node *kn)
|
|
{ return NULL; }
|
|
|
|
static inline struct kernfs_root *
|
|
kernfs_create_root(struct kernfs_syscall_ops *scops, unsigned int flags,
|
|
void *priv)
|
|
{ return ERR_PTR(-ENOSYS); }
|
|
|
|
static inline void kernfs_destroy_root(struct kernfs_root *root) { }
|
|
|
|
static inline struct kernfs_node *
|
|
kernfs_create_dir_ns(struct kernfs_node *parent, const char *name,
|
|
umode_t mode, kuid_t uid, kgid_t gid,
|
|
void *priv, const void *ns)
|
|
{ return ERR_PTR(-ENOSYS); }
|
|
|
|
static inline struct kernfs_node *
|
|
__kernfs_create_file(struct kernfs_node *parent, const char *name,
|
|
umode_t mode, kuid_t uid, kgid_t gid,
|
|
loff_t size, const struct kernfs_ops *ops,
|
|
void *priv, const void *ns, struct lock_class_key *key)
|
|
{ return ERR_PTR(-ENOSYS); }
|
|
|
|
static inline struct kernfs_node *
|
|
kernfs_create_link(struct kernfs_node *parent, const char *name,
|
|
struct kernfs_node *target)
|
|
{ return ERR_PTR(-ENOSYS); }
|
|
|
|
static inline void kernfs_activate(struct kernfs_node *kn) { }
|
|
|
|
static inline void kernfs_remove(struct kernfs_node *kn) { }
|
|
|
|
static inline bool kernfs_remove_self(struct kernfs_node *kn)
|
|
{ return false; }
|
|
|
|
static inline int kernfs_remove_by_name_ns(struct kernfs_node *kn,
|
|
const char *name, const void *ns)
|
|
{ return -ENOSYS; }
|
|
|
|
static inline int kernfs_rename_ns(struct kernfs_node *kn,
|
|
struct kernfs_node *new_parent,
|
|
const char *new_name, const void *new_ns)
|
|
{ return -ENOSYS; }
|
|
|
|
static inline int kernfs_setattr(struct kernfs_node *kn,
|
|
const struct iattr *iattr)
|
|
{ return -ENOSYS; }
|
|
|
|
static inline void kernfs_notify(struct kernfs_node *kn) { }
|
|
|
|
static inline const void *kernfs_super_ns(struct super_block *sb)
|
|
{ return NULL; }
|
|
|
|
static inline struct dentry *
|
|
kernfs_mount_ns(struct file_system_type *fs_type, int flags,
|
|
struct kernfs_root *root, unsigned long magic,
|
|
bool *new_sb_created, const void *ns)
|
|
{ return ERR_PTR(-ENOSYS); }
|
|
|
|
static inline void kernfs_kill_sb(struct super_block *sb) { }
|
|
|
|
static inline void kernfs_init(void) { }
|
|
|
|
#endif /* CONFIG_KERNFS */
|
|
|
|
/**
|
|
* kernfs_path - build full path of a given node
|
|
* @kn: kernfs_node of interest
|
|
* @buf: buffer to copy @kn's name into
|
|
* @buflen: size of @buf
|
|
*
|
|
* Builds and returns the full path of @kn in @buf of @buflen bytes. The
|
|
* path is built from the end of @buf so the returned pointer usually
|
|
* doesn't match @buf. If @buf isn't long enough, @buf is nul terminated
|
|
* and %NULL is returned.
|
|
*/
|
|
static inline int kernfs_path(struct kernfs_node *kn, char *buf, size_t buflen)
|
|
{
|
|
return kernfs_path_from_node(kn, NULL, buf, buflen);
|
|
}
|
|
|
|
static inline struct kernfs_node *
|
|
kernfs_find_and_get(struct kernfs_node *kn, const char *name)
|
|
{
|
|
return kernfs_find_and_get_ns(kn, name, NULL);
|
|
}
|
|
|
|
static inline struct kernfs_node *
|
|
kernfs_walk_and_get(struct kernfs_node *kn, const char *path)
|
|
{
|
|
return kernfs_walk_and_get_ns(kn, path, NULL);
|
|
}
|
|
|
|
static inline struct kernfs_node *
|
|
kernfs_create_dir(struct kernfs_node *parent, const char *name, umode_t mode,
|
|
void *priv)
|
|
{
|
|
return kernfs_create_dir_ns(parent, name, mode,
|
|
GLOBAL_ROOT_UID, GLOBAL_ROOT_GID,
|
|
priv, NULL);
|
|
}
|
|
|
|
static inline struct kernfs_node *
|
|
kernfs_create_file_ns(struct kernfs_node *parent, const char *name,
|
|
umode_t mode, kuid_t uid, kgid_t gid,
|
|
loff_t size, const struct kernfs_ops *ops,
|
|
void *priv, const void *ns)
|
|
{
|
|
struct lock_class_key *key = NULL;
|
|
|
|
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
|
key = (struct lock_class_key *)&ops->lockdep_key;
|
|
#endif
|
|
return __kernfs_create_file(parent, name, mode, uid, gid,
|
|
size, ops, priv, ns, key);
|
|
}
|
|
|
|
static inline struct kernfs_node *
|
|
kernfs_create_file(struct kernfs_node *parent, const char *name, umode_t mode,
|
|
loff_t size, const struct kernfs_ops *ops, void *priv)
|
|
{
|
|
return kernfs_create_file_ns(parent, name, mode,
|
|
GLOBAL_ROOT_UID, GLOBAL_ROOT_GID,
|
|
size, ops, priv, NULL);
|
|
}
|
|
|
|
static inline int kernfs_remove_by_name(struct kernfs_node *parent,
|
|
const char *name)
|
|
{
|
|
return kernfs_remove_by_name_ns(parent, name, NULL);
|
|
}
|
|
|
|
static inline int kernfs_rename(struct kernfs_node *kn,
|
|
struct kernfs_node *new_parent,
|
|
const char *new_name)
|
|
{
|
|
return kernfs_rename_ns(kn, new_parent, new_name, NULL);
|
|
}
|
|
|
|
static inline struct dentry *
|
|
kernfs_mount(struct file_system_type *fs_type, int flags,
|
|
struct kernfs_root *root, unsigned long magic,
|
|
bool *new_sb_created)
|
|
{
|
|
return kernfs_mount_ns(fs_type, flags, root,
|
|
magic, new_sb_created, NULL);
|
|
}
|
|
|
|
#endif /* __LINUX_KERNFS_H */
|