12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689 |
- #ifndef _LINUX_FS_H
- #define _LINUX_FS_H
- #include <linux/linkage.h>
- #include <linux/wait_bit.h>
- #include <linux/kdev_t.h>
- #include <linux/dcache.h>
- #include <linux/path.h>
- #include <linux/stat.h>
- #include <linux/cache.h>
- #include <linux/list.h>
- #include <linux/list_lru.h>
- #include <linux/llist.h>
- #include <linux/radix-tree.h>
- #include <linux/xarray.h>
- #include <linux/rbtree.h>
- #include <linux/init.h>
- #include <linux/pid.h>
- #include <linux/bug.h>
- #include <linux/mutex.h>
- #include <linux/rwsem.h>
- #include <linux/mm_types.h>
- #include <linux/capability.h>
- #include <linux/semaphore.h>
- #include <linux/fcntl.h>
- #include <linux/rculist_bl.h>
- #include <linux/atomic.h>
- #include <linux/shrinker.h>
- #include <linux/migrate_mode.h>
- #include <linux/uidgid.h>
- #include <linux/lockdep.h>
- #include <linux/percpu-rwsem.h>
- #include <linux/workqueue.h>
- #include <linux/delayed_call.h>
- #include <linux/uuid.h>
- #include <linux/errseq.h>
- #include <linux/ioprio.h>
- #include <linux/fs_types.h>
- #include <linux/build_bug.h>
- #include <linux/stddef.h>
- #include <linux/mount.h>
- #include <linux/cred.h>
- #include <linux/mnt_idmapping.h>
- #include <linux/slab.h>
- #include <asm/byteorder.h>
- #include <uapi/linux/fs.h>
- struct backing_dev_info;
- struct bdi_writeback;
- struct bio;
- struct io_comp_batch;
- struct export_operations;
- struct fiemap_extent_info;
- struct hd_geometry;
- struct iovec;
- struct kiocb;
- struct kobject;
- struct pipe_inode_info;
- struct poll_table_struct;
- struct kstatfs;
- struct vm_area_struct;
- struct vfsmount;
- struct cred;
- struct swap_info_struct;
- struct seq_file;
- struct workqueue_struct;
- struct iov_iter;
- struct fscrypt_info;
- struct fscrypt_operations;
- struct fsverity_info;
- struct fsverity_operations;
- struct fs_context;
- struct fs_parameter_spec;
- struct fileattr;
- struct iomap_ops;
- extern void __init inode_init(void);
- extern void __init inode_init_early(void);
- extern void __init files_init(void);
- extern void __init files_maxfiles_init(void);
- extern unsigned long get_max_files(void);
- extern unsigned int sysctl_nr_open;
- typedef __kernel_rwf_t rwf_t;
- struct buffer_head;
- typedef int (get_block_t)(struct inode *inode, sector_t iblock,
- struct buffer_head *bh_result, int create);
- typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
- ssize_t bytes, void *private);
- #define MAY_EXEC 0x00000001
- #define MAY_WRITE 0x00000002
- #define MAY_READ 0x00000004
- #define MAY_APPEND 0x00000008
- #define MAY_ACCESS 0x00000010
- #define MAY_OPEN 0x00000020
- #define MAY_CHDIR 0x00000040
- #define MAY_NOT_BLOCK 0x00000080
- #define FMODE_READ ((__force fmode_t)0x1)
- #define FMODE_WRITE ((__force fmode_t)0x2)
- #define FMODE_LSEEK ((__force fmode_t)0x4)
- #define FMODE_PREAD ((__force fmode_t)0x8)
- #define FMODE_PWRITE ((__force fmode_t)0x10)
- #define FMODE_EXEC ((__force fmode_t)0x20)
- #define FMODE_NDELAY ((__force fmode_t)0x40)
- #define FMODE_EXCL ((__force fmode_t)0x80)
- #define FMODE_WRITE_IOCTL ((__force fmode_t)0x100)
- #define FMODE_32BITHASH ((__force fmode_t)0x200)
- #define FMODE_64BITHASH ((__force fmode_t)0x400)
- #define FMODE_NOCMTIME ((__force fmode_t)0x800)
- #define FMODE_RANDOM ((__force fmode_t)0x1000)
- #define FMODE_UNSIGNED_OFFSET ((__force fmode_t)0x2000)
- #define FMODE_PATH ((__force fmode_t)0x4000)
- #define FMODE_ATOMIC_POS ((__force fmode_t)0x8000)
- #define FMODE_WRITER ((__force fmode_t)0x10000)
- #define FMODE_CAN_READ ((__force fmode_t)0x20000)
- #define FMODE_CAN_WRITE ((__force fmode_t)0x40000)
- #define FMODE_OPENED ((__force fmode_t)0x80000)
- #define FMODE_CREATED ((__force fmode_t)0x100000)
- #define FMODE_STREAM ((__force fmode_t)0x200000)
- #define FMODE_CAN_ODIRECT ((__force fmode_t)0x400000)
- #define FMODE_NOREUSE ((__force fmode_t)0x800000)
- #define FMODE_NONOTIFY ((__force fmode_t)0x4000000)
- #define FMODE_NOWAIT ((__force fmode_t)0x8000000)
- #define FMODE_NEED_UNMOUNT ((__force fmode_t)0x10000000)
- #define FMODE_NOACCOUNT ((__force fmode_t)0x20000000)
- #define FMODE_BUF_RASYNC ((__force fmode_t)0x40000000)
- #define FMODE_BUF_WASYNC ((__force fmode_t)0x80000000)
- #define ATTR_MODE (1 << 0)
- #define ATTR_UID (1 << 1)
- #define ATTR_GID (1 << 2)
- #define ATTR_SIZE (1 << 3)
- #define ATTR_ATIME (1 << 4)
- #define ATTR_MTIME (1 << 5)
- #define ATTR_CTIME (1 << 6)
- #define ATTR_ATIME_SET (1 << 7)
- #define ATTR_MTIME_SET (1 << 8)
- #define ATTR_FORCE (1 << 9)
- #define ATTR_KILL_SUID (1 << 11)
- #define ATTR_KILL_SGID (1 << 12)
- #define ATTR_FILE (1 << 13)
- #define ATTR_KILL_PRIV (1 << 14)
- #define ATTR_OPEN (1 << 15)
- #define ATTR_TIMES_SET (1 << 16)
- #define ATTR_TOUCH (1 << 17)
- #define WHITEOUT_MODE 0
- #define WHITEOUT_DEV 0
- struct iattr {
- unsigned int ia_valid;
- umode_t ia_mode;
-
- union {
- kuid_t ia_uid;
- vfsuid_t ia_vfsuid;
- };
- union {
- kgid_t ia_gid;
- vfsgid_t ia_vfsgid;
- };
- loff_t ia_size;
- struct timespec64 ia_atime;
- struct timespec64 ia_mtime;
- struct timespec64 ia_ctime;
-
- struct file *ia_file;
- };
- #include <linux/quota.h>
- #define FILESYSTEM_MAX_STACK_DEPTH 2
- enum positive_aop_returns {
- AOP_WRITEPAGE_ACTIVATE = 0x80000,
- AOP_TRUNCATED_PAGE = 0x80001,
- };
- struct page;
- struct address_space;
- struct writeback_control;
- struct readahead_control;
- enum rw_hint {
- WRITE_LIFE_NOT_SET = 0,
- WRITE_LIFE_NONE = RWH_WRITE_LIFE_NONE,
- WRITE_LIFE_SHORT = RWH_WRITE_LIFE_SHORT,
- WRITE_LIFE_MEDIUM = RWH_WRITE_LIFE_MEDIUM,
- WRITE_LIFE_LONG = RWH_WRITE_LIFE_LONG,
- WRITE_LIFE_EXTREME = RWH_WRITE_LIFE_EXTREME,
- };
- #define IOCB_HIPRI (__force int) RWF_HIPRI
- #define IOCB_DSYNC (__force int) RWF_DSYNC
- #define IOCB_SYNC (__force int) RWF_SYNC
- #define IOCB_NOWAIT (__force int) RWF_NOWAIT
- #define IOCB_APPEND (__force int) RWF_APPEND
- #define IOCB_EVENTFD (1 << 16)
- #define IOCB_DIRECT (1 << 17)
- #define IOCB_WRITE (1 << 18)
- #define IOCB_WAITQ (1 << 19)
- #define IOCB_NOIO (1 << 20)
- #define IOCB_ALLOC_CACHE (1 << 21)
- struct kiocb {
- struct file *ki_filp;
- loff_t ki_pos;
- void (*ki_complete)(struct kiocb *iocb, long ret);
- void *private;
- int ki_flags;
- u16 ki_ioprio;
- struct wait_page_queue *ki_waitq;
- };
- static inline bool is_sync_kiocb(struct kiocb *kiocb)
- {
- return kiocb->ki_complete == NULL;
- }
- struct address_space_operations {
- int (*writepage)(struct page *page, struct writeback_control *wbc);
- int (*read_folio)(struct file *, struct folio *);
-
- int (*writepages)(struct address_space *, struct writeback_control *);
-
- bool (*dirty_folio)(struct address_space *, struct folio *);
- void (*readahead)(struct readahead_control *);
- int (*write_begin)(struct file *, struct address_space *mapping,
- loff_t pos, unsigned len,
- struct page **pagep, void **fsdata);
- int (*write_end)(struct file *, struct address_space *mapping,
- loff_t pos, unsigned len, unsigned copied,
- struct page *page, void *fsdata);
-
- sector_t (*bmap)(struct address_space *, sector_t);
- void (*invalidate_folio) (struct folio *, size_t offset, size_t len);
- bool (*release_folio)(struct folio *, gfp_t);
- void (*free_folio)(struct folio *folio);
- ssize_t (*direct_IO)(struct kiocb *, struct iov_iter *iter);
-
- int (*migrate_folio)(struct address_space *, struct folio *dst,
- struct folio *src, enum migrate_mode);
- int (*launder_folio)(struct folio *);
- bool (*is_partially_uptodate) (struct folio *, size_t from,
- size_t count);
- void (*is_dirty_writeback) (struct folio *, bool *dirty, bool *wb);
- int (*error_remove_page)(struct address_space *, struct page *);
-
- int (*swap_activate)(struct swap_info_struct *sis, struct file *file,
- sector_t *span);
- void (*swap_deactivate)(struct file *file);
- int (*swap_rw)(struct kiocb *iocb, struct iov_iter *iter);
- };
- extern const struct address_space_operations empty_aops;
- struct address_space {
- struct inode *host;
- struct xarray i_pages;
- struct rw_semaphore invalidate_lock;
- gfp_t gfp_mask;
- atomic_t i_mmap_writable;
- #ifdef CONFIG_READ_ONLY_THP_FOR_FS
-
- atomic_t nr_thps;
- #endif
- struct rb_root_cached i_mmap;
- struct rw_semaphore i_mmap_rwsem;
- unsigned long nrpages;
- pgoff_t writeback_index;
- const struct address_space_operations *a_ops;
- unsigned long flags;
- errseq_t wb_err;
- spinlock_t private_lock;
- struct list_head private_list;
- void *private_data;
- } __attribute__((aligned(sizeof(long)))) __randomize_layout;
-
- #define PAGECACHE_TAG_DIRTY XA_MARK_0
- #define PAGECACHE_TAG_WRITEBACK XA_MARK_1
- #define PAGECACHE_TAG_TOWRITE XA_MARK_2
- static inline bool mapping_tagged(struct address_space *mapping, xa_mark_t tag)
- {
- return xa_marked(&mapping->i_pages, tag);
- }
- static inline void i_mmap_lock_write(struct address_space *mapping)
- {
- down_write(&mapping->i_mmap_rwsem);
- }
- static inline int i_mmap_trylock_write(struct address_space *mapping)
- {
- return down_write_trylock(&mapping->i_mmap_rwsem);
- }
- static inline void i_mmap_unlock_write(struct address_space *mapping)
- {
- up_write(&mapping->i_mmap_rwsem);
- }
- static inline int i_mmap_trylock_read(struct address_space *mapping)
- {
- return down_read_trylock(&mapping->i_mmap_rwsem);
- }
- static inline void i_mmap_lock_read(struct address_space *mapping)
- {
- down_read(&mapping->i_mmap_rwsem);
- }
- static inline void i_mmap_unlock_read(struct address_space *mapping)
- {
- up_read(&mapping->i_mmap_rwsem);
- }
- static inline void i_mmap_assert_locked(struct address_space *mapping)
- {
- lockdep_assert_held(&mapping->i_mmap_rwsem);
- }
- static inline void i_mmap_assert_write_locked(struct address_space *mapping)
- {
- lockdep_assert_held_write(&mapping->i_mmap_rwsem);
- }
- static inline int mapping_mapped(struct address_space *mapping)
- {
- return !RB_EMPTY_ROOT(&mapping->i_mmap.rb_root);
- }
- static inline int mapping_writably_mapped(struct address_space *mapping)
- {
- return atomic_read(&mapping->i_mmap_writable) > 0;
- }
- static inline int mapping_map_writable(struct address_space *mapping)
- {
- return atomic_inc_unless_negative(&mapping->i_mmap_writable) ?
- 0 : -EPERM;
- }
- static inline void mapping_unmap_writable(struct address_space *mapping)
- {
- atomic_dec(&mapping->i_mmap_writable);
- }
- static inline int mapping_deny_writable(struct address_space *mapping)
- {
- return atomic_dec_unless_positive(&mapping->i_mmap_writable) ?
- 0 : -EBUSY;
- }
- static inline void mapping_allow_writable(struct address_space *mapping)
- {
- atomic_inc(&mapping->i_mmap_writable);
- }
- #if BITS_PER_LONG==32 && defined(CONFIG_SMP)
- #include <linux/seqlock.h>
- #define __NEED_I_SIZE_ORDERED
- #define i_size_ordered_init(inode) seqcount_init(&inode->i_size_seqcount)
- #else
- #define i_size_ordered_init(inode) do { } while (0)
- #endif
- struct posix_acl;
- #define ACL_NOT_CACHED ((void *)(-1))
- #define ACL_DONT_CACHE ((void *)(-3))
- static inline struct posix_acl *
- uncached_acl_sentinel(struct task_struct *task)
- {
- return (void *)task + 1;
- }
- static inline bool
- is_uncached_acl(struct posix_acl *acl)
- {
- return (long)acl & 1;
- }
- #define IOP_FASTPERM 0x0001
- #define IOP_LOOKUP 0x0002
- #define IOP_NOFOLLOW 0x0004
- #define IOP_XATTR 0x0008
- #define IOP_DEFAULT_READLINK 0x0010
- struct fsnotify_mark_connector;
- struct inode {
- umode_t i_mode;
- unsigned short i_opflags;
- kuid_t i_uid;
- kgid_t i_gid;
- unsigned int i_flags;
- #ifdef CONFIG_FS_POSIX_ACL
- struct posix_acl *i_acl;
- struct posix_acl *i_default_acl;
- #endif
- const struct inode_operations *i_op;
- struct super_block *i_sb;
- struct address_space *i_mapping;
- #ifdef CONFIG_SECURITY
- void *i_security;
- #endif
-
- unsigned long i_ino;
-
- union {
- const unsigned int i_nlink;
- unsigned int __i_nlink;
- };
- dev_t i_rdev;
- loff_t i_size;
- struct timespec64 i_atime;
- struct timespec64 i_mtime;
- struct timespec64 i_ctime;
- spinlock_t i_lock;
- unsigned short i_bytes;
- u8 i_blkbits;
- u8 i_write_hint;
- blkcnt_t i_blocks;
- #ifdef __NEED_I_SIZE_ORDERED
- seqcount_t i_size_seqcount;
- #endif
-
- unsigned long i_state;
- struct rw_semaphore i_rwsem;
- unsigned long dirtied_when;
- unsigned long dirtied_time_when;
- struct hlist_node i_hash;
- struct list_head i_io_list;
- #ifdef CONFIG_CGROUP_WRITEBACK
- struct bdi_writeback *i_wb;
-
- int i_wb_frn_winner;
- u16 i_wb_frn_avg_time;
- u16 i_wb_frn_history;
- #endif
- struct list_head i_lru;
- struct list_head i_sb_list;
- struct list_head i_wb_list;
- union {
- struct hlist_head i_dentry;
- struct rcu_head i_rcu;
- };
- atomic64_t i_version;
- atomic64_t i_sequence;
- atomic_t i_count;
- atomic_t i_dio_count;
- atomic_t i_writecount;
- #if defined(CONFIG_IMA) || defined(CONFIG_FILE_LOCKING)
- atomic_t i_readcount;
- #endif
- union {
- const struct file_operations *i_fop;
- void (*free_inode)(struct inode *);
- };
- struct file_lock_context *i_flctx;
- struct address_space i_data;
- struct list_head i_devices;
- union {
- struct pipe_inode_info *i_pipe;
- struct cdev *i_cdev;
- char *i_link;
- unsigned i_dir_seq;
- };
- __u32 i_generation;
- #ifdef CONFIG_FSNOTIFY
- __u32 i_fsnotify_mask;
- struct fsnotify_mark_connector __rcu *i_fsnotify_marks;
- #endif
- #ifdef CONFIG_FS_ENCRYPTION
- struct fscrypt_info *i_crypt_info;
- #endif
- #ifdef CONFIG_FS_VERITY
- struct fsverity_info *i_verity_info;
- #endif
- void *i_private;
- } __randomize_layout;
- struct timespec64 timestamp_truncate(struct timespec64 t, struct inode *inode);
- static inline unsigned int i_blocksize(const struct inode *node)
- {
- return (1 << node->i_blkbits);
- }
- static inline int inode_unhashed(struct inode *inode)
- {
- return hlist_unhashed(&inode->i_hash);
- }
- static inline void inode_fake_hash(struct inode *inode)
- {
- hlist_add_fake(&inode->i_hash);
- }
- enum inode_i_mutex_lock_class
- {
- I_MUTEX_NORMAL,
- I_MUTEX_PARENT,
- I_MUTEX_CHILD,
- I_MUTEX_XATTR,
- I_MUTEX_NONDIR2,
- I_MUTEX_PARENT2,
- };
- static inline void inode_lock(struct inode *inode)
- {
- down_write(&inode->i_rwsem);
- }
- static inline void inode_unlock(struct inode *inode)
- {
- up_write(&inode->i_rwsem);
- }
- static inline void inode_lock_shared(struct inode *inode)
- {
- down_read(&inode->i_rwsem);
- }
- static inline void inode_unlock_shared(struct inode *inode)
- {
- up_read(&inode->i_rwsem);
- }
- static inline int inode_trylock(struct inode *inode)
- {
- return down_write_trylock(&inode->i_rwsem);
- }
- static inline int inode_trylock_shared(struct inode *inode)
- {
- return down_read_trylock(&inode->i_rwsem);
- }
- static inline int inode_is_locked(struct inode *inode)
- {
- return rwsem_is_locked(&inode->i_rwsem);
- }
- static inline void inode_lock_nested(struct inode *inode, unsigned subclass)
- {
- down_write_nested(&inode->i_rwsem, subclass);
- }
- static inline void inode_lock_shared_nested(struct inode *inode, unsigned subclass)
- {
- down_read_nested(&inode->i_rwsem, subclass);
- }
- static inline void filemap_invalidate_lock(struct address_space *mapping)
- {
- down_write(&mapping->invalidate_lock);
- }
- static inline void filemap_invalidate_unlock(struct address_space *mapping)
- {
- up_write(&mapping->invalidate_lock);
- }
- static inline void filemap_invalidate_lock_shared(struct address_space *mapping)
- {
- down_read(&mapping->invalidate_lock);
- }
- static inline int filemap_invalidate_trylock_shared(
- struct address_space *mapping)
- {
- return down_read_trylock(&mapping->invalidate_lock);
- }
- static inline void filemap_invalidate_unlock_shared(
- struct address_space *mapping)
- {
- up_read(&mapping->invalidate_lock);
- }
- void lock_two_nondirectories(struct inode *, struct inode*);
- void unlock_two_nondirectories(struct inode *, struct inode*);
- void filemap_invalidate_lock_two(struct address_space *mapping1,
- struct address_space *mapping2);
- void filemap_invalidate_unlock_two(struct address_space *mapping1,
- struct address_space *mapping2);
- static inline loff_t i_size_read(const struct inode *inode)
- {
- #if BITS_PER_LONG==32 && defined(CONFIG_SMP)
- loff_t i_size;
- unsigned int seq;
- do {
- seq = read_seqcount_begin(&inode->i_size_seqcount);
- i_size = inode->i_size;
- } while (read_seqcount_retry(&inode->i_size_seqcount, seq));
- return i_size;
- #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)
- loff_t i_size;
- preempt_disable();
- i_size = inode->i_size;
- preempt_enable();
- return i_size;
- #else
- return inode->i_size;
- #endif
- }
- static inline void i_size_write(struct inode *inode, loff_t i_size)
- {
- #if BITS_PER_LONG==32 && defined(CONFIG_SMP)
- preempt_disable();
- write_seqcount_begin(&inode->i_size_seqcount);
- inode->i_size = i_size;
- write_seqcount_end(&inode->i_size_seqcount);
- preempt_enable();
- #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)
- preempt_disable();
- inode->i_size = i_size;
- preempt_enable();
- #else
- inode->i_size = i_size;
- #endif
- }
- static inline unsigned iminor(const struct inode *inode)
- {
- return MINOR(inode->i_rdev);
- }
- static inline unsigned imajor(const struct inode *inode)
- {
- return MAJOR(inode->i_rdev);
- }
- struct fown_struct {
- rwlock_t lock;
- struct pid *pid;
- enum pid_type pid_type;
- kuid_t uid, euid;
- int signum;
- };
- struct file_ra_state {
- pgoff_t start;
- unsigned int size;
- unsigned int async_size;
- unsigned int ra_pages;
- unsigned int mmap_miss;
- loff_t prev_pos;
- };
- static inline int ra_has_index(struct file_ra_state *ra, pgoff_t index)
- {
- return (index >= ra->start &&
- index < ra->start + ra->size);
- }
- struct file {
- union {
- struct llist_node f_llist;
- struct rcu_head f_rcuhead;
- unsigned int f_iocb_flags;
- };
- struct path f_path;
- struct inode *f_inode;
- const struct file_operations *f_op;
-
- spinlock_t f_lock;
- atomic_long_t f_count;
- unsigned int f_flags;
- fmode_t f_mode;
- struct mutex f_pos_lock;
- loff_t f_pos;
- struct fown_struct f_owner;
- const struct cred *f_cred;
- struct file_ra_state f_ra;
- u64 f_version;
- #ifdef CONFIG_SECURITY
- void *f_security;
- #endif
-
- void *private_data;
- #ifdef CONFIG_EPOLL
-
- struct hlist_head *f_ep;
- #endif
- struct address_space *f_mapping;
- errseq_t f_wb_err;
- errseq_t f_sb_err;
- ANDROID_KABI_RESERVE(1);
- ANDROID_KABI_RESERVE(2);
- } __randomize_layout
- __attribute__((aligned(4)));
- struct file_handle {
- __u32 handle_bytes;
- int handle_type;
-
- unsigned char f_handle[];
- };
- static inline struct file *get_file(struct file *f)
- {
- atomic_long_inc(&f->f_count);
- return f;
- }
- #define get_file_rcu(x) atomic_long_inc_not_zero(&(x)->f_count)
- #define file_count(x) atomic_long_read(&(x)->f_count)
- #define MAX_NON_LFS ((1UL<<31) - 1)
-
- #if BITS_PER_LONG==32
- #define MAX_LFS_FILESIZE ((loff_t)ULONG_MAX << PAGE_SHIFT)
- #elif BITS_PER_LONG==64
- #define MAX_LFS_FILESIZE ((loff_t)LLONG_MAX)
- #endif
- #define FL_POSIX 1
- #define FL_FLOCK 2
- #define FL_DELEG 4
- #define FL_ACCESS 8
- #define FL_EXISTS 16
- #define FL_LEASE 32
- #define FL_CLOSE 64
- #define FL_SLEEP 128
- #define FL_DOWNGRADE_PENDING 256
- #define FL_UNLOCK_PENDING 512
- #define FL_OFDLCK 1024
- #define FL_LAYOUT 2048
- #define FL_RECLAIM 4096
- #define FL_CLOSE_POSIX (FL_POSIX | FL_CLOSE)
- #define FILE_LOCK_DEFERRED 1
- typedef void *fl_owner_t;
- struct file_lock;
- struct file_lock_operations {
- void (*fl_copy_lock)(struct file_lock *, struct file_lock *);
- void (*fl_release_private)(struct file_lock *);
- };
- struct lock_manager_operations {
- void *lm_mod_owner;
- fl_owner_t (*lm_get_owner)(fl_owner_t);
- void (*lm_put_owner)(fl_owner_t);
- void (*lm_notify)(struct file_lock *);
- int (*lm_grant)(struct file_lock *, int);
- bool (*lm_break)(struct file_lock *);
- int (*lm_change)(struct file_lock *, int, struct list_head *);
- void (*lm_setup)(struct file_lock *, void **);
- bool (*lm_breaker_owns_lease)(struct file_lock *);
- bool (*lm_lock_expirable)(struct file_lock *cfl);
- void (*lm_expire_lock)(void);
- };
- struct lock_manager {
- struct list_head list;
-
- bool block_opens;
- };
- struct net;
- void locks_start_grace(struct net *, struct lock_manager *);
- void locks_end_grace(struct lock_manager *);
- bool locks_in_grace(struct net *);
- bool opens_in_grace(struct net *);
- #include <linux/nfs_fs_i.h>
- struct file_lock {
- struct file_lock *fl_blocker;
- struct list_head fl_list;
- struct hlist_node fl_link;
- struct list_head fl_blocked_requests;
- struct list_head fl_blocked_member;
- fl_owner_t fl_owner;
- unsigned int fl_flags;
- unsigned char fl_type;
- unsigned int fl_pid;
- int fl_link_cpu;
- wait_queue_head_t fl_wait;
- struct file *fl_file;
- loff_t fl_start;
- loff_t fl_end;
- struct fasync_struct * fl_fasync;
-
- unsigned long fl_break_time;
- unsigned long fl_downgrade_time;
- const struct file_lock_operations *fl_ops;
- const struct lock_manager_operations *fl_lmops;
- union {
- struct nfs_lock_info nfs_fl;
- struct nfs4_lock_info nfs4_fl;
- struct {
- struct list_head link;
- int state;
- unsigned int debug_id;
- } afs;
- } fl_u;
- } __randomize_layout;
- struct file_lock_context {
- spinlock_t flc_lock;
- struct list_head flc_flock;
- struct list_head flc_posix;
- struct list_head flc_lease;
- };
- #ifndef OFFSET_MAX
- #define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
- #define OFFSET_MAX INT_LIMIT(loff_t)
- #define OFFT_OFFSET_MAX INT_LIMIT(off_t)
- #endif
- extern void send_sigio(struct fown_struct *fown, int fd, int band);
- #define locks_inode(f) file_inode(f)
- #ifdef CONFIG_FILE_LOCKING
- extern int fcntl_getlk(struct file *, unsigned int, struct flock *);
- extern int fcntl_setlk(unsigned int, struct file *, unsigned int,
- struct flock *);
- #if BITS_PER_LONG == 32
- extern int fcntl_getlk64(struct file *, unsigned int, struct flock64 *);
- extern int fcntl_setlk64(unsigned int, struct file *, unsigned int,
- struct flock64 *);
- #endif
- extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
- extern int fcntl_getlease(struct file *filp);
- void locks_free_lock_context(struct inode *inode);
- void locks_free_lock(struct file_lock *fl);
- extern void locks_init_lock(struct file_lock *);
- extern struct file_lock * locks_alloc_lock(void);
- extern void locks_copy_lock(struct file_lock *, struct file_lock *);
- extern void locks_copy_conflock(struct file_lock *, struct file_lock *);
- extern void locks_remove_posix(struct file *, fl_owner_t);
- extern void locks_remove_file(struct file *);
- extern void locks_release_private(struct file_lock *);
- extern void posix_test_lock(struct file *, struct file_lock *);
- extern int posix_lock_file(struct file *, struct file_lock *, struct file_lock *);
- extern int locks_delete_block(struct file_lock *);
- extern int vfs_test_lock(struct file *, struct file_lock *);
- extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *);
- extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl);
- bool vfs_inode_has_locks(struct inode *inode);
- extern int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl);
- extern int __break_lease(struct inode *inode, unsigned int flags, unsigned int type);
- extern void lease_get_mtime(struct inode *, struct timespec64 *time);
- extern int generic_setlease(struct file *, long, struct file_lock **, void **priv);
- extern int vfs_setlease(struct file *, long, struct file_lock **, void **);
- extern int lease_modify(struct file_lock *, int, struct list_head *);
- struct notifier_block;
- extern int lease_register_notifier(struct notifier_block *);
- extern void lease_unregister_notifier(struct notifier_block *);
- struct files_struct;
- extern void show_fd_locks(struct seq_file *f,
- struct file *filp, struct files_struct *files);
- extern bool locks_owner_has_blockers(struct file_lock_context *flctx,
- fl_owner_t owner);
- #else
- static inline int fcntl_getlk(struct file *file, unsigned int cmd,
- struct flock __user *user)
- {
- return -EINVAL;
- }
- static inline int fcntl_setlk(unsigned int fd, struct file *file,
- unsigned int cmd, struct flock __user *user)
- {
- return -EACCES;
- }
- #if BITS_PER_LONG == 32
- static inline int fcntl_getlk64(struct file *file, unsigned int cmd,
- struct flock64 *user)
- {
- return -EINVAL;
- }
- static inline int fcntl_setlk64(unsigned int fd, struct file *file,
- unsigned int cmd, struct flock64 *user)
- {
- return -EACCES;
- }
- #endif
- static inline int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
- {
- return -EINVAL;
- }
- static inline int fcntl_getlease(struct file *filp)
- {
- return F_UNLCK;
- }
- static inline void
- locks_free_lock_context(struct inode *inode)
- {
- }
- static inline void locks_init_lock(struct file_lock *fl)
- {
- return;
- }
- static inline void locks_copy_conflock(struct file_lock *new, struct file_lock *fl)
- {
- return;
- }
- static inline void locks_copy_lock(struct file_lock *new, struct file_lock *fl)
- {
- return;
- }
- static inline void locks_remove_posix(struct file *filp, fl_owner_t owner)
- {
- return;
- }
- static inline void locks_remove_file(struct file *filp)
- {
- return;
- }
- static inline void posix_test_lock(struct file *filp, struct file_lock *fl)
- {
- return;
- }
- static inline int posix_lock_file(struct file *filp, struct file_lock *fl,
- struct file_lock *conflock)
- {
- return -ENOLCK;
- }
- static inline int locks_delete_block(struct file_lock *waiter)
- {
- return -ENOENT;
- }
- static inline int vfs_test_lock(struct file *filp, struct file_lock *fl)
- {
- return 0;
- }
- static inline int vfs_lock_file(struct file *filp, unsigned int cmd,
- struct file_lock *fl, struct file_lock *conf)
- {
- return -ENOLCK;
- }
- static inline int vfs_cancel_lock(struct file *filp, struct file_lock *fl)
- {
- return 0;
- }
- static inline bool vfs_inode_has_locks(struct inode *inode)
- {
- return false;
- }
- static inline int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl)
- {
- return -ENOLCK;
- }
- static inline int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
- {
- return 0;
- }
- static inline void lease_get_mtime(struct inode *inode,
- struct timespec64 *time)
- {
- return;
- }
- static inline int generic_setlease(struct file *filp, long arg,
- struct file_lock **flp, void **priv)
- {
- return -EINVAL;
- }
- static inline int vfs_setlease(struct file *filp, long arg,
- struct file_lock **lease, void **priv)
- {
- return -EINVAL;
- }
- static inline int lease_modify(struct file_lock *fl, int arg,
- struct list_head *dispose)
- {
- return -EINVAL;
- }
- struct files_struct;
- static inline void show_fd_locks(struct seq_file *f,
- struct file *filp, struct files_struct *files) {}
- static inline bool locks_owner_has_blockers(struct file_lock_context *flctx,
- fl_owner_t owner)
- {
- return false;
- }
- #endif
- static inline struct inode *file_inode(const struct file *f)
- {
- return f->f_inode;
- }
- static inline struct dentry *file_dentry(const struct file *file)
- {
- return d_real(file->f_path.dentry, file_inode(file));
- }
- static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl)
- {
- return locks_lock_inode_wait(locks_inode(filp), fl);
- }
- struct fasync_struct {
- rwlock_t fa_lock;
- int magic;
- int fa_fd;
- struct fasync_struct *fa_next;
- struct file *fa_file;
- struct rcu_head fa_rcu;
- };
- #define FASYNC_MAGIC 0x4601
- extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
- extern struct fasync_struct *fasync_insert_entry(int, struct file *, struct fasync_struct **, struct fasync_struct *);
- extern int fasync_remove_entry(struct file *, struct fasync_struct **);
- extern struct fasync_struct *fasync_alloc(void);
- extern void fasync_free(struct fasync_struct *);
- extern void kill_fasync(struct fasync_struct **, int, int);
- extern void __f_setown(struct file *filp, struct pid *, enum pid_type, int force);
- extern int f_setown(struct file *filp, unsigned long arg, int force);
- extern void f_delown(struct file *filp);
- extern pid_t f_getown(struct file *filp);
- extern int send_sigurg(struct fown_struct *fown);
- #define SB_RDONLY BIT(0)
- #define SB_NOSUID BIT(1)
- #define SB_NODEV BIT(2)
- #define SB_NOEXEC BIT(3)
- #define SB_SYNCHRONOUS BIT(4)
- #define SB_MANDLOCK BIT(6)
- #define SB_DIRSYNC BIT(7)
- #define SB_NOATIME BIT(10)
- #define SB_NODIRATIME BIT(11)
- #define SB_SILENT BIT(15)
- #define SB_POSIXACL BIT(16)
- #define SB_INLINECRYPT BIT(17)
- #define SB_KERNMOUNT BIT(22)
- #define SB_I_VERSION BIT(23)
- #define SB_LAZYTIME BIT(25)
- #define SB_SUBMOUNT BIT(26)
- #define SB_FORCE BIT(27)
- #define SB_NOSEC BIT(28)
- #define SB_BORN BIT(29)
- #define SB_ACTIVE BIT(30)
- #define SB_NOUSER BIT(31)
- #define SB_ENC_STRICT_MODE_FL (1 << 0)
- #define sb_has_strict_encoding(sb) \
- (sb->s_encoding_flags & SB_ENC_STRICT_MODE_FL)
- #define MNT_FORCE 0x00000001
- #define MNT_DETACH 0x00000002
- #define MNT_EXPIRE 0x00000004
- #define UMOUNT_NOFOLLOW 0x00000008
- #define UMOUNT_UNUSED 0x80000000
- #define SB_I_CGROUPWB 0x00000001
- #define SB_I_NOEXEC 0x00000002
- #define SB_I_NODEV 0x00000004
- #define SB_I_STABLE_WRITES 0x00000008
- #define SB_I_USERNS_VISIBLE 0x00000010
- #define SB_I_IMA_UNVERIFIABLE_SIGNATURE 0x00000020
- #define SB_I_UNTRUSTED_MOUNTER 0x00000040
- #define SB_I_SKIP_SYNC 0x00000100
- #define SB_I_PERSB_BDI 0x00000200
- #define SB_I_TS_EXPIRY_WARNED 0x00000400
- #define SB_I_RETIRED 0x00000800
- enum {
- SB_UNFROZEN = 0,
- SB_FREEZE_WRITE = 1,
- SB_FREEZE_PAGEFAULT = 2,
- SB_FREEZE_FS = 3,
- SB_FREEZE_COMPLETE = 4,
- };
- #define SB_FREEZE_LEVELS (SB_FREEZE_COMPLETE - 1)
- struct sb_writers {
- int frozen;
- wait_queue_head_t wait_unfrozen;
- struct percpu_rw_semaphore rw_sem[SB_FREEZE_LEVELS];
- };
- struct super_block {
- struct list_head s_list;
- dev_t s_dev;
- unsigned char s_blocksize_bits;
- unsigned long s_blocksize;
- loff_t s_maxbytes;
- struct file_system_type *s_type;
- const struct super_operations *s_op;
- const struct dquot_operations *dq_op;
- const struct quotactl_ops *s_qcop;
- const struct export_operations *s_export_op;
- unsigned long s_flags;
- unsigned long s_iflags;
- unsigned long s_magic;
- struct dentry *s_root;
- struct rw_semaphore s_umount;
- int s_count;
- atomic_t s_active;
- #ifdef CONFIG_SECURITY
- void *s_security;
- #endif
- const struct xattr_handler **s_xattr;
- #ifdef CONFIG_FS_ENCRYPTION
- const struct fscrypt_operations *s_cop;
- struct fscrypt_keyring *s_master_keys;
- #endif
- #ifdef CONFIG_FS_VERITY
- const struct fsverity_operations *s_vop;
- #endif
- #if IS_ENABLED(CONFIG_UNICODE)
- struct unicode_map *s_encoding;
- __u16 s_encoding_flags;
- #endif
- struct hlist_bl_head s_roots;
- struct list_head s_mounts;
- struct block_device *s_bdev;
- struct backing_dev_info *s_bdi;
- struct mtd_info *s_mtd;
- struct hlist_node s_instances;
- unsigned int s_quota_types;
- struct quota_info s_dquot;
- struct sb_writers s_writers;
-
- void *s_fs_info;
-
- u32 s_time_gran;
-
- time64_t s_time_min;
- time64_t s_time_max;
- #ifdef CONFIG_FSNOTIFY
- __u32 s_fsnotify_mask;
- struct fsnotify_mark_connector __rcu *s_fsnotify_marks;
- #endif
- char s_id[32];
- uuid_t s_uuid;
- unsigned int s_max_links;
- fmode_t s_mode;
-
- struct mutex s_vfs_rename_mutex;
-
- const char *s_subtype;
- const struct dentry_operations *s_d_op;
-
- int cleancache_poolid;
- struct shrinker s_shrink;
-
- atomic_long_t s_remove_count;
-
- atomic_long_t s_fsnotify_connectors;
-
- int s_readonly_remount;
-
- errseq_t s_wb_err;
-
- struct workqueue_struct *s_dio_done_wq;
- struct hlist_head s_pins;
-
- struct user_namespace *s_user_ns;
-
- struct list_lru s_dentry_lru;
- struct list_lru s_inode_lru;
- struct rcu_head rcu;
- struct work_struct destroy_work;
- struct mutex s_sync_lock;
-
- int s_stack_depth;
-
- spinlock_t s_inode_list_lock ____cacheline_aligned_in_smp;
- struct list_head s_inodes;
- spinlock_t s_inode_wblist_lock;
- struct list_head s_inodes_wb;
- } __randomize_layout;
- static inline struct user_namespace *i_user_ns(const struct inode *inode)
- {
- return inode->i_sb->s_user_ns;
- }
- static inline uid_t i_uid_read(const struct inode *inode)
- {
- return from_kuid(i_user_ns(inode), inode->i_uid);
- }
- static inline gid_t i_gid_read(const struct inode *inode)
- {
- return from_kgid(i_user_ns(inode), inode->i_gid);
- }
- static inline void i_uid_write(struct inode *inode, uid_t uid)
- {
- inode->i_uid = make_kuid(i_user_ns(inode), uid);
- }
- static inline void i_gid_write(struct inode *inode, gid_t gid)
- {
- inode->i_gid = make_kgid(i_user_ns(inode), gid);
- }
- static inline kuid_t i_uid_into_mnt(struct user_namespace *mnt_userns,
- const struct inode *inode)
- {
- return AS_KUIDT(make_vfsuid(mnt_userns, i_user_ns(inode), inode->i_uid));
- }
- static inline vfsuid_t i_uid_into_vfsuid(struct user_namespace *mnt_userns,
- const struct inode *inode)
- {
- return make_vfsuid(mnt_userns, i_user_ns(inode), inode->i_uid);
- }
- static inline bool i_uid_needs_update(struct user_namespace *mnt_userns,
- const struct iattr *attr,
- const struct inode *inode)
- {
- return ((attr->ia_valid & ATTR_UID) &&
- !vfsuid_eq(attr->ia_vfsuid,
- i_uid_into_vfsuid(mnt_userns, inode)));
- }
- static inline void i_uid_update(struct user_namespace *mnt_userns,
- const struct iattr *attr,
- struct inode *inode)
- {
- if (attr->ia_valid & ATTR_UID)
- inode->i_uid = from_vfsuid(mnt_userns, i_user_ns(inode),
- attr->ia_vfsuid);
- }
- static inline kgid_t i_gid_into_mnt(struct user_namespace *mnt_userns,
- const struct inode *inode)
- {
- return AS_KGIDT(make_vfsgid(mnt_userns, i_user_ns(inode), inode->i_gid));
- }
- static inline vfsgid_t i_gid_into_vfsgid(struct user_namespace *mnt_userns,
- const struct inode *inode)
- {
- return make_vfsgid(mnt_userns, i_user_ns(inode), inode->i_gid);
- }
- static inline bool i_gid_needs_update(struct user_namespace *mnt_userns,
- const struct iattr *attr,
- const struct inode *inode)
- {
- return ((attr->ia_valid & ATTR_GID) &&
- !vfsgid_eq(attr->ia_vfsgid,
- i_gid_into_vfsgid(mnt_userns, inode)));
- }
- static inline void i_gid_update(struct user_namespace *mnt_userns,
- const struct iattr *attr,
- struct inode *inode)
- {
- if (attr->ia_valid & ATTR_GID)
- inode->i_gid = from_vfsgid(mnt_userns, i_user_ns(inode),
- attr->ia_vfsgid);
- }
- static inline void inode_fsuid_set(struct inode *inode,
- struct user_namespace *mnt_userns)
- {
- inode->i_uid = mapped_fsuid(mnt_userns, i_user_ns(inode));
- }
- static inline void inode_fsgid_set(struct inode *inode,
- struct user_namespace *mnt_userns)
- {
- inode->i_gid = mapped_fsgid(mnt_userns, i_user_ns(inode));
- }
- static inline bool fsuidgid_has_mapping(struct super_block *sb,
- struct user_namespace *mnt_userns)
- {
- struct user_namespace *fs_userns = sb->s_user_ns;
- kuid_t kuid;
- kgid_t kgid;
- kuid = mapped_fsuid(mnt_userns, fs_userns);
- if (!uid_valid(kuid))
- return false;
- kgid = mapped_fsgid(mnt_userns, fs_userns);
- if (!gid_valid(kgid))
- return false;
- return kuid_has_mapping(fs_userns, kuid) &&
- kgid_has_mapping(fs_userns, kgid);
- }
- struct timespec64 current_time(struct inode *inode);
- struct timespec64 inode_set_ctime_current(struct inode *inode);
- static inline struct timespec64 inode_get_ctime(const struct inode *inode)
- {
- return inode->i_ctime;
- }
- static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode,
- struct timespec64 ts)
- {
- inode->i_ctime = ts;
- return ts;
- }
- static inline struct timespec64 inode_set_ctime(struct inode *inode,
- time64_t sec, long nsec)
- {
- struct timespec64 ts = { .tv_sec = sec,
- .tv_nsec = nsec };
- return inode_set_ctime_to_ts(inode, ts);
- }
- static inline void __sb_end_write(struct super_block *sb, int level)
- {
- percpu_up_read(sb->s_writers.rw_sem + level-1);
- }
- static inline void __sb_start_write(struct super_block *sb, int level)
- {
- percpu_down_read(sb->s_writers.rw_sem + level - 1);
- }
- static inline bool __sb_start_write_trylock(struct super_block *sb, int level)
- {
- return percpu_down_read_trylock(sb->s_writers.rw_sem + level - 1);
- }
- #define __sb_writers_acquired(sb, lev) \
- percpu_rwsem_acquire(&(sb)->s_writers.rw_sem[(lev)-1], 1, _THIS_IP_)
- #define __sb_writers_release(sb, lev) \
- percpu_rwsem_release(&(sb)->s_writers.rw_sem[(lev)-1], 1, _THIS_IP_)
- static inline bool sb_write_started(const struct super_block *sb)
- {
- return lockdep_is_held_type(sb->s_writers.rw_sem + SB_FREEZE_WRITE - 1, 1);
- }
- static inline void sb_end_write(struct super_block *sb)
- {
- __sb_end_write(sb, SB_FREEZE_WRITE);
- }
- static inline void sb_end_pagefault(struct super_block *sb)
- {
- __sb_end_write(sb, SB_FREEZE_PAGEFAULT);
- }
- static inline void sb_end_intwrite(struct super_block *sb)
- {
- __sb_end_write(sb, SB_FREEZE_FS);
- }
- static inline void sb_start_write(struct super_block *sb)
- {
- __sb_start_write(sb, SB_FREEZE_WRITE);
- }
- static inline bool sb_start_write_trylock(struct super_block *sb)
- {
- return __sb_start_write_trylock(sb, SB_FREEZE_WRITE);
- }
- static inline void sb_start_pagefault(struct super_block *sb)
- {
- __sb_start_write(sb, SB_FREEZE_PAGEFAULT);
- }
- static inline void sb_start_intwrite(struct super_block *sb)
- {
- __sb_start_write(sb, SB_FREEZE_FS);
- }
- static inline bool sb_start_intwrite_trylock(struct super_block *sb)
- {
- return __sb_start_write_trylock(sb, SB_FREEZE_FS);
- }
- bool inode_owner_or_capable(struct user_namespace *mnt_userns,
- const struct inode *inode);
- int vfs_create(struct user_namespace *, struct inode *,
- struct dentry *, umode_t, bool);
- int vfs_mkdir(struct user_namespace *, struct inode *,
- struct dentry *, umode_t);
- int vfs_mknod(struct user_namespace *, struct inode *, struct dentry *,
- umode_t, dev_t);
- int vfs_symlink(struct user_namespace *, struct inode *,
- struct dentry *, const char *);
- int vfs_link(struct dentry *, struct user_namespace *, struct inode *,
- struct dentry *, struct inode **);
- int vfs_rmdir(struct user_namespace *, struct inode *, struct dentry *);
- int vfs_unlink(struct user_namespace *, struct inode *, struct dentry *,
- struct inode **);
- struct renamedata {
- struct user_namespace *old_mnt_userns;
- struct inode *old_dir;
- struct dentry *old_dentry;
- struct user_namespace *new_mnt_userns;
- struct inode *new_dir;
- struct dentry *new_dentry;
- struct inode **delegated_inode;
- unsigned int flags;
- } __randomize_layout;
- int vfs_rename(struct renamedata *);
- static inline int vfs_whiteout(struct user_namespace *mnt_userns,
- struct inode *dir, struct dentry *dentry)
- {
- return vfs_mknod(mnt_userns, dir, dentry, S_IFCHR | WHITEOUT_MODE,
- WHITEOUT_DEV);
- }
- struct file *vfs_tmpfile_open(struct user_namespace *mnt_userns,
- const struct path *parentpath,
- umode_t mode, int open_flag, const struct cred *cred);
- int vfs_mkobj(struct dentry *, umode_t,
- int (*f)(struct dentry *, umode_t, void *),
- void *);
- int vfs_fchown(struct file *file, uid_t user, gid_t group);
- int vfs_fchmod(struct file *file, umode_t mode);
- int vfs_utimes(const struct path *path, struct timespec64 *times);
- extern long vfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
- #ifdef CONFIG_COMPAT
- extern long compat_ptr_ioctl(struct file *file, unsigned int cmd,
- unsigned long arg);
- #else
- #define compat_ptr_ioctl NULL
- #endif
- void inode_init_owner(struct user_namespace *mnt_userns, struct inode *inode,
- const struct inode *dir, umode_t mode);
- extern bool may_open_dev(const struct path *path);
- umode_t mode_strip_sgid(struct user_namespace *mnt_userns,
- const struct inode *dir, umode_t mode);
- struct dir_context;
- typedef bool (*filldir_t)(struct dir_context *, const char *, int, loff_t, u64,
- unsigned);
- struct dir_context {
- filldir_t actor;
- loff_t pos;
- };
- #define NOMMU_MAP_COPY 0x00000001
- #define NOMMU_MAP_DIRECT 0x00000008
- #define NOMMU_MAP_READ VM_MAYREAD
- #define NOMMU_MAP_WRITE VM_MAYWRITE
- #define NOMMU_MAP_EXEC VM_MAYEXEC
- #define NOMMU_VMFLAGS \
- (NOMMU_MAP_READ | NOMMU_MAP_WRITE | NOMMU_MAP_EXEC)
- #define REMAP_FILE_DEDUP (1 << 0)
- #define REMAP_FILE_CAN_SHORTEN (1 << 1)
- #define REMAP_FILE_ADVISORY (REMAP_FILE_CAN_SHORTEN)
- #define COPY_FILE_SPLICE (1 << 0)
- struct iov_iter;
- struct io_uring_cmd;
- struct file_operations {
- struct module *owner;
- loff_t (*llseek) (struct file *, loff_t, int);
- ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
- ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
- ssize_t (*read_iter) (struct kiocb *, struct iov_iter *);
- ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
- int (*iopoll)(struct kiocb *kiocb, struct io_comp_batch *,
- unsigned int flags);
- int (*iterate) (struct file *, struct dir_context *);
- int (*iterate_shared) (struct file *, struct dir_context *);
- __poll_t (*poll) (struct file *, struct poll_table_struct *);
- long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
- long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
- int (*mmap) (struct file *, struct vm_area_struct *);
- unsigned long mmap_supported_flags;
- int (*open) (struct inode *, struct file *);
- int (*flush) (struct file *, fl_owner_t id);
- int (*release) (struct inode *, struct file *);
- int (*fsync) (struct file *, loff_t, loff_t, int datasync);
- int (*fasync) (int, struct file *, int);
- int (*lock) (struct file *, int, struct file_lock *);
- ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
- unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
- int (*check_flags)(int);
- int (*flock) (struct file *, int, struct file_lock *);
- ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);
- ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int);
- int (*setlease)(struct file *, long, struct file_lock **, void **);
- long (*fallocate)(struct file *file, int mode, loff_t offset,
- loff_t len);
- void (*show_fdinfo)(struct seq_file *m, struct file *f);
- #ifndef CONFIG_MMU
- unsigned (*mmap_capabilities)(struct file *);
- #endif
- ssize_t (*copy_file_range)(struct file *, loff_t, struct file *,
- loff_t, size_t, unsigned int);
- loff_t (*remap_file_range)(struct file *file_in, loff_t pos_in,
- struct file *file_out, loff_t pos_out,
- loff_t len, unsigned int remap_flags);
- int (*fadvise)(struct file *, loff_t, loff_t, int);
- int (*uring_cmd)(struct io_uring_cmd *ioucmd, unsigned int issue_flags);
- int (*uring_cmd_iopoll)(struct io_uring_cmd *, struct io_comp_batch *,
- unsigned int poll_flags);
- } __randomize_layout;
- struct inode_operations {
- struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
- const char * (*get_link) (struct dentry *, struct inode *, struct delayed_call *);
- int (*permission) (struct user_namespace *, struct inode *, int);
- struct posix_acl * (*get_acl)(struct inode *, int, bool);
- int (*readlink) (struct dentry *, char __user *,int);
- int (*create) (struct user_namespace *, struct inode *,struct dentry *,
- umode_t, bool);
- int (*link) (struct dentry *,struct inode *,struct dentry *);
- int (*unlink) (struct inode *,struct dentry *);
- int (*symlink) (struct user_namespace *, struct inode *,struct dentry *,
- const char *);
- int (*mkdir) (struct user_namespace *, struct inode *,struct dentry *,
- umode_t);
- int (*rmdir) (struct inode *,struct dentry *);
- int (*mknod) (struct user_namespace *, struct inode *,struct dentry *,
- umode_t,dev_t);
- int (*rename) (struct user_namespace *, struct inode *, struct dentry *,
- struct inode *, struct dentry *, unsigned int);
- int (*setattr) (struct user_namespace *, struct dentry *,
- struct iattr *);
- int (*getattr) (struct user_namespace *, const struct path *,
- struct kstat *, u32, unsigned int);
- ssize_t (*listxattr) (struct dentry *, char *, size_t);
- int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
- u64 len);
- int (*update_time)(struct inode *, struct timespec64 *, int);
- int (*atomic_open)(struct inode *, struct dentry *,
- struct file *, unsigned open_flag,
- umode_t create_mode);
- int (*tmpfile) (struct user_namespace *, struct inode *,
- struct file *, umode_t);
- int (*set_acl)(struct user_namespace *, struct inode *,
- struct posix_acl *, int);
- int (*fileattr_set)(struct user_namespace *mnt_userns,
- struct dentry *dentry, struct fileattr *fa);
- int (*fileattr_get)(struct dentry *dentry, struct fileattr *fa);
- } ____cacheline_aligned;
- static inline ssize_t call_read_iter(struct file *file, struct kiocb *kio,
- struct iov_iter *iter)
- {
- return file->f_op->read_iter(kio, iter);
- }
- static inline ssize_t call_write_iter(struct file *file, struct kiocb *kio,
- struct iov_iter *iter)
- {
- return file->f_op->write_iter(kio, iter);
- }
- static inline int call_mmap(struct file *file, struct vm_area_struct *vma)
- {
- return file->f_op->mmap(file, vma);
- }
- extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
- extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *);
- extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *,
- loff_t, size_t, unsigned int);
- extern ssize_t generic_copy_file_range(struct file *file_in, loff_t pos_in,
- struct file *file_out, loff_t pos_out,
- size_t len, unsigned int flags);
- int __generic_remap_file_range_prep(struct file *file_in, loff_t pos_in,
- struct file *file_out, loff_t pos_out,
- loff_t *len, unsigned int remap_flags,
- const struct iomap_ops *dax_read_ops);
- int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in,
- struct file *file_out, loff_t pos_out,
- loff_t *count, unsigned int remap_flags);
- extern loff_t do_clone_file_range(struct file *file_in, loff_t pos_in,
- struct file *file_out, loff_t pos_out,
- loff_t len, unsigned int remap_flags);
- extern loff_t vfs_clone_file_range(struct file *file_in, loff_t pos_in,
- struct file *file_out, loff_t pos_out,
- loff_t len, unsigned int remap_flags);
- extern int vfs_dedupe_file_range(struct file *file,
- struct file_dedupe_range *same);
- extern loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos,
- struct file *dst_file, loff_t dst_pos,
- loff_t len, unsigned int remap_flags);
- struct super_operations {
- struct inode *(*alloc_inode)(struct super_block *sb);
- void (*destroy_inode)(struct inode *);
- void (*free_inode)(struct inode *);
- void (*dirty_inode) (struct inode *, int flags);
- int (*write_inode) (struct inode *, struct writeback_control *wbc);
- int (*drop_inode) (struct inode *);
- void (*evict_inode) (struct inode *);
- void (*put_super) (struct super_block *);
- int (*sync_fs)(struct super_block *sb, int wait);
- int (*freeze_super) (struct super_block *);
- int (*freeze_fs) (struct super_block *);
- int (*thaw_super) (struct super_block *);
- int (*unfreeze_fs) (struct super_block *);
- int (*statfs) (struct dentry *, struct kstatfs *);
- int (*remount_fs) (struct super_block *, int *, char *);
- void (*umount_begin) (struct super_block *);
- int (*show_options)(struct seq_file *, struct dentry *);
- int (*show_devname)(struct seq_file *, struct dentry *);
- int (*show_path)(struct seq_file *, struct dentry *);
- int (*show_stats)(struct seq_file *, struct dentry *);
- #ifdef CONFIG_QUOTA
- ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t);
- ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t);
- struct dquot **(*get_dquots)(struct inode *);
- #endif
- long (*nr_cached_objects)(struct super_block *,
- struct shrink_control *);
- long (*free_cached_objects)(struct super_block *,
- struct shrink_control *);
- };
- #define S_SYNC (1 << 0)
- #define S_NOATIME (1 << 1)
- #define S_APPEND (1 << 2)
- #define S_IMMUTABLE (1 << 3)
- #define S_DEAD (1 << 4)
- #define S_NOQUOTA (1 << 5)
- #define S_DIRSYNC (1 << 6)
- #define S_NOCMTIME (1 << 7)
- #define S_SWAPFILE (1 << 8)
- #define S_PRIVATE (1 << 9)
- #define S_IMA (1 << 10)
- #define S_AUTOMOUNT (1 << 11)
- #define S_NOSEC (1 << 12)
- #ifdef CONFIG_FS_DAX
- #define S_DAX (1 << 13)
- #else
- #define S_DAX 0
- #endif
- #define S_ENCRYPTED (1 << 14)
- #define S_CASEFOLD (1 << 15)
- #define S_VERITY (1 << 16)
- #define S_KERNEL_FILE (1 << 17)
- #define __IS_FLG(inode, flg) ((inode)->i_sb->s_flags & (flg))
- static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags & SB_RDONLY; }
- #define IS_RDONLY(inode) sb_rdonly((inode)->i_sb)
- #define IS_SYNC(inode) (__IS_FLG(inode, SB_SYNCHRONOUS) || \
- ((inode)->i_flags & S_SYNC))
- #define IS_DIRSYNC(inode) (__IS_FLG(inode, SB_SYNCHRONOUS|SB_DIRSYNC) || \
- ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
- #define IS_MANDLOCK(inode) __IS_FLG(inode, SB_MANDLOCK)
- #define IS_NOATIME(inode) __IS_FLG(inode, SB_RDONLY|SB_NOATIME)
- #define IS_I_VERSION(inode) __IS_FLG(inode, SB_I_VERSION)
- #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
- #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
- #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
- #define IS_POSIXACL(inode) __IS_FLG(inode, SB_POSIXACL)
- #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
- #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
- #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
- #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
- #define IS_IMA(inode) ((inode)->i_flags & S_IMA)
- #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
- #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
- #define IS_DAX(inode) ((inode)->i_flags & S_DAX)
- #define IS_ENCRYPTED(inode) ((inode)->i_flags & S_ENCRYPTED)
- #define IS_CASEFOLDED(inode) ((inode)->i_flags & S_CASEFOLD)
- #define IS_VERITY(inode) ((inode)->i_flags & S_VERITY)
- #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \
- (inode)->i_rdev == WHITEOUT_DEV)
- static inline bool HAS_UNMAPPED_ID(struct user_namespace *mnt_userns,
- struct inode *inode)
- {
- return !vfsuid_valid(i_uid_into_vfsuid(mnt_userns, inode)) ||
- !vfsgid_valid(i_gid_into_vfsgid(mnt_userns, inode));
- }
- static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp)
- {
- *kiocb = (struct kiocb) {
- .ki_filp = filp,
- .ki_flags = filp->f_iocb_flags,
- .ki_ioprio = get_current_ioprio(),
- };
- }
- static inline void kiocb_clone(struct kiocb *kiocb, struct kiocb *kiocb_src,
- struct file *filp)
- {
- *kiocb = (struct kiocb) {
- .ki_filp = filp,
- .ki_flags = kiocb_src->ki_flags,
- .ki_ioprio = kiocb_src->ki_ioprio,
- .ki_pos = kiocb_src->ki_pos,
- };
- }
- #define I_DIRTY_SYNC (1 << 0)
- #define I_DIRTY_DATASYNC (1 << 1)
- #define I_DIRTY_PAGES (1 << 2)
- #define __I_NEW 3
- #define I_NEW (1 << __I_NEW)
- #define I_WILL_FREE (1 << 4)
- #define I_FREEING (1 << 5)
- #define I_CLEAR (1 << 6)
- #define __I_SYNC 7
- #define I_SYNC (1 << __I_SYNC)
- #define I_REFERENCED (1 << 8)
- #define __I_DIO_WAKEUP 9
- #define I_DIO_WAKEUP (1 << __I_DIO_WAKEUP)
- #define I_LINKABLE (1 << 10)
- #define I_DIRTY_TIME (1 << 11)
- #define I_WB_SWITCH (1 << 13)
- #define I_OVL_INUSE (1 << 14)
- #define I_CREATING (1 << 15)
- #define I_DONTCACHE (1 << 16)
- #define I_SYNC_QUEUED (1 << 17)
- #define I_PINNING_FSCACHE_WB (1 << 18)
- #define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC)
- #define I_DIRTY (I_DIRTY_INODE | I_DIRTY_PAGES)
- #define I_DIRTY_ALL (I_DIRTY | I_DIRTY_TIME)
- extern void __mark_inode_dirty(struct inode *, int);
- static inline void mark_inode_dirty(struct inode *inode)
- {
- __mark_inode_dirty(inode, I_DIRTY);
- }
- static inline void mark_inode_dirty_sync(struct inode *inode)
- {
- __mark_inode_dirty(inode, I_DIRTY_SYNC);
- }
- static inline bool inode_is_dirtytime_only(struct inode *inode)
- {
- return (inode->i_state & (I_DIRTY_TIME | I_NEW |
- I_FREEING | I_WILL_FREE)) == I_DIRTY_TIME;
- }
- extern void inc_nlink(struct inode *inode);
- extern void drop_nlink(struct inode *inode);
- extern void clear_nlink(struct inode *inode);
- extern void set_nlink(struct inode *inode, unsigned int nlink);
- static inline void inode_inc_link_count(struct inode *inode)
- {
- inc_nlink(inode);
- mark_inode_dirty(inode);
- }
- static inline void inode_dec_link_count(struct inode *inode)
- {
- drop_nlink(inode);
- mark_inode_dirty(inode);
- }
- enum file_time_flags {
- S_ATIME = 1,
- S_MTIME = 2,
- S_CTIME = 4,
- S_VERSION = 8,
- };
- extern bool atime_needs_update(const struct path *, struct inode *);
- extern void touch_atime(const struct path *);
- int inode_update_time(struct inode *inode, struct timespec64 *time, int flags);
- static inline void file_accessed(struct file *file)
- {
- if (!(file->f_flags & O_NOATIME))
- touch_atime(&file->f_path);
- }
- extern int file_modified(struct file *file);
- int kiocb_modified(struct kiocb *iocb);
- int sync_inode_metadata(struct inode *inode, int wait);
- struct file_system_type {
- const char *name;
- int fs_flags;
- #define FS_REQUIRES_DEV 1
- #define FS_BINARY_MOUNTDATA 2
- #define FS_HAS_SUBTYPE 4
- #define FS_USERNS_MOUNT 8
- #define FS_DISALLOW_NOTIFY_PERM 16
- #define FS_ALLOW_IDMAP 32
- #define FS_RENAME_DOES_D_MOVE 32768
- int (*init_fs_context)(struct fs_context *);
- const struct fs_parameter_spec *parameters;
- struct dentry *(*mount) (struct file_system_type *, int,
- const char *, void *);
- void (*kill_sb) (struct super_block *);
- struct module *owner;
- struct file_system_type * next;
- struct hlist_head fs_supers;
- struct lock_class_key s_lock_key;
- struct lock_class_key s_umount_key;
- struct lock_class_key s_vfs_rename_key;
- struct lock_class_key s_writers_key[SB_FREEZE_LEVELS];
- struct lock_class_key i_lock_key;
- struct lock_class_key i_mutex_key;
- struct lock_class_key invalidate_lock_key;
- struct lock_class_key i_mutex_dir_key;
- };
- #define MODULE_ALIAS_FS(NAME) MODULE_ALIAS("fs-" NAME)
- extern struct dentry *mount_bdev(struct file_system_type *fs_type,
- int flags, const char *dev_name, void *data,
- int (*fill_super)(struct super_block *, void *, int));
- extern struct dentry *mount_single(struct file_system_type *fs_type,
- int flags, void *data,
- int (*fill_super)(struct super_block *, void *, int));
- extern struct dentry *mount_nodev(struct file_system_type *fs_type,
- int flags, void *data,
- int (*fill_super)(struct super_block *, void *, int));
- extern struct dentry *mount_subtree(struct vfsmount *mnt, const char *path);
- void retire_super(struct super_block *sb);
- void generic_shutdown_super(struct super_block *sb);
- void kill_block_super(struct super_block *sb);
- void kill_anon_super(struct super_block *sb);
- void kill_litter_super(struct super_block *sb);
- void deactivate_super(struct super_block *sb);
- void deactivate_locked_super(struct super_block *sb);
- int set_anon_super(struct super_block *s, void *data);
- int set_anon_super_fc(struct super_block *s, struct fs_context *fc);
- int get_anon_bdev(dev_t *);
- void free_anon_bdev(dev_t);
- struct super_block *sget_fc(struct fs_context *fc,
- int (*test)(struct super_block *, struct fs_context *),
- int (*set)(struct super_block *, struct fs_context *));
- struct super_block *sget(struct file_system_type *type,
- int (*test)(struct super_block *,void *),
- int (*set)(struct super_block *,void *),
- int flags, void *data);
- #define fops_get(fops) \
- (((fops) && try_module_get((fops)->owner) ? (fops) : NULL))
- #define fops_put(fops) \
- do { if (fops) module_put((fops)->owner); } while(0)
- #define replace_fops(f, fops) \
- do { \
- struct file *__file = (f); \
- fops_put(__file->f_op); \
- BUG_ON(!(__file->f_op = (fops))); \
- } while(0)
- extern int register_filesystem(struct file_system_type *);
- extern int unregister_filesystem(struct file_system_type *);
- extern int vfs_statfs(const struct path *, struct kstatfs *);
- extern int user_statfs(const char __user *, struct kstatfs *);
- extern int fd_statfs(int, struct kstatfs *);
- extern int freeze_super(struct super_block *super);
- extern int thaw_super(struct super_block *super);
- extern __printf(2, 3)
- int super_setup_bdi_name(struct super_block *sb, char *fmt, ...);
- extern int super_setup_bdi(struct super_block *sb);
- extern int current_umask(void);
- extern void ihold(struct inode * inode);
- extern void iput(struct inode *);
- extern int generic_update_time(struct inode *, struct timespec64 *, int);
- extern struct kobject *fs_kobj;
- #define MAX_RW_COUNT (INT_MAX & PAGE_MASK)
- #ifdef CONFIG_FILE_LOCKING
- static inline int break_lease(struct inode *inode, unsigned int mode)
- {
-
- smp_mb();
- if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease))
- return __break_lease(inode, mode, FL_LEASE);
- return 0;
- }
- static inline int break_deleg(struct inode *inode, unsigned int mode)
- {
-
- smp_mb();
- if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease))
- return __break_lease(inode, mode, FL_DELEG);
- return 0;
- }
- static inline int try_break_deleg(struct inode *inode, struct inode **delegated_inode)
- {
- int ret;
- ret = break_deleg(inode, O_WRONLY|O_NONBLOCK);
- if (ret == -EWOULDBLOCK && delegated_inode) {
- *delegated_inode = inode;
- ihold(inode);
- }
- return ret;
- }
- static inline int break_deleg_wait(struct inode **delegated_inode)
- {
- int ret;
- ret = break_deleg(*delegated_inode, O_WRONLY);
- iput(*delegated_inode);
- *delegated_inode = NULL;
- return ret;
- }
- static inline int break_layout(struct inode *inode, bool wait)
- {
- smp_mb();
- if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease))
- return __break_lease(inode,
- wait ? O_WRONLY : O_WRONLY | O_NONBLOCK,
- FL_LAYOUT);
- return 0;
- }
- #else
- static inline int break_lease(struct inode *inode, unsigned int mode)
- {
- return 0;
- }
- static inline int break_deleg(struct inode *inode, unsigned int mode)
- {
- return 0;
- }
- static inline int try_break_deleg(struct inode *inode, struct inode **delegated_inode)
- {
- return 0;
- }
- static inline int break_deleg_wait(struct inode **delegated_inode)
- {
- BUG();
- return 0;
- }
- static inline int break_layout(struct inode *inode, bool wait)
- {
- return 0;
- }
- #endif
- struct audit_names;
- struct filename {
- const char *name;
- const __user char *uptr;
- int refcnt;
- struct audit_names *aname;
- const char iname[];
- };
- static_assert(offsetof(struct filename, iname) % sizeof(long) == 0);
- static inline struct user_namespace *file_mnt_user_ns(struct file *file)
- {
- return mnt_user_ns(file->f_path.mnt);
- }
- static inline bool is_idmapped_mnt(const struct vfsmount *mnt)
- {
- return mnt_user_ns(mnt) != mnt->mnt_sb->s_user_ns;
- }
- extern long vfs_truncate(const struct path *, loff_t);
- int do_truncate(struct user_namespace *, struct dentry *, loff_t start,
- unsigned int time_attrs, struct file *filp);
- extern int vfs_fallocate(struct file *file, int mode, loff_t offset,
- loff_t len);
- extern long do_sys_open(int dfd, const char __user *filename, int flags,
- umode_t mode);
- extern struct file *file_open_name(struct filename *, int, umode_t);
- extern struct file *filp_open(const char *, int, umode_t);
- extern struct file *filp_open_block(const char *, int, umode_t);
- extern struct file *file_open_root(const struct path *,
- const char *, int, umode_t);
- static inline struct file *file_open_root_mnt(struct vfsmount *mnt,
- const char *name, int flags, umode_t mode)
- {
- return file_open_root(&(struct path){.mnt = mnt, .dentry = mnt->mnt_root},
- name, flags, mode);
- }
- extern struct file * dentry_open(const struct path *, int, const struct cred *);
- extern struct file *dentry_create(const struct path *path, int flags,
- umode_t mode, const struct cred *cred);
- extern struct file * open_with_fake_path(const struct path *, int,
- struct inode*, const struct cred *);
- static inline struct file *file_clone_open(struct file *file)
- {
- return dentry_open(&file->f_path, file->f_flags, file->f_cred);
- }
- extern int filp_close(struct file *, fl_owner_t id);
- extern struct filename *getname_flags(const char __user *, int, int *);
- extern struct filename *getname_uflags(const char __user *, int);
- extern struct filename *getname(const char __user *);
- extern struct filename *getname_kernel(const char *);
- extern void putname(struct filename *name);
- extern int finish_open(struct file *file, struct dentry *dentry,
- int (*open)(struct inode *, struct file *));
- extern int finish_no_open(struct file *file, struct dentry *dentry);
- static inline int finish_open_simple(struct file *file, int error)
- {
- if (error)
- return error;
- return finish_open(file, file->f_path.dentry, NULL);
- }
- extern void __init vfs_caches_init_early(void);
- extern void __init vfs_caches_init(void);
- extern struct kmem_cache *names_cachep;
- #define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL)
- #define __putname(name) kmem_cache_free(names_cachep, (void *)(name))
- extern struct super_block *blockdev_superblock;
- static inline bool sb_is_blkdev_sb(struct super_block *sb)
- {
- return IS_ENABLED(CONFIG_BLOCK) && sb == blockdev_superblock;
- }
- void emergency_thaw_all(void);
- extern int sync_filesystem(struct super_block *);
- extern const struct file_operations def_blk_fops;
- extern const struct file_operations def_chr_fops;
- #define CHRDEV_MAJOR_MAX 512
- #define CHRDEV_MAJOR_DYN_END 234
- #define CHRDEV_MAJOR_DYN_EXT_START 511
- #define CHRDEV_MAJOR_DYN_EXT_END 384
- extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *);
- extern int register_chrdev_region(dev_t, unsigned, const char *);
- extern int __register_chrdev(unsigned int major, unsigned int baseminor,
- unsigned int count, const char *name,
- const struct file_operations *fops);
- extern void __unregister_chrdev(unsigned int major, unsigned int baseminor,
- unsigned int count, const char *name);
- extern void unregister_chrdev_region(dev_t, unsigned);
- extern void chrdev_show(struct seq_file *,off_t);
- static inline int register_chrdev(unsigned int major, const char *name,
- const struct file_operations *fops)
- {
- return __register_chrdev(major, 0, 256, name, fops);
- }
- static inline void unregister_chrdev(unsigned int major, const char *name)
- {
- __unregister_chrdev(major, 0, 256, name);
- }
- extern void init_special_inode(struct inode *, umode_t, dev_t);
- extern void make_bad_inode(struct inode *);
- extern bool is_bad_inode(struct inode *);
- extern int __must_check file_fdatawait_range(struct file *file, loff_t lstart,
- loff_t lend);
- extern int __must_check file_check_and_advance_wb_err(struct file *file);
- extern int __must_check file_write_and_wait_range(struct file *file,
- loff_t start, loff_t end);
- static inline int file_write_and_wait(struct file *file)
- {
- return file_write_and_wait_range(file, 0, LLONG_MAX);
- }
- extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end,
- int datasync);
- extern int vfs_fsync(struct file *file, int datasync);
- extern int sync_file_range(struct file *file, loff_t offset, loff_t nbytes,
- unsigned int flags);
- static inline bool iocb_is_dsync(const struct kiocb *iocb)
- {
- return (iocb->ki_flags & IOCB_DSYNC) ||
- IS_SYNC(iocb->ki_filp->f_mapping->host);
- }
- static inline ssize_t generic_write_sync(struct kiocb *iocb, ssize_t count)
- {
- if (iocb_is_dsync(iocb)) {
- int ret = vfs_fsync_range(iocb->ki_filp,
- iocb->ki_pos - count, iocb->ki_pos - 1,
- (iocb->ki_flags & IOCB_SYNC) ? 0 : 1);
- if (ret)
- return ret;
- }
- return count;
- }
- extern void emergency_sync(void);
- extern void emergency_remount(void);
- #ifdef CONFIG_BLOCK
- extern int bmap(struct inode *inode, sector_t *block);
- #else
- static inline int bmap(struct inode *inode, sector_t *block)
- {
- return -EINVAL;
- }
- #endif
- int notify_change(struct user_namespace *, struct dentry *,
- struct iattr *, struct inode **);
- int inode_permission(struct user_namespace *, struct inode *, int);
- int generic_permission(struct user_namespace *, struct inode *, int);
- static inline int file_permission(struct file *file, int mask)
- {
- return inode_permission(file_mnt_user_ns(file),
- file_inode(file), mask);
- }
- static inline int path_permission(const struct path *path, int mask)
- {
- return inode_permission(mnt_user_ns(path->mnt),
- d_inode(path->dentry), mask);
- }
- int __check_sticky(struct user_namespace *mnt_userns, struct inode *dir,
- struct inode *inode);
- static inline bool execute_ok(struct inode *inode)
- {
- return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode);
- }
- static inline bool inode_wrong_type(const struct inode *inode, umode_t mode)
- {
- return (inode->i_mode ^ mode) & S_IFMT;
- }
- static inline void file_start_write(struct file *file)
- {
- if (!S_ISREG(file_inode(file)->i_mode))
- return;
- sb_start_write(file_inode(file)->i_sb);
- }
- static inline bool file_start_write_trylock(struct file *file)
- {
- if (!S_ISREG(file_inode(file)->i_mode))
- return true;
- return sb_start_write_trylock(file_inode(file)->i_sb);
- }
- static inline void file_end_write(struct file *file)
- {
- if (!S_ISREG(file_inode(file)->i_mode))
- return;
- __sb_end_write(file_inode(file)->i_sb, SB_FREEZE_WRITE);
- }
- static inline int get_write_access(struct inode *inode)
- {
- return atomic_inc_unless_negative(&inode->i_writecount) ? 0 : -ETXTBSY;
- }
- static inline int deny_write_access(struct file *file)
- {
- struct inode *inode = file_inode(file);
- return atomic_dec_unless_positive(&inode->i_writecount) ? 0 : -ETXTBSY;
- }
- static inline void put_write_access(struct inode * inode)
- {
- atomic_dec(&inode->i_writecount);
- }
- static inline void allow_write_access(struct file *file)
- {
- if (file)
- atomic_inc(&file_inode(file)->i_writecount);
- }
- static inline bool inode_is_open_for_write(const struct inode *inode)
- {
- return atomic_read(&inode->i_writecount) > 0;
- }
- #if defined(CONFIG_IMA) || defined(CONFIG_FILE_LOCKING)
- static inline void i_readcount_dec(struct inode *inode)
- {
- BUG_ON(!atomic_read(&inode->i_readcount));
- atomic_dec(&inode->i_readcount);
- }
- static inline void i_readcount_inc(struct inode *inode)
- {
- atomic_inc(&inode->i_readcount);
- }
- #else
- static inline void i_readcount_dec(struct inode *inode)
- {
- return;
- }
- static inline void i_readcount_inc(struct inode *inode)
- {
- return;
- }
- #endif
- extern int do_pipe_flags(int *, int);
- extern ssize_t kernel_read(struct file *, void *, size_t, loff_t *);
- ssize_t __kernel_read(struct file *file, void *buf, size_t count, loff_t *pos);
- extern ssize_t kernel_write(struct file *, const void *, size_t, loff_t *);
- extern ssize_t __kernel_write(struct file *, const void *, size_t, loff_t *);
- extern struct file * open_exec(const char *);
-
- extern bool is_subdir(struct dentry *, struct dentry *);
- extern bool path_is_under(const struct path *, const struct path *);
- extern char *file_path(struct file *, char *, int);
- #include <linux/err.h>
- extern loff_t default_llseek(struct file *file, loff_t offset, int whence);
- extern loff_t vfs_llseek(struct file *file, loff_t offset, int whence);
- extern int inode_init_always(struct super_block *, struct inode *);
- extern void inode_init_once(struct inode *);
- extern void address_space_init_once(struct address_space *mapping);
- extern struct inode * igrab(struct inode *);
- extern ino_t iunique(struct super_block *, ino_t);
- extern int inode_needs_sync(struct inode *inode);
- extern int generic_delete_inode(struct inode *inode);
- static inline int generic_drop_inode(struct inode *inode)
- {
- return !inode->i_nlink || inode_unhashed(inode);
- }
- extern void d_mark_dontcache(struct inode *inode);
- extern struct inode *ilookup5_nowait(struct super_block *sb,
- unsigned long hashval, int (*test)(struct inode *, void *),
- void *data);
- extern struct inode *ilookup5(struct super_block *sb, unsigned long hashval,
- int (*test)(struct inode *, void *), void *data);
- extern struct inode *ilookup(struct super_block *sb, unsigned long ino);
- extern struct inode *inode_insert5(struct inode *inode, unsigned long hashval,
- int (*test)(struct inode *, void *),
- int (*set)(struct inode *, void *),
- void *data);
- extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *);
- extern struct inode * iget_locked(struct super_block *, unsigned long);
- extern struct inode *find_inode_nowait(struct super_block *,
- unsigned long,
- int (*match)(struct inode *,
- unsigned long, void *),
- void *data);
- extern struct inode *find_inode_rcu(struct super_block *, unsigned long,
- int (*)(struct inode *, void *), void *);
- extern struct inode *find_inode_by_ino_rcu(struct super_block *, unsigned long);
- extern int insert_inode_locked4(struct inode *, unsigned long, int (*test)(struct inode *, void *), void *);
- extern int insert_inode_locked(struct inode *);
- #ifdef CONFIG_DEBUG_LOCK_ALLOC
- extern void lockdep_annotate_inode_mutex_key(struct inode *inode);
- #else
- static inline void lockdep_annotate_inode_mutex_key(struct inode *inode) { };
- #endif
- extern void unlock_new_inode(struct inode *);
- extern void discard_new_inode(struct inode *);
- extern unsigned int get_next_ino(void);
- extern void evict_inodes(struct super_block *sb);
- void dump_mapping(const struct address_space *);
- static inline bool is_zero_ino(ino_t ino)
- {
- return (u32)ino == 0;
- }
- extern void __iget(struct inode * inode);
- extern void iget_failed(struct inode *);
- extern void clear_inode(struct inode *);
- extern void __destroy_inode(struct inode *);
- extern struct inode *new_inode_pseudo(struct super_block *sb);
- extern struct inode *new_inode(struct super_block *sb);
- extern void free_inode_nonrcu(struct inode *inode);
- extern int setattr_should_drop_suidgid(struct user_namespace *, struct inode *);
- extern int file_remove_privs(struct file *);
- int setattr_should_drop_sgid(struct user_namespace *mnt_userns,
- const struct inode *inode);
- static inline void *
- alloc_inode_sb(struct super_block *sb, struct kmem_cache *cache, gfp_t gfp)
- {
- return kmem_cache_alloc_lru(cache, &sb->s_inode_lru, gfp);
- }
- extern void __insert_inode_hash(struct inode *, unsigned long hashval);
- static inline void insert_inode_hash(struct inode *inode)
- {
- __insert_inode_hash(inode, inode->i_ino);
- }
- extern void __remove_inode_hash(struct inode *);
- static inline void remove_inode_hash(struct inode *inode)
- {
- if (!inode_unhashed(inode) && !hlist_fake(&inode->i_hash))
- __remove_inode_hash(inode);
- }
- extern void inode_sb_list_add(struct inode *inode);
- extern void inode_add_lru(struct inode *inode);
- extern int sb_set_blocksize(struct super_block *, int);
- extern int sb_min_blocksize(struct super_block *, int);
- extern int generic_file_mmap(struct file *, struct vm_area_struct *);
- extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);
- extern ssize_t generic_write_checks(struct kiocb *, struct iov_iter *);
- int generic_write_checks_count(struct kiocb *iocb, loff_t *count);
- extern int generic_write_check_limits(struct file *file, loff_t pos,
- loff_t *count);
- extern int generic_file_rw_checks(struct file *file_in, struct file *file_out);
- ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *to,
- ssize_t already_read);
- extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *);
- extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *);
- extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *);
- extern ssize_t generic_file_direct_write(struct kiocb *, struct iov_iter *);
- ssize_t generic_perform_write(struct kiocb *, struct iov_iter *);
- ssize_t vfs_iter_read(struct file *file, struct iov_iter *iter, loff_t *ppos,
- rwf_t flags);
- ssize_t vfs_iter_write(struct file *file, struct iov_iter *iter, loff_t *ppos,
- rwf_t flags);
- ssize_t vfs_iocb_iter_read(struct file *file, struct kiocb *iocb,
- struct iov_iter *iter);
- ssize_t vfs_iocb_iter_write(struct file *file, struct kiocb *iocb,
- struct iov_iter *iter);
- extern ssize_t generic_file_splice_read(struct file *, loff_t *,
- struct pipe_inode_info *, size_t, unsigned int);
- extern ssize_t iter_file_splice_write(struct pipe_inode_info *,
- struct file *, loff_t *, size_t, unsigned int);
- extern ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
- struct file *out, loff_t *, size_t len, unsigned int flags);
- extern long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
- loff_t *opos, size_t len, unsigned int flags);
- extern void
- file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);
- extern loff_t noop_llseek(struct file *file, loff_t offset, int whence);
- #define no_llseek NULL
- extern loff_t vfs_setpos(struct file *file, loff_t offset, loff_t maxsize);
- extern loff_t generic_file_llseek(struct file *file, loff_t offset, int whence);
- extern loff_t generic_file_llseek_size(struct file *file, loff_t offset,
- int whence, loff_t maxsize, loff_t eof);
- extern loff_t fixed_size_llseek(struct file *file, loff_t offset,
- int whence, loff_t size);
- extern loff_t no_seek_end_llseek_size(struct file *, loff_t, int, loff_t);
- extern loff_t no_seek_end_llseek(struct file *, loff_t, int);
- int rw_verify_area(int, struct file *, const loff_t *, size_t);
- extern int generic_file_open(struct inode * inode, struct file * filp);
- extern int nonseekable_open(struct inode * inode, struct file * filp);
- extern int stream_open(struct inode * inode, struct file * filp);
- #ifdef CONFIG_BLOCK
- typedef void (dio_submit_t)(struct bio *bio, struct inode *inode,
- loff_t file_offset);
- enum {
-
- DIO_LOCKING = 0x01,
-
- DIO_SKIP_HOLES = 0x02,
- };
- ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
- struct block_device *bdev, struct iov_iter *iter,
- get_block_t get_block,
- dio_iodone_t end_io, dio_submit_t submit_io,
- int flags);
- static inline ssize_t blockdev_direct_IO(struct kiocb *iocb,
- struct inode *inode,
- struct iov_iter *iter,
- get_block_t get_block)
- {
- return __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, iter,
- get_block, NULL, NULL, DIO_LOCKING | DIO_SKIP_HOLES);
- }
- #endif
- void inode_dio_wait(struct inode *inode);
- static inline void inode_dio_begin(struct inode *inode)
- {
- atomic_inc(&inode->i_dio_count);
- }
- static inline void inode_dio_end(struct inode *inode)
- {
- if (atomic_dec_and_test(&inode->i_dio_count))
- wake_up_bit(&inode->i_state, __I_DIO_WAKEUP);
- }
- void dio_warn_stale_pagecache(struct file *filp);
- extern void inode_set_flags(struct inode *inode, unsigned int flags,
- unsigned int mask);
- extern const struct file_operations generic_ro_fops;
- #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
- extern int readlink_copy(char __user *, int, const char *);
- extern int page_readlink(struct dentry *, char __user *, int);
- extern const char *page_get_link(struct dentry *, struct inode *,
- struct delayed_call *);
- extern void page_put_link(void *);
- extern int page_symlink(struct inode *inode, const char *symname, int len);
- extern const struct inode_operations page_symlink_inode_operations;
- extern void kfree_link(void *);
- void generic_fillattr(struct user_namespace *, struct inode *, struct kstat *);
- void generic_fill_statx_attr(struct inode *inode, struct kstat *stat);
- extern int vfs_getattr_nosec(const struct path *, struct kstat *, u32, unsigned int);
- extern int vfs_getattr(const struct path *, struct kstat *, u32, unsigned int);
- void __inode_add_bytes(struct inode *inode, loff_t bytes);
- void inode_add_bytes(struct inode *inode, loff_t bytes);
- void __inode_sub_bytes(struct inode *inode, loff_t bytes);
- void inode_sub_bytes(struct inode *inode, loff_t bytes);
- static inline loff_t __inode_get_bytes(struct inode *inode)
- {
- return (((loff_t)inode->i_blocks) << 9) + inode->i_bytes;
- }
- loff_t inode_get_bytes(struct inode *inode);
- void inode_set_bytes(struct inode *inode, loff_t bytes);
- const char *simple_get_link(struct dentry *, struct inode *,
- struct delayed_call *);
- extern const struct inode_operations simple_symlink_inode_operations;
- extern int iterate_dir(struct file *, struct dir_context *);
- int vfs_fstatat(int dfd, const char __user *filename, struct kstat *stat,
- int flags);
- int vfs_fstat(int fd, struct kstat *stat);
- static inline int vfs_stat(const char __user *filename, struct kstat *stat)
- {
- return vfs_fstatat(AT_FDCWD, filename, stat, 0);
- }
- static inline int vfs_lstat(const char __user *name, struct kstat *stat)
- {
- return vfs_fstatat(AT_FDCWD, name, stat, AT_SYMLINK_NOFOLLOW);
- }
- extern const char *vfs_get_link(struct dentry *, struct delayed_call *);
- extern int vfs_readlink(struct dentry *, char __user *, int);
- extern struct file_system_type *get_filesystem(struct file_system_type *fs);
- extern void put_filesystem(struct file_system_type *fs);
- extern struct file_system_type *get_fs_type(const char *name);
- extern struct super_block *get_super(struct block_device *);
- extern struct super_block *get_active_super(struct block_device *bdev);
- extern void drop_super(struct super_block *sb);
- extern void drop_super_exclusive(struct super_block *sb);
- extern void iterate_supers(void (*)(struct super_block *, void *), void *);
- extern void iterate_supers_type(struct file_system_type *,
- void (*)(struct super_block *, void *), void *);
- extern int dcache_dir_open(struct inode *, struct file *);
- extern int dcache_dir_close(struct inode *, struct file *);
- extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
- extern int dcache_readdir(struct file *, struct dir_context *);
- extern int simple_setattr(struct user_namespace *, struct dentry *,
- struct iattr *);
- extern int simple_getattr(struct user_namespace *, const struct path *,
- struct kstat *, u32, unsigned int);
- extern int simple_statfs(struct dentry *, struct kstatfs *);
- extern int simple_open(struct inode *inode, struct file *file);
- extern int simple_link(struct dentry *, struct inode *, struct dentry *);
- extern int simple_unlink(struct inode *, struct dentry *);
- extern int simple_rmdir(struct inode *, struct dentry *);
- extern int simple_rename_exchange(struct inode *old_dir, struct dentry *old_dentry,
- struct inode *new_dir, struct dentry *new_dentry);
- extern int simple_rename(struct user_namespace *, struct inode *,
- struct dentry *, struct inode *, struct dentry *,
- unsigned int);
- extern void simple_recursive_removal(struct dentry *,
- void (*callback)(struct dentry *));
- extern int noop_fsync(struct file *, loff_t, loff_t, int);
- extern ssize_t noop_direct_IO(struct kiocb *iocb, struct iov_iter *iter);
- extern int simple_empty(struct dentry *);
- extern int simple_write_begin(struct file *file, struct address_space *mapping,
- loff_t pos, unsigned len,
- struct page **pagep, void **fsdata);
- extern const struct address_space_operations ram_aops;
- extern int always_delete_dentry(const struct dentry *);
- extern struct inode *alloc_anon_inode(struct super_block *);
- extern int simple_nosetlease(struct file *, long, struct file_lock **, void **);
- extern const struct dentry_operations simple_dentry_operations;
- extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags);
- extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *);
- extern const struct file_operations simple_dir_operations;
- extern const struct inode_operations simple_dir_inode_operations;
- extern void make_empty_dir_inode(struct inode *inode);
- extern bool is_empty_dir_inode(struct inode *inode);
- struct tree_descr { const char *name; const struct file_operations *ops; int mode; };
- struct dentry *d_alloc_name(struct dentry *, const char *);
- extern int simple_fill_super(struct super_block *, unsigned long,
- const struct tree_descr *);
- extern int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count);
- extern void simple_release_fs(struct vfsmount **mount, int *count);
- extern ssize_t simple_read_from_buffer(void __user *to, size_t count,
- loff_t *ppos, const void *from, size_t available);
- extern ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos,
- const void __user *from, size_t count);
- extern int __generic_file_fsync(struct file *, loff_t, loff_t, int);
- extern int generic_file_fsync(struct file *, loff_t, loff_t, int);
- extern int generic_check_addressable(unsigned, u64);
- extern void generic_set_encrypted_ci_d_ops(struct dentry *dentry);
- int may_setattr(struct user_namespace *mnt_userns, struct inode *inode,
- unsigned int ia_valid);
- int setattr_prepare(struct user_namespace *, struct dentry *, struct iattr *);
- extern int inode_newsize_ok(const struct inode *, loff_t offset);
- void setattr_copy(struct user_namespace *, struct inode *inode,
- const struct iattr *attr);
- extern int file_update_time(struct file *file);
- static inline bool vma_is_dax(const struct vm_area_struct *vma)
- {
- return vma->vm_file && IS_DAX(vma->vm_file->f_mapping->host);
- }
- static inline bool vma_is_fsdax(struct vm_area_struct *vma)
- {
- struct inode *inode;
- if (!IS_ENABLED(CONFIG_FS_DAX) || !vma->vm_file)
- return false;
- if (!vma_is_dax(vma))
- return false;
- inode = file_inode(vma->vm_file);
- if (S_ISCHR(inode->i_mode))
- return false;
- return true;
- }
- static inline int iocb_flags(struct file *file)
- {
- int res = 0;
- if (file->f_flags & O_APPEND)
- res |= IOCB_APPEND;
- if (file->f_flags & O_DIRECT)
- res |= IOCB_DIRECT;
- if (file->f_flags & O_DSYNC)
- res |= IOCB_DSYNC;
- if (file->f_flags & __O_SYNC)
- res |= IOCB_SYNC;
- return res;
- }
- static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags)
- {
- int kiocb_flags = 0;
-
- BUILD_BUG_ON((__force int) RWF_SUPPORTED & IOCB_EVENTFD);
- if (!flags)
- return 0;
- if (unlikely(flags & ~RWF_SUPPORTED))
- return -EOPNOTSUPP;
- if (flags & RWF_NOWAIT) {
- if (!(ki->ki_filp->f_mode & FMODE_NOWAIT))
- return -EOPNOTSUPP;
- kiocb_flags |= IOCB_NOIO;
- }
- kiocb_flags |= (__force int) (flags & RWF_SUPPORTED);
- if (flags & RWF_SYNC)
- kiocb_flags |= IOCB_DSYNC;
- ki->ki_flags |= kiocb_flags;
- return 0;
- }
- static inline rwf_t iocb_to_rw_flags(int ifl, int iocb_mask)
- {
- return ifl & iocb_mask;
- }
- static inline ino_t parent_ino(struct dentry *dentry)
- {
- ino_t res;
-
- spin_lock(&dentry->d_lock);
- res = dentry->d_parent->d_inode->i_ino;
- spin_unlock(&dentry->d_lock);
- return res;
- }
- struct simple_transaction_argresp {
- ssize_t size;
- char data[];
- };
- #define SIMPLE_TRANSACTION_LIMIT (PAGE_SIZE - sizeof(struct simple_transaction_argresp))
- char *simple_transaction_get(struct file *file, const char __user *buf,
- size_t size);
- ssize_t simple_transaction_read(struct file *file, char __user *buf,
- size_t size, loff_t *pos);
- int simple_transaction_release(struct inode *inode, struct file *file);
- void simple_transaction_set(struct file *file, size_t n);
- #define DEFINE_SIMPLE_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, __is_signed) \
- static int __fops ## _open(struct inode *inode, struct file *file) \
- { \
- __simple_attr_check_format(__fmt, 0ull); \
- return simple_attr_open(inode, file, __get, __set, __fmt); \
- } \
- static const struct file_operations __fops = { \
- .owner = THIS_MODULE, \
- .open = __fops ## _open, \
- .release = simple_attr_release, \
- .read = simple_attr_read, \
- .write = (__is_signed) ? simple_attr_write_signed : simple_attr_write, \
- .llseek = generic_file_llseek, \
- }
- #define DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt) \
- DEFINE_SIMPLE_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, false)
- #define DEFINE_SIMPLE_ATTRIBUTE_SIGNED(__fops, __get, __set, __fmt) \
- DEFINE_SIMPLE_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, true)
- static inline __printf(1, 2)
- void __simple_attr_check_format(const char *fmt, ...)
- {
-
- }
- int simple_attr_open(struct inode *inode, struct file *file,
- int (*get)(void *, u64 *), int (*set)(void *, u64),
- const char *fmt);
- int simple_attr_release(struct inode *inode, struct file *file);
- ssize_t simple_attr_read(struct file *file, char __user *buf,
- size_t len, loff_t *ppos);
- ssize_t simple_attr_write(struct file *file, const char __user *buf,
- size_t len, loff_t *ppos);
- ssize_t simple_attr_write_signed(struct file *file, const char __user *buf,
- size_t len, loff_t *ppos);
- struct ctl_table;
- int __init list_bdev_fs_names(char *buf, size_t size);
- #define __FMODE_EXEC ((__force int) FMODE_EXEC)
- #define __FMODE_NONOTIFY ((__force int) FMODE_NONOTIFY)
- #define ACC_MODE(x) ("\004\002\006\006"[(x)&O_ACCMODE])
- #define OPEN_FMODE(flag) ((__force fmode_t)(((flag + 1) & O_ACCMODE) | \
- (flag & __FMODE_NONOTIFY)))
- static inline bool is_sxid(umode_t mode)
- {
- return mode & (S_ISUID | S_ISGID);
- }
- static inline int check_sticky(struct user_namespace *mnt_userns,
- struct inode *dir, struct inode *inode)
- {
- if (!(dir->i_mode & S_ISVTX))
- return 0;
- return __check_sticky(mnt_userns, dir, inode);
- }
- static inline void inode_has_no_xattr(struct inode *inode)
- {
- if (!is_sxid(inode->i_mode) && (inode->i_sb->s_flags & SB_NOSEC))
- inode->i_flags |= S_NOSEC;
- }
- static inline bool is_root_inode(struct inode *inode)
- {
- return inode == inode->i_sb->s_root->d_inode;
- }
- static inline bool dir_emit(struct dir_context *ctx,
- const char *name, int namelen,
- u64 ino, unsigned type)
- {
- return ctx->actor(ctx, name, namelen, ctx->pos, ino, type);
- }
- static inline bool dir_emit_dot(struct file *file, struct dir_context *ctx)
- {
- return ctx->actor(ctx, ".", 1, ctx->pos,
- file->f_path.dentry->d_inode->i_ino, DT_DIR);
- }
- static inline bool dir_emit_dotdot(struct file *file, struct dir_context *ctx)
- {
- return ctx->actor(ctx, "..", 2, ctx->pos,
- parent_ino(file->f_path.dentry), DT_DIR);
- }
- static inline bool dir_emit_dots(struct file *file, struct dir_context *ctx)
- {
- if (ctx->pos == 0) {
- if (!dir_emit_dot(file, ctx))
- return false;
- ctx->pos = 1;
- }
- if (ctx->pos == 1) {
- if (!dir_emit_dotdot(file, ctx))
- return false;
- ctx->pos = 2;
- }
- return true;
- }
- static inline bool dir_relax(struct inode *inode)
- {
- inode_unlock(inode);
- inode_lock(inode);
- return !IS_DEADDIR(inode);
- }
- static inline bool dir_relax_shared(struct inode *inode)
- {
- inode_unlock_shared(inode);
- inode_lock_shared(inode);
- return !IS_DEADDIR(inode);
- }
- extern bool path_noexec(const struct path *path);
- extern void inode_nohighmem(struct inode *inode);
- extern int vfs_fadvise(struct file *file, loff_t offset, loff_t len,
- int advice);
- extern int generic_fadvise(struct file *file, loff_t offset, loff_t len,
- int advice);
- #endif
|