Jsphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget'/translations/zh_CN/filesystems/debugfsmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget'/translations/zh_TW/filesystems/debugfsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget'/translations/it_IT/filesystems/debugfsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget'/translations/ja_JP/filesystems/debugfsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget'/translations/ko_KR/filesystems/debugfsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget'/translations/sp_SP/filesystems/debugfsmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhcomment)}(h SPDX-License-Identifier: GPL-2.0h]h SPDX-License-Identifier: GPL-2.0}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhhA/var/lib/git/docbuild/linux/Documentation/filesystems/debugfs.rsthKubh)}(h4This data file has been placed in the public domain.h]h4This data file has been placed in the public domain.}hhsbah}(h]h ]h"]h$]h&]hhuh1hhhhhho/srv/docbuild/lib/venvs/build-kernel-docs/lib64/python3.9/site-packages/docutils/parsers/rst/include/isonum.txthKubh)}(hDerived from the Unicode character mappings available from . Processed by unicode2rstsubs.py, part of Docutils: .h]hDerived from the Unicode character mappings available from . Processed by unicode2rstsubs.py, part of Docutils: .}hhsbah}(h]h ]h"]h$]h&]hhuh1hhhhhhhhKubhsubstitution_definition)}(h*.. |amp| unicode:: U+00026 .. AMPERSANDh]h&}hhsbah}(h]h ]h"]ampah$]h&]uh1hhhhKhhhhubh)}(h+.. |apos| unicode:: U+00027 .. APOSTROPHEh]h'}hhsbah}(h]h ]h"]aposah$]h&]uh1hhhhKhhhhubh)}(h).. |ast| unicode:: U+0002A .. ASTERISKh]h*}hhsbah}(h]h ]h"]astah$]h&]uh1hhhhK hhhhubh)}(h+.. |brvbar| unicode:: U+000A6 .. BROKEN BARh]h¦}hjsbah}(h]h ]h"]brvbarah$]h&]uh1hhhhK hhhhubh)}(h0.. |bsol| unicode:: U+0005C .. REVERSE SOLIDUSh]h\}hjsbah}(h]h ]h"]bsolah$]h&]uh1hhhhK hhhhubh)}(h*.. |cent| unicode:: U+000A2 .. CENT SIGNh]h¢}hjsbah}(h]h ]h"]centah$]h&]uh1hhhhK hhhhubh)}(h&.. |colon| unicode:: U+0003A .. COLONh]h:}hj-sbah}(h]h ]h"]colonah$]h&]uh1hhhhK hhhhubh)}(h&.. |comma| unicode:: U+0002C .. COMMAh]h,}hj<sbah}(h]h ]h"]commaah$]h&]uh1hhhhKhhhhubh)}(h... |commat| unicode:: U+00040 .. COMMERCIAL ATh]h@}hjKsbah}(h]h ]h"]commatah$]h&]uh1hhhhKhhhhubh)}(h/.. |copy| unicode:: U+000A9 .. COPYRIGHT SIGNh]h©}hjZsbah}(h]h ]h"]copyah$]h&]uh1hhhhKhhhhubh)}(h... |curren| unicode:: U+000A4 .. CURRENCY SIGNh]h¤}hjisbah}(h]h ]h"]currenah$]h&]uh1hhhhKhhhhubh)}(h0.. |darr| unicode:: U+02193 .. DOWNWARDS ARROWh]h↓}hjxsbah}(h]h ]h"]darrah$]h&]uh1hhhhKhhhhubh)}(h,.. |deg| unicode:: U+000B0 .. DEGREE SIGNh]h°}hjsbah}(h]h ]h"]degah$]h&]uh1hhhhKhhhhubh)}(h... |divide| unicode:: U+000F7 .. DIVISION SIGNh]h÷}hjsbah}(h]h ]h"]divideah$]h&]uh1hhhhKhhhhubh)}(h,.. |dollar| unicode:: U+00024 .. DOLLAR SIGNh]h$}hjsbah}(h]h ]h"]dollarah$]h&]uh1hhhhKhhhhubh)}(h,.. |equals| unicode:: U+0003D .. EQUALS SIGNh]h=}hjsbah}(h]h ]h"]equalsah$]h&]uh1hhhhKhhhhubh)}(h1.. |excl| unicode:: U+00021 .. EXCLAMATION MARKh]h!}hjsbah}(h]h ]h"]exclah$]h&]uh1hhhhKhhhhubh)}(h9.. |frac12| unicode:: U+000BD .. VULGAR FRACTION ONE HALFh]h½}hjsbah}(h]h ]h"]frac12ah$]h&]uh1hhhhKhhhhubh)}(h<.. |frac14| unicode:: U+000BC .. VULGAR FRACTION ONE QUARTERh]h¼}hjsbah}(h]h ]h"]frac14ah$]h&]uh1hhhhKhhhhubh)}(h;.. |frac18| unicode:: U+0215B .. VULGAR FRACTION ONE EIGHTHh]h⅛}hjsbah}(h]h ]h"]frac18ah$]h&]uh1hhhhKhhhhubh)}(h?.. |frac34| unicode:: U+000BE .. VULGAR FRACTION THREE QUARTERSh]h¾}hjsbah}(h]h ]h"]frac34ah$]h&]uh1hhhhKhhhhubh)}(h>.. |frac38| unicode:: U+0215C .. VULGAR FRACTION THREE EIGHTHSh]h⅜}hjsbah}(h]h ]h"]frac38ah$]h&]uh1hhhhKhhhhubh)}(h=.. |frac58| unicode:: U+0215D .. VULGAR FRACTION FIVE EIGHTHSh]h⅝}hjsbah}(h]h ]h"]frac58ah$]h&]uh1hhhhKhhhhubh)}(h>.. |frac78| unicode:: U+0215E .. VULGAR FRACTION SEVEN EIGHTHSh]h⅞}hj,sbah}(h]h ]h"]frac78ah$]h&]uh1hhhhKhhhhubh)}(h2.. |gt| unicode:: U+0003E .. GREATER-THAN SIGNh]h>}hj;sbah}(h]h ]h"]gtah$]h&]uh1hhhhKhhhhubh)}(h9.. |half| unicode:: U+000BD .. VULGAR FRACTION ONE HALFh]h½}hjJsbah}(h]h ]h"]halfah$]h&]uh1hhhhK hhhhubh)}(h/.. |horbar| unicode:: U+02015 .. HORIZONTAL BARh]h―}hjYsbah}(h]h ]h"]horbarah$]h&]uh1hhhhK!hhhhubh)}(h'.. |hyphen| unicode:: U+02010 .. HYPHENh]h‐}hjhsbah}(h]h ]h"]hyphenah$]h&]uh1hhhhK"hhhhubh)}(h:.. |iexcl| unicode:: U+000A1 .. INVERTED EXCLAMATION MARKh]h¡}hjwsbah}(h]h ]h"]iexclah$]h&]uh1hhhhK#hhhhubh)}(h7.. |iquest| unicode:: U+000BF .. INVERTED QUESTION MARKh]h¿}hjsbah}(h]h ]h"]iquestah$]h&]uh1hhhhK$hhhhubh)}(hJ.. |laquo| unicode:: U+000AB .. LEFT-POINTING DOUBLE ANGLE QUOTATION MARKh]h«}hjsbah}(h]h ]h"]laquoah$]h&]uh1hhhhK%hhhhubh)}(h0.. |larr| unicode:: U+02190 .. LEFTWARDS ARROWh]h←}hjsbah}(h]h ]h"]larrah$]h&]uh1hhhhK&hhhhubh)}(h3.. |lcub| unicode:: U+0007B .. LEFT CURLY BRACKETh]h{}hjsbah}(h]h ]h"]lcubah$]h&]uh1hhhhK'hhhhubh)}(h;.. |ldquo| unicode:: U+0201C .. LEFT DOUBLE QUOTATION MARKh]h“}hjsbah}(h]h ]h"]ldquoah$]h&]uh1hhhhK(hhhhubh)}(h).. |lowbar| unicode:: U+0005F .. LOW LINEh]h_}hjsbah}(h]h ]h"]lowbarah$]h&]uh1hhhhK)hhhhubh)}(h1.. |lpar| unicode:: U+00028 .. LEFT PARENTHESISh]h(}hjsbah}(h]h ]h"]lparah$]h&]uh1hhhhK*hhhhubh)}(h4.. |lsqb| unicode:: U+0005B .. LEFT SQUARE BRACKETh]h[}hjsbah}(h]h ]h"]lsqbah$]h&]uh1hhhhK+hhhhubh)}(h;.. |lsquo| unicode:: U+02018 .. LEFT SINGLE QUOTATION MARKh]h‘}hjsbah}(h]h ]h"]lsquoah$]h&]uh1hhhhK,hhhhubh)}(h/.. |lt| unicode:: U+0003C .. LESS-THAN SIGNh]h<}hj sbah}(h]h ]h"]ltah$]h&]uh1hhhhK-hhhhubh)}(h+.. |micro| unicode:: U+000B5 .. MICRO SIGNh]hµ}hjsbah}(h]h ]h"]microah$]h&]uh1hhhhK.hhhhubh)}(h+.. |middot| unicode:: U+000B7 .. MIDDLE DOTh]h·}hj+sbah}(h]h ]h"]middotah$]h&]uh1hhhhK/hhhhubh)}(h/.. |nbsp| unicode:: U+000A0 .. NO-BREAK SPACEh]h }hj:sbah}(h]h ]h"]nbspah$]h&]uh1hhhhK0hhhhubh)}(h).. |not| unicode:: U+000AC .. NOT SIGNh]h¬}hjIsbah}(h]h ]h"]notah$]h&]uh1hhhhK1hhhhubh)}(h,.. |num| unicode:: U+00023 .. NUMBER SIGNh]h#}hjXsbah}(h]h ]h"]numah$]h&]uh1hhhhK2hhhhubh)}(h).. |ohm| unicode:: U+02126 .. OHM SIGNh]hΩ}hjgsbah}(h]h ]h"]ohmah$]h&]uh1hhhhK3hhhhubh)}(h;.. |ordf| unicode:: U+000AA .. FEMININE ORDINAL INDICATORh]hª}hjvsbah}(h]h ]h"]ordfah$]h&]uh1hhhhK4hhhhubh)}(h<.. |ordm| unicode:: U+000BA .. MASCULINE ORDINAL INDICATORh]hº}hjsbah}(h]h ]h"]ordmah$]h&]uh1hhhhK5hhhhubh)}(h-.. |para| unicode:: U+000B6 .. PILCROW SIGNh]h¶}hjsbah}(h]h ]h"]paraah$]h&]uh1hhhhK6hhhhubh)}(h-.. |percnt| unicode:: U+00025 .. PERCENT SIGNh]h%}hjsbah}(h]h ]h"]percntah$]h&]uh1hhhhK7hhhhubh)}(h*.. |period| unicode:: U+0002E .. FULL STOPh]h.}hjsbah}(h]h ]h"]periodah$]h&]uh1hhhhK8hhhhubh)}(h*.. |plus| unicode:: U+0002B .. PLUS SIGNh]h+}hjsbah}(h]h ]h"]plusah$]h&]uh1hhhhK9hhhhubh)}(h0.. |plusmn| unicode:: U+000B1 .. PLUS-MINUS SIGNh]h±}hjsbah}(h]h ]h"]plusmnah$]h&]uh1hhhhK:hhhhubh)}(h+.. |pound| unicode:: U+000A3 .. POUND SIGNh]h£}hjsbah}(h]h ]h"]poundah$]h&]uh1hhhhK;hhhhubh)}(h... |quest| unicode:: U+0003F .. QUESTION MARKh]h?}hjsbah}(h]h ]h"]questah$]h&]uh1hhhhKhhhhubh)}(h1.. |rarr| unicode:: U+02192 .. RIGHTWARDS ARROWh]h→}hjsbah}(h]h ]h"]rarrah$]h&]uh1hhhhK?hhhhubh)}(h4.. |rcub| unicode:: U+0007D .. RIGHT CURLY BRACKETh]h}}hj*sbah}(h]h ]h"]rcubah$]h&]uh1hhhhK@hhhhubh)}(h<.. |rdquo| unicode:: U+0201D .. RIGHT DOUBLE QUOTATION MARKh]h”}hj9sbah}(h]h ]h"]rdquoah$]h&]uh1hhhhKAhhhhubh)}(h0.. |reg| unicode:: U+000AE .. REGISTERED SIGNh]h®}hjHsbah}(h]h ]h"]regah$]h&]uh1hhhhKBhhhhubh)}(h2.. |rpar| unicode:: U+00029 .. RIGHT PARENTHESISh]h)}hjWsbah}(h]h ]h"]rparah$]h&]uh1hhhhKChhhhubh)}(h5.. |rsqb| unicode:: U+0005D .. RIGHT SQUARE BRACKETh]h]}hjfsbah}(h]h ]h"]rsqbah$]h&]uh1hhhhKDhhhhubh)}(h<.. |rsquo| unicode:: U+02019 .. RIGHT SINGLE QUOTATION MARKh]h’}hjusbah}(h]h ]h"]rsquoah$]h&]uh1hhhhKEhhhhubh)}(h-.. |sect| unicode:: U+000A7 .. SECTION SIGNh]h§}hjsbah}(h]h ]h"]sectah$]h&]uh1hhhhKFhhhhubh)}(h*.. |semi| unicode:: U+0003B .. SEMICOLONh]h;}hjsbah}(h]h ]h"]semiah$]h&]uh1hhhhKGhhhhubh)}(h,.. |shy| unicode:: U+000AD .. SOFT HYPHENh]h­}hjsbah}(h]h ]h"]shyah$]h&]uh1hhhhKHhhhhubh)}(h(.. |sol| unicode:: U+0002F .. SOLIDUSh]h/}hjsbah}(h]h ]h"]solah$]h&]uh1hhhhKIhhhhubh)}(h,.. |sung| unicode:: U+0266A .. EIGHTH NOTEh]h♪}hjsbah}(h]h ]h"]sungah$]h&]uh1hhhhKJhhhhubh)}(h0.. |sup1| unicode:: U+000B9 .. SUPERSCRIPT ONEh]h¹}hjsbah}(h]h ]h"]sup1ah$]h&]uh1hhhhKKhhhhubh)}(h0.. |sup2| unicode:: U+000B2 .. SUPERSCRIPT TWOh]h²}hjsbah}(h]h ]h"]sup2ah$]h&]uh1hhhhKLhhhhubh)}(h2.. |sup3| unicode:: U+000B3 .. SUPERSCRIPT THREEh]h³}hjsbah}(h]h ]h"]sup3ah$]h&]uh1hhhhKMhhhhubh)}(h4.. |times| unicode:: U+000D7 .. MULTIPLICATION SIGNh]h×}hjsbah}(h]h ]h"]timesah$]h&]uh1hhhhKNhhhhubh)}(h0.. |trade| unicode:: U+02122 .. TRADE MARK SIGNh]h™}hj sbah}(h]h ]h"]tradeah$]h&]uh1hhhhKOhhhhubh)}(h... |uarr| unicode:: U+02191 .. UPWARDS ARROWh]h↑}hjsbah}(h]h ]h"]uarrah$]h&]uh1hhhhKPhhhhubh)}(h... |verbar| unicode:: U+0007C .. VERTICAL LINEh]h|}hj)sbah}(h]h ]h"]verbarah$]h&]uh1hhhhKQhhhhubh)}(h*.. |yen| unicode:: U+000A5 .. YEN SIGN h]h¥}hj8sbah}(h]h ]h"]yenah$]h&]uh1hhhhKRhhhhubhsection)}(hhh](htitle)}(hDebugFSh]hDebugFS}(hjNhhhNhNubah}(h]h ]h"]h$]h&]uh1jLhjIhhhhhKubh paragraph)}(h6Copyright |copy| 2009 Jonathan Corbet h](h Copyright }(hj^hhhNhNubh©}(hj^hhhNhNubh 2009 Jonathan Corbet <}(hj^hhhNhNubh reference)}(hcorbet@lwn.neth]hcorbet@lwn.net}(hjphhhNhNubah}(h]h ]h"]h$]h&]refurimailto:corbet@lwn.netuh1jnhj^ubh>}(hj^hhhNhNubeh}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj])}(hXkDebugfs exists as a simple way for kernel developers to make information available to user space. Unlike /proc, which is only meant for information about a process, or sysfs, which has strict one-value-per-file rules, debugfs has no rules at all. Developers can put any information they want there. The debugfs filesystem is also intended to not serve as a stable ABI to user space; in theory, there are no stability constraints placed on files exported there. The real world is not always so simple, though [1]_; even debugfs interfaces are best designed with the idea that they will need to be maintained forever.h](hXDebugfs exists as a simple way for kernel developers to make information available to user space. Unlike /proc, which is only meant for information about a process, or sysfs, which has strict one-value-per-file rules, debugfs has no rules at all. Developers can put any information they want there. The debugfs filesystem is also intended to not serve as a stable ABI to user space; in theory, there are no stability constraints placed on files exported there. The real world is not always so simple, though }(hjhhhNhNubhfootnote_reference)}(h[1]_h]h1}(hjhhhNhNubah}(h]id1ah ]h"]h$]h&]refidid2docnamefilesystems/debugfsuh1jhjresolvedKubhg; even debugfs interfaces are best designed with the idea that they will need to be maintained forever.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1j\hhhK hjIhhubj])}(h2Debugfs is typically mounted with a command like::h]h1Debugfs is typically mounted with a command like:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubh literal_block)}(h'mount -t debugfs none /sys/kernel/debugh]h'mount -t debugfs none /sys/kernel/debug}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjIhhubj])}(h(Or an equivalent /etc/fstab line). The debugfs root directory is accessible only to the root user by default. To change access to the tree the "uid", "gid" and "mode" mount options can be used.h]h(Or an equivalent /etc/fstab line). The debugfs root directory is accessible only to the root user by default. To change access to the tree the “uid”, “gid” and “mode” mount options can be used.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj])}(h:Note that the debugfs API is exported GPL-only to modules.h]h:Note that the debugfs API is exported GPL-only to modules.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj])}(hCode using debugfs should include . Then, the first order of business will be to create at least one directory to hold a set of debugfs files::h]hCode using debugfs should include . Then, the first order of business will be to create at least one directory to hold a set of debugfs files:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj)}(hKstruct dentry *debugfs_create_dir(const char *name, struct dentry *parent);h]hKstruct dentry *debugfs_create_dir(const char *name, struct dentry *parent);}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhK#hjIhhubj])}(hX$This call, if successful, will make a directory called name underneath the indicated parent directory. If parent is NULL, the directory will be created in the debugfs root. On success, the return value is a struct dentry pointer which can be used to create files in the directory (and to clean it up at the end). An ERR_PTR(-ERROR) return value indicates that something went wrong. If ERR_PTR(-ENODEV) is returned, that is an indication that the kernel has been built without debugfs support and none of the functions described below will work.h]hX$This call, if successful, will make a directory called name underneath the indicated parent directory. If parent is NULL, the directory will be created in the debugfs root. On success, the return value is a struct dentry pointer which can be used to create files in the directory (and to clean it up at the end). An ERR_PTR(-ERROR) return value indicates that something went wrong. If ERR_PTR(-ENODEV) is returned, that is an indication that the kernel has been built without debugfs support and none of the functions described below will work.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhK%hjIhhubj])}(hJThe most general way to create a file within a debugfs directory is with::h]hIThe most general way to create a file within a debugfs directory is with:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhK.hjIhhubj)}(hstruct dentry *debugfs_create_file(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops);h]hstruct dentry *debugfs_create_file(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops);}hj$sbah}(h]h ]h"]h$]h&]hhuh1jhhhK0hjIhhubj])}(hX9Here, name is the name of the file to create, mode describes the access permissions the file should have, parent indicates the directory which should hold the file, data will be stored in the i_private field of the resulting inode structure, and fops is a set of file operations which implement the file's behavior. At a minimum, the read() and/or write() operations should be provided; others can be included as needed. Again, the return value will be a dentry pointer to the created file, ERR_PTR(-ERROR) on error, or ERR_PTR(-ENODEV) if debugfs support is missing.h]hX;Here, name is the name of the file to create, mode describes the access permissions the file should have, parent indicates the directory which should hold the file, data will be stored in the i_private field of the resulting inode structure, and fops is a set of file operations which implement the file’s behavior. At a minimum, the read() and/or write() operations should be provided; others can be included as needed. Again, the return value will be a dentry pointer to the created file, ERR_PTR(-ERROR) on error, or ERR_PTR(-ENODEV) if debugfs support is missing.}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhK4hjIhhubj])}(hPCreate a file with an initial size, the following function can be used instead::h]hOCreate a file with an initial size, the following function can be used instead:}(hj@hhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhK>hjIhhubj)}(hvoid debugfs_create_file_size(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops, loff_t file_size);h]hvoid debugfs_create_file_size(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops, loff_t file_size);}hjNsbah}(h]h ]h"]h$]h&]hhuh1jhhhKAhjIhhubj])}(hjfile_size is the initial file size. The other parameters are the same as the function debugfs_create_file.h]hjfile_size is the initial file size. The other parameters are the same as the function debugfs_create_file.}(hj\hhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKFhjIhhubj])}(hIn a number of cases, the creation of a set of file operations is not actually necessary; the debugfs code provides a number of helper functions for simple situations. Files containing a single integer value can be created with any of::h]hIn a number of cases, the creation of a set of file operations is not actually necessary; the debugfs code provides a number of helper functions for simple situations. Files containing a single integer value can be created with any of:}(hjjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKIhjIhhubj)}(hXvoid debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent, u8 *value); void debugfs_create_u16(const char *name, umode_t mode, struct dentry *parent, u16 *value); void debugfs_create_u32(const char *name, umode_t mode, struct dentry *parent, u32 *value); void debugfs_create_u64(const char *name, umode_t mode, struct dentry *parent, u64 *value);h]hXvoid debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent, u8 *value); void debugfs_create_u16(const char *name, umode_t mode, struct dentry *parent, u16 *value); void debugfs_create_u32(const char *name, umode_t mode, struct dentry *parent, u32 *value); void debugfs_create_u64(const char *name, umode_t mode, struct dentry *parent, u64 *value);}hjxsbah}(h]h ]h"]h$]h&]hhuh1jhhhKNhjIhhubj])}(hX These files support both reading and writing the given value; if a specific file should not be written to, simply set the mode bits accordingly. The values in these files are in decimal; if hexadecimal is more appropriate, the following functions can be used instead::h]hX These files support both reading and writing the given value; if a specific file should not be written to, simply set the mode bits accordingly. The values in these files are in decimal; if hexadecimal is more appropriate, the following functions can be used instead:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKWhjIhhubj)}(hXvoid debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent, u8 *value); void debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent, u16 *value); void debugfs_create_x32(const char *name, umode_t mode, struct dentry *parent, u32 *value); void debugfs_create_x64(const char *name, umode_t mode, struct dentry *parent, u64 *value);h]hXvoid debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent, u8 *value); void debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent, u16 *value); void debugfs_create_x32(const char *name, umode_t mode, struct dentry *parent, u32 *value); void debugfs_create_x64(const char *name, umode_t mode, struct dentry *parent, u64 *value);}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhK\hjIhhubj])}(hX These functions are useful as long as the developer knows the size of the value to be exported. Some types can have different widths on different architectures, though, complicating the situation somewhat. There are functions meant to help out in such special cases::h]hX These functions are useful as long as the developer knows the size of the value to be exported. Some types can have different widths on different architectures, though, complicating the situation somewhat. There are functions meant to help out in such special cases:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKehjIhhubj)}(h|void debugfs_create_size_t(const char *name, umode_t mode, struct dentry *parent, size_t *value);h]h|void debugfs_create_size_t(const char *name, umode_t mode, struct dentry *parent, size_t *value);}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKjhjIhhubj])}(hfAs might be expected, this function will create a debugfs file to represent a variable of type size_t.h]hfAs might be expected, this function will create a debugfs file to represent a variable of type size_t.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKmhjIhhubj])}(h^Similarly, there are helpers for variables of type unsigned long, in decimal and hexadecimal::h]h]Similarly, there are helpers for variables of type unsigned long, in decimal and hexadecimal:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKphjIhhubj)}(hX7struct dentry *debugfs_create_ulong(const char *name, umode_t mode, struct dentry *parent, unsigned long *value); void debugfs_create_xul(const char *name, umode_t mode, struct dentry *parent, unsigned long *value);h]hX7struct dentry *debugfs_create_ulong(const char *name, umode_t mode, struct dentry *parent, unsigned long *value); void debugfs_create_xul(const char *name, umode_t mode, struct dentry *parent, unsigned long *value);}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKshjIhhubj])}(h.Boolean values can be placed in debugfs with::h]h-Boolean values can be placed in debugfs with:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKyhjIhhubj)}(hvvoid debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent, bool *value);h]hvvoid debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent, bool *value);}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhK{hjIhhubj])}(hA read on the resulting file will yield either Y (for non-zero values) or N, followed by a newline. If written to, it will accept either upper- or lower-case values, or 1 or 0. Any other input will be silently ignored.h]hA read on the resulting file will yield either Y (for non-zero values) or N, followed by a newline. If written to, it will accept either upper- or lower-case values, or 1 or 0. Any other input will be silently ignored.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhK~hjIhhubj])}(h5Also, atomic_t values can be placed in debugfs with::h]h4Also, atomic_t values can be placed in debugfs with:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj)}(hvoid debugfs_create_atomic_t(const char *name, umode_t mode, struct dentry *parent, atomic_t *value)h]hvoid debugfs_create_atomic_t(const char *name, umode_t mode, struct dentry *parent, atomic_t *value)}hj sbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjIhhubj])}(h`A read of this file will get atomic_t values, and a write of this file will set atomic_t values.h]h`A read of this file will get atomic_t values, and a write of this file will set atomic_t values.}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj])}(h`Another option is exporting a block of arbitrary binary data, with this structure and function::h]h_Another option is exporting a block of arbitrary binary data, with this structure and function:}(hj<hhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj)}(hX struct debugfs_blob_wrapper { void *data; unsigned long size; }; struct dentry *debugfs_create_blob(const char *name, umode_t mode, struct dentry *parent, struct debugfs_blob_wrapper *blob);h]hX struct debugfs_blob_wrapper { void *data; unsigned long size; }; struct dentry *debugfs_create_blob(const char *name, umode_t mode, struct dentry *parent, struct debugfs_blob_wrapper *blob);}hjJsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjIhhubj])}(hXA read of this file will return the data pointed to by the debugfs_blob_wrapper structure. Some drivers use "blobs" as a simple way to return several lines of (static) formatted text output. This function can be used to export binary information, but there does not appear to be any code which does so in the mainline. Note that all files created with debugfs_create_blob() are read-only.h]hXA read of this file will return the data pointed to by the debugfs_blob_wrapper structure. Some drivers use “blobs” as a simple way to return several lines of (static) formatted text output. This function can be used to export binary information, but there does not appear to be any code which does so in the mainline. Note that all files created with debugfs_create_blob() are read-only.}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj])}(hXIf you want to dump a block of registers (something that happens quite often during development, even if little such code reaches mainline), debugfs offers two functions: one to make a registers-only file, and another to insert a register block in the middle of another sequential file::h]hXIf you want to dump a block of registers (something that happens quite often during development, even if little such code reaches mainline), debugfs offers two functions: one to make a registers-only file, and another to insert a register block in the middle of another sequential file:}(hjfhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj)}(hX%struct debugfs_reg32 { char *name; unsigned long offset; }; struct debugfs_regset32 { const struct debugfs_reg32 *regs; int nregs; void __iomem *base; struct device *dev; /* Optional device for Runtime PM */ }; debugfs_create_regset32(const char *name, umode_t mode, struct dentry *parent, struct debugfs_regset32 *regset); void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs, int nregs, void __iomem *base, char *prefix);h]hX%struct debugfs_reg32 { char *name; unsigned long offset; }; struct debugfs_regset32 { const struct debugfs_reg32 *regs; int nregs; void __iomem *base; struct device *dev; /* Optional device for Runtime PM */ }; debugfs_create_regset32(const char *name, umode_t mode, struct dentry *parent, struct debugfs_regset32 *regset); void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs, int nregs, void __iomem *base, char *prefix);}hjtsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjIhhubj])}(hThe "base" argument may be 0, but you may want to build the reg32 array using __stringify, and a number of register names (macros) are actually byte offsets over a base for the register block.h]hThe “base” argument may be 0, but you may want to build the reg32 array using __stringify, and a number of register names (macros) are actually byte offsets over a base for the register block.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj])}(hHIf you want to dump a u32 array in debugfs, you can create a file with::h]hGIf you want to dump a u32 array in debugfs, you can create a file with:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj)}(hstruct debugfs_u32_array { u32 *array; u32 n_elements; }; void debugfs_create_u32_array(const char *name, umode_t mode, struct dentry *parent, struct debugfs_u32_array *array);h]hstruct debugfs_u32_array { u32 *array; u32 n_elements; }; void debugfs_create_u32_array(const char *name, umode_t mode, struct dentry *parent, struct debugfs_u32_array *array);}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjIhhubj])}(hThe "array" argument wraps a pointer to the array's data and the number of its elements. Note: Once array is created its size can not be changed.h]hThe “array” argument wraps a pointer to the array’s data and the number of its elements. Note: Once array is created its size can not be changed.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj])}(h@There is a helper function to create a device-related seq_file::h]h?There is a helper function to create a device-related seq_file:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj)}(hX void debugfs_create_devm_seqfile(struct device *dev, const char *name, struct dentry *parent, int (*read_fn)(struct seq_file *s, void *data));h]hX void debugfs_create_devm_seqfile(struct device *dev, const char *name, struct dentry *parent, int (*read_fn)(struct seq_file *s, void *data));}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjIhhubj])}(hThe "dev" argument is the device related to this debugfs file, and the "read_fn" is a function pointer which to be called to print the seq_file content.h]hThe “dev” argument is the device related to this debugfs file, and the “read_fn” is a function pointer which to be called to print the seq_file content.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj])}(hAThere are a couple of other directory-oriented helper functions::h]h@There are a couple of other directory-oriented helper functions:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj)}(hX'struct dentry *debugfs_change_name(struct dentry *dentry, const char *fmt, ...); struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, const char *target);h]hX'struct dentry *debugfs_change_name(struct dentry *dentry, const char *fmt, ...); struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, const char *target);}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjIhhubj])}(hXA call to debugfs_change_name() will give a new name to an existing debugfs file, always in the same directory. The new_name must not exist prior to the call; the return value is 0 on success and -E... on failure. Symbolic links can be created with debugfs_create_symlink().h]hXA call to debugfs_change_name() will give a new name to an existing debugfs file, always in the same directory. The new_name must not exist prior to the call; the return value is 0 on success and -E... on failure. Symbolic links can be created with debugfs_create_symlink().}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj])}(hXThere is one important thing that all debugfs users must take into account: there is no automatic cleanup of any directories created in debugfs. If a module is unloaded without explicitly removing debugfs entries, the result will be a lot of stale pointers and no end of highly antisocial behavior. So all debugfs users - at least those which can be built as modules - must be prepared to remove all files and directories they create there. A file can be removed with::h]hXThere is one important thing that all debugfs users must take into account: there is no automatic cleanup of any directories created in debugfs. If a module is unloaded without explicitly removing debugfs entries, the result will be a lot of stale pointers and no end of highly antisocial behavior. So all debugfs users - at least those which can be built as modules - must be prepared to remove all files and directories they create there. A file can be removed with:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj)}(h+void debugfs_remove(struct dentry *dentry);h]h+void debugfs_remove(struct dentry *dentry);}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjIhhubj])}(hVThe dentry value can be NULL or an error value, in which case nothing will be removed.h]hVThe dentry value can be NULL or an error value, in which case nothing will be removed.}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj])}(hOnce upon a time, debugfs users were required to remember the dentry pointer for every debugfs file they created so that all files could be cleaned up. We live in more civilized times now, though, and debugfs users can call::h]hOnce upon a time, debugfs users were required to remember the dentry pointer for every debugfs file they created so that all files could be cleaned up. We live in more civilized times now, though, and debugfs users can call:}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubj)}(h5void debugfs_remove_recursive(struct dentry *dentry);h]h5void debugfs_remove_recursive(struct dentry *dentry);}hjFsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjIhhubj])}(hIf this function is passed a pointer for the dentry corresponding to the top-level directory, the entire hierarchy below that directory will be removed.h]hIf this function is passed a pointer for the dentry corresponding to the top-level directory, the entire hierarchy below that directory will be removed.}(hjThhhNhNubah}(h]h ]h"]h$]h&]uh1j\hhhKhjIhhubhfootnote)}(hhttp://lwn.net/Articles/309298/h](hlabel)}(h1h]h1}(hjjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhjdubj])}(hjfh]jo)}(hjfh]hhttp://lwn.net/Articles/309298/}(hj{hhhNhNubah}(h]h ]h"]h$]h&]refurijfuh1jnhjxubah}(h]h ]h"]h$]h&]uh1j\hhhKhjdubeh}(h]jah ]h"]1ah$]h&]jajjuh1jbhhhKhjIhhjKubeh}(h]debugfsah ]h"]debugfsah$]h&]uh1jGhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(jLN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}(hhhhhhj jjjj*jj9j-jHj<jWjKjfjZjujijjxjjjjjjjjjjjjjjjjj jjjj)jj8j,jGj;jVjJjejYjtjhjjwjjjjjjjjjjjjjjjjj jjj j(jj7j+jFj:jUjIjdjXjsjgjjvjjjjjjjjjjjjjjjjj jjj j'jj6j*jEj9jTjHjcjWjrjfjjujjjjjjjjjjjjjjjjjjjj j&jj5j)jDj8usubstitution_names}(amphߌaposhasthbrvbarj bsoljcentj*colonj9commajHcommatjWcopyjfcurrenjudarrjdegjdividejdollarjequalsjexcljfrac12jfrac14jfrac18jfrac34j frac38jfrac58j)frac78j8gtjGhalfjVhorbarjehyphenjtiexcljiquestjlaquojlarrjlcubjldquojlowbarjlparjlsqbjlsquoj ltjmicroj(middotj7nbspjFnotjUnumjdohmjsordfjordmjparajpercntjperiodjplusjplusmnjpoundjquestjquotj raquojrarrj'rcubj6rdquojEregjTrparjcrsqbjrrsquojsectjsemijshyjsoljsungjsup1jsup2jsup3jtimesjtradejuarrj&verbarj5yenjDurefnames}1]jasrefids}nameids}(jjjju nametypes}(jjuh}(jjIjjjjdu footnote_refs}jM ]jas citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes]jda citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}jKsRparse_messages]transform_messages] transformerN include_log]%Documentation/filesystems/debugfs.rst(NNNNta decorationNhhub.