Part 1 Os
Part 1 Os
ffles
deu
"_evesy
-Contoos
-UNIXhaspresent vi)fie "letclposSaod
idRnteall4
creatag
ussTag fsmaiotaoed fCleS
6hich-USertipasSWOTduidgidi
aSbe
directo
bome
Bydefault
diecto4
boe
multpleuSersas
qrouphasgoufp a
StUctuYe
data
tee
tdimectory [executoble uniquefd as.
ame
mkdir
System enit
Command
allfofoY
USeYi bieraschical usique
assignedqihasassiqnedoso
d
Secondary io the
parent
thece tuso directeries are cIeoted
pathname specT4ies hosto
partcular ftie fo
hierarchy
locat3on for fiie
patbname specified bytoo Gs
OAbSolute pathname
Spectfying Storting
Juserfavol toial. fova
(3Relatiye pathoame
6tat
kéyboord by defouit
(t7) t andcrd Olpdevice
nonrtor bydefout
Gi)tondasd erordevice
montor by defout
-Shellis-also-assoiot edcaithalheSe
deviCes
ction.
ofedire
we con-chonqe
devices
usingredirectioo
) Redirection f
poog*am.
OLP
Cusiog operator]
exi$ pud>filetxt
Outut
$ cat frletxt
aftesqivingthese Connand
Ro the f l e t x t
one Éleioto othey
OCopy
charch Cioo];
fiie2
fot fi le l, t2,fid, f2d;
fid:write fiie2,chFLdl;
e\se
pintfC fnor occunedto 'open fiue 2")
lose FTLe2)}.
els e
P f f eno 0ccued to open ffte 1");
Ctose( fite):
open canbe usedio tuoways
O to open exising fiie
to rreote andop n newfíle
Syntax:
întcreat pathname, mode)
Ceote
where to storethe petmissian
<reated file
. (Teat(l Ceates
andopens the new ffle
orikng
Lwheneverile fS Ceated in_0S itiS
3 type5 0f
pesmisSion
aliowS to See
the Content of the file
" allowS to oite the (n tent io fiie
)execute
-allowS to
execute the
.this pesmission is for
only executobe files
". for
eveyfi\e there oreà typeS of usexs
Oowner
qouP
others.
owneiS.the usex
whohos cKeated the i
uppe here S 4fie
omed fiie.zt
bere are d
5usersouped Into 2
q2(uuG)
then
ond. u ueoted
files.txt
otheKSu4,US
thers
the
pemiss.
oconerhas sights tochange
nly
OOSoftheffle
Home as6iqnment
ead every looth çh£ioter
Wiite a Cprogam to
Fie and sh dTsplay
used to
tnternaiy
characters Cre not
Stseam iepnesent
pesmiSsions4uses bit.
Ofor permssionotetee denied
pesmissTen. qaoted
1 for. StseamniS
Suppose pesmission
o5 2
Io|olo
inode
Koode_Contains the Characteisticsofftie
physícal device can ae ategorized inton.
multípe loqícol devtces
physiral devire
FS
loqical devi ces
Lo24 bytes
-biocks o6sigoed ha
store_file data are
Scatte red 9ot Sequen
tial
OSal0oys store the fle to temS af blocks
oSneeds to Ikeep toack on al the blocks
allocated to fle.
(jciatie)
primary
PoM perreenant
stuctre
Tabieof content 1s
present
Jarge
{ogdeS aiereusabie
Oumber of incdes and biocks ase dependent on
Super
în
. A fnformation abut fiie systern e present
these biork
.ex : hcw many toodes. has mnany fee inedes
and iSst of free 1ocdes
about data biocKs
stmtiarly
centaiing To fo.
5mall function
- +boot
preseot in t ohichiocater.
a Smoll Toutine.tG
on hosd disk.
the operading sytem
stortedRom functoo. ideotifies
hen System is
boet bioc k aod then routine Ts -itenHfied
the
which lecates0s
" all pzores5es have cnlq
<npde Iype
pezmission
hole ) Do dato.
e mpty area in f Tie ohere no data is present
declaed outGTde
loCal as deleared tnside tuna yeheye
to access l2eq th
then t diuides
we qet 2Gq by blocr charater
4hen al nteqer iuteton value hen
to that. Vele fadex fatable of ontent
and 4hat black (ontotns the dete 12.04 th
char acter
these block contaros lo4 bytes
Me boo to ind tho Se pasition use 126g.
lo24 4hat positian Contatns l2Gqth charocter
LY)i
lo-wR0NLYJ;
fde0pen (foeme, 0ADoNAr
3itefdhello", sl;
lseek(fd, 50,5EEKSUR);
write fd," orld'5):
aritten to the
-printf ". S0cessfull
poimany memosy in core memory
Q Ioode toble
.It ts present fn primavs memsry
I} rs used to Store tnode looded from
device
wheninode is iooded secunday
alL characteaistics
is loaded
ta jncde loaded from dísk is knoon tocore
disk faode )Se(ondany memoy
iocere fnode rimory mnemory
add1tional prepesties of focere inode
Oiaode numbex
. in tnode \ist 3nodes are stored Sequenialls
Do need of it
ioincore inode are_ \oaded as pe reqiYemeot
So esçentialy needed
refereoce Count
It tells that hoo mans pIOCSSes are
inede
using tha
Too pocesses can access faode at same tne
but cant madify Lupdate it
3) stotUS
for lack¯nq purpose
2FRle toble.
Tt contoíos folloeing properies.
Ormode Lopeiation
Io cohich mode user
Yemembex
opened the filet has to
tode st2e is aloays Powe of2
redoffset
oeeds tomafntoin offset tor Teadíng the
data from next chaIocter.
refeece count
atoial-do operafon
eod
le ffSet :o
opeiation:
(orite
Offset
taial. dot
4Hiakdat
tIEopenuSampledat AR DONLY)
f2 open ( tiol dat',oMRONLY)
P2
|Yef count3
teial offset: o
8Sespie
dat
opoite
offSeto
Race conditons
is possibilityot
.because of shoríng their.
inceDsistency prepealyllectíng
4.meanGeven if takíng care
0CCULS
theDs inconsístency
Atoriity iether both should beeXe Cuted
no one should be executed
there to avoid
are20ayS
O it pOuides appendfiaa (O.AePEND) KAceCondions
"open tle at append mode ifyou aloays
to cote data ct end of file
thee are 2additiona funcHons poulded bu ns
Opead and pite.
Opreod (omb of xead k lseet)
Syatax preod(fd,St,no_0f_char, offset)
what off Set you coat to
ead the dato
puonite (comb afoite R lseek)
Syntax poriteltd, St,
oofÁchor,offSet)
lhat ffset ou coint
to corite the data
atomicity
opetations
Can be
ensuredfrm the Se fetee
open ( Etxt,0-WRsNLYloCREAT)
IE file exist ît
tonrate the ile ad cae (an
isS all the dato
ale
E-0pen "ÁNtxt oRoNLY)
ope
dupfdi,lo)
tt 7l CiSe alre ady
uGe 4hen
fie and copies fdI into e
Opened
problenin (opying
dupc)retuins - l f there is
enoY
the fle or there is
outpt
&
stondard Input edirection
olP
>
dedirettong chongíng.
edtrecion
g t
Jess + K io Put
int minu int fdl, fa
2duptfdi;
printfc Text"};
letuxno,
sbuffes
buffe hs Same si2e os
thatof block
both iie o1e are io texms of
bLocks
choxactex
posses dotacharacte by chracter
pooblemn. Is that 0S does not
baiddisk tmme tsonsfen bufrer to.
for
HI
Ahese
all
àiately
O5 does not
wite buffe fmmedíately
buffer. pocessupdotes it or
tilltreuse the
Content
1eULed
fsnccfd)
fdato syoc Cfd).
syncc)ollthe buttes
hen any process Calls towríte
ohich are. nodífid Ore queued.up
staods_forStotus
"Gtat
he headexf1e StothContaosLthe stat) totype of
characteISticsof
It qives status (ie
Syntax :
st_Stsu c t i
Stat (pathname
stuct Stat
*Tups of iles fo
yNTX
eqular (NKMal data)
3directors files GCotains ee
nodes axe stuctuneoll
diIectories
nonleatCon be
leaf0de
3) pipe fIes ( Fles)for eg, folder
Ttrs used Tnte
pocess Communication)
anothes file
1Stato l Stonds for fak,
These are 2
Varíatíunsof stato
fstat(o
Syntax:
f5tatlfd, ¢ 5+.Stsuct)
Ghuct 6tat S:
Gtat ( Gompiedat"4 S);
*S-15fEG (S.stmode))
else
printf"Requla"),
prínt Not reglor")
deutce fiies
evesy deuice has on entySoto fiie system
..devices ffis aie stored in dev fie.
there are 2 tupes of device fiies.
block character
different)
Smbolfc \iok.C (nodes are
Syntax
Syrmlink ("existinq-fiie,oeofiie'):
aS writes the pathoame ot exsinq-file into o
(6)Socket fiies
these are used for Sendinq data to
machie ovex netork another
Ttfs usedfor
(omnunicatian betoeen mochines
ovethe fotenetLnetooxk.
Stat,h paouides certain
machos
TSLK () block
OS-1SREGO aular s_ISEIFO ( Lpipe
s-1SDIRL)(titetoy 5-1sLINKULSubolic ns
acter
bat
Homeassígnment
poss fiieaame caS Command
Line agunent
eck the fieype and dfsplay type of Aie
iocide<stdiohs
ioclude <StdR6h>
foclude<syslstath
0ludes fcotl-h>
else
fie tpe")j
priotfc" Uokogws
Absolute ) ( use Samplet
Relafve = (£mple-t xt
permisston is
pexmissisn is qiuen.
-a umasko O
to.O.Se+omas
it cIeatingfor
umaSk
Io..createoeH.cawn e. we.Can ons
permiustsostgComon these_functan Constants offiles ewner
kis permission
Son YetuinSe t (pathome,
acceGS
nude)
umask(pemiwantto
tohotssio.gnsiven).
set be
Tfhese
for +hese
mask
to f
qíve alJowG Ts
USe
oBhes.fwmasK
termioal etin yivenfunction
all tunc15oo
cífyspecimasfki.eudvalsiogpeue smis ion
Coo?4) s
pe to
UmasK(0) proqamandcon
9ups
miSsio0S. t
permission
USe CEate
Alenotq1venmeo0s tetusns (exçcte)
il
p.eimissiao
Specife
ie d. 1
al beSet not)
den' constants othe