📄 fcntl.2
字号:
10 B1336(F_RDLCK)S10 R1839(to)S1944(set)S2083(a)S2155(read)S2356(lock,)S10 B2581(F_WRLCK)S10 R3111(to)S3216(set)S3355(a)S3427(write)S3662(lock,)S3887(and)S10 B4058(F_UNLCK)S10 R4560(to)S4664(remove)S4992(a)S5063(lock.)S6480 V1080(Several)S1421(processes)S1845(may)S2056(have)S2284(a)S2368(read)S2581(lock)S2793(on)S2932(a)S3016(segment,)S3415(but)S3582(only)S3799(one)S3983(process)S4324(can)S4503(have)S4732(a)S4816(write)S5063(lock.)S6600 V10 B1080(L_whence)S10 R1555(tells)S1761(if)S1861(the)S10 B2022(l_start)S10 R2340(offset)S2608(must)S2841(be)S2974(interpreted)S3449(from)S3682(the)S3842(start)S4053(of)S4174(the)S4334(\256le)S4500(\()S10 B4534(SEEK_SET)S10 R5042(\),)S5138(the)S6720 V1080(current)S1393(\256le)S(position)323 1549 A1899(\()S10 B(SEEK_CUR)537 1933 A10 R2470(\),)S2556(or)S2667(the)S2817(end)S2989(of)S3100(the)S3250(\256le)S3406(\()S10 B3440(SEEK_END)S10 R3971(\).)S4082(This)S4288(is)S(analogous)407 4382 A4816(to)S4921(the)S5071(third)S6840 V1080(parameter)S1525(of)S10 B1650(lseek)S10 R1863(\(2\).)S2072(These)S10 B2354(SEEK_*)S10 R2763(symbols)S3138(are)S3303(declared)S3686(in)S3805(<unistd.h>.)S10 B4330(L_start)S10 R4689(is)S4796(the)S4959(starting)S6960 V1080(offset)S1338(of)S1450(the)S1601(segment)S1964(of)S2076(the)S2227(\256le.)S10 B2434(L_end)S10 R2736(is)S2831(the)S2982(length)S3261(of)S3373(the)S3524(segment.)S3937(If)S4033(zero)S4236(then)S4438(the)S4590(segment)S4954(extends)S7080 V(until)184 1080 A1296(end)S1473(of)S1589(\256le.)S10 B1800(L_pid)S10 R2089(is)S2187(the)S2341(process-id)S2786(of)S2901(the)S3055(process)S3388(currently)S3783(holding)S4120(a)S4196(lock)S4400(on)S4531(the)S4685(segment.)S5101(It)S5194(is)S7200 V1080(returned)S1441(by)S10 B(F_GETLK)469 1566 A10 R2035(.)S7368 V10 B1080(fcntl\()S10 I1311(fd)S10 B1397(,)S(F_GETLK,)494 1447 A1966(struct)S2244(\257ock)S2476(*)S10 I2526(lkp)S10 B2657(\))S7488 V10 R1440(Find)S1652(out)S1808(if)S1898(some)S2138(other)S2373(process)S2703(has)S2865(a)S2938(lock)S3139(on)S3267(a)S3341(segment)S3705(of)S3818(the)S3970(\256le)S4128(associated)S4571(by)S4700(\256le)S4858(descriptor)S7903 V720(Page)S941(1)S4455(September)S4911(13,)S(1996)200 5061 A8143 VEP%%Page: 2 2BP/slant 0 def/height 0 def480 V10 R720(FCNTL)S1048(\()S1090(2)S1148(\))S2696(Eighth)S(Edition)296 2989 A4799(FCNTL)S5127(\()S5169(2)S5227(\))S960 V10 I1440(fd)S10 R1544(that)S1720(overlaps)S2086(with)S2290(the)S2438(segment)S2798(described)S3209(by)S3334(the)S10 B3482(\257ock)S10 R3714(structure)S4092(pointed)S4418(to)S4521(by)S10 I4646(lkp)S10 R4777(.)S4852(If)S4945(the)S5093(seg-)S1080 V1440(ment)S1672(is)S1770(not)S1929(locked)S2228(then)S10 B2432(l_type)S10 R2726(is)S2824(set)S2967(to)S10 B3076(F_UNLCK)S10 R3552(.)S3633(Otherwise)S4079(an)S10 B4205(\257ock)S10 R4443(structure)S4827(is)S4925(returned)S1200 V(through)312 1440 A10 I1778(lkp)S10 R1927(that)S2104(describes)S2505(the)S2654(lock)S2853(held)S3052(by)S3178(the)S3326(other)S3558(process.)S10 B3935(L_start)S10 R4279(is)S4371(set)S4508(relative)S4836(to)S4939(the)S5087(start)S1320 V1440(of)S1549(the)S1697(\256le.)S1488 V10 B1080(fcntl\()S10 I1311(fd)S10 B1397(,)S(F_SETLK,)472 1447 A1944(struct)S2222(\257ock)S2454(*)S10 I2504(lkp)S10 B2635(\))S1608 V10 R1440(Register)S1805(a)S1879(lock)S2081(on)S2210(a)S2284(segment)S2648(of)S2761(the)S2913(\256le)S3072(associated)S3516(with)S3725(\256le)S3884(descriptor)S10 I4317(fd)S10 R4403(.)S4483(The)S4670(\256le)S4829(segment)S5194(is)S1728 V1440(described)S1861(by)S1996(the)S10 B2154(struct)S2442(\257ock)S10 R2684(pointed)S3020(to)S3133(by)S10 I3268(lkp)S10 R3399(.)S3484(This)S3698(call)S3879(returns)S4194(an)S4323(error)S4554(if)S4650(any)S4829(part)S5020(of)S5138(the)S1848 V1440(segment)S1800(is)S1892(already)S2214(locked.)S2016 V10 B1080(fcntl\()S10 I1311(fd)S10 B1397(,)S(F_SETLKW,)572 1447 A2044(struct)S2322(\257ock)S2554(*)S10 I2604(lkp)S10 B2735(\))S2136 V10 R1440(Register)S1805(a)S1879(lock)S2081(on)S2210(a)S2284(segment)S2648(of)S2761(the)S2913(\256le)S3072(associated)S3516(with)S3725(\256le)S3884(descriptor)S10 I4317(fd)S10 R4403(.)S4483(The)S4670(\256le)S4829(segment)S5194(is)S2256 V1440(described)S1863(by)S2000(the)S10 B2160(struct)S2450(\257ock)S10 R2693(pointed)S3030(to)S3144(by)S10 I3280(lkp)S10 R3411(.)S3497(This)S3712(call)S3894(blocks)S(waiting)302 4192 A4530(for)S4684(the)S4843(lock)S5052(to)S5166(be)S2376 V1440(released)S1796(if)S1883(any)S2053(part)S2235(of)S2344(the)S2492(segment)S2852(is)S2944(already)S3266(locked.)S2544 V10 B1080(fcntl\()S10 I1311(fd)S10 B1397(,)S1447(F_FREESP,)S1996(struct)S2274(\257ock)S2506(*)S10 I2556(lkp)S10 B2687(\))S2664 V10 R1440(Free)S1650(a)S1725(segment)S2090(of)S2204(disk)S(space)224 2401 A2655(occupied)S3048(by)S3178(the)S3331(\256le)S3490(associated)S3934(with)S4144(\256le)S4304(descriptor)S10 I4738(fd)S10 R4824(.)S4905(The)S5093(seg-)S2784 V1440(ment)S1673(is)S1772(described)S2190(by)S2322(the)S10 B2477(struct)S2762(\257ock)S10 R3001(pointed)S3334(to)S3443(by)S10 I3574(lkp)S10 R3705(.)S3786(The)S3974(\256le)S4134(is)S4232(truncated)S4638(in)S4747(length)S5029(to)S5138(the)S2904 V1440(byte)S(position)323 1648 A2006(indicated)S2410(by)S10 B2545(l_start)S10 R2860(if)S10 B2957(l_len)S10 R3199(is)S3301(zero.)S3560(If)S10 B3663(l_len)S10 R3905(is)S(nonzero)324 4008 A4368(then)S4577(the)S4736(\256le)S4901(keeps)S5166(its)S3024 V1440(size,)S1657(but)S1820(the)S1978(freed)S2221(bytes)S2467(now)S2674(read)S2882(as)S3000(zeros.)S3297(\(Other)S3595(than)S3802(sharing)S4132(the)S4289(\257ock)S4524(structure,)S4936(this)S5115(call)S3144 V1440(has)S1599(nothing)S1930(to)S2033(do)S2158(with)S2362(locking.\))S3312 V10 B1080(fcntl\()S10 I1311(fd)S10 B1397(,)S1447(F_SEEK,)S(u64_t)240 1877 A10 I2142(pos)S10 B2289(\))S3432 V10 R1440(This)S1650(Minix-vmd)S2138(speci\256c)S2477(call)S2654(sets)S2836(the)S2990(\256le)S(position)323 3150 A3504(of)S3619(the)S3773(\256le)S3933(associated)S4378(with)S4588(\256le)S4748(descriptor)S10 I5183(fd)S3552 V10 R1440(to)S1543(the)S1691(byte)S1889(offset)S2144(indicated)S2538(by)S2663(the)S2811(64-bit)S3076(number)S10 I3408(pos)S10 R3555(.)S3630(This)S3834(is)S(analogous)407 3926 A4358(to)S4461(the)S4609(call)S3720 V10 B1800(lseek\()S10 I2047(fd)S10 B2133(,)S10 I2183(pos)S10 B2330(,)S2380(SEEK_SET\))S3888 V10 R1440(except)S1728(that)S10 B1904(F_SEEK)S10 R2309(can)S2474(be)S2594(used)S2803(on)S2928(devices)S3255(larger)S3516(than)S3714(4)S3789(gigabyte.)S4056 V9 R720(S)S722(SE)S774(EE)S832(E)S913(A)S915(AL)S983(LS)S1041(SO)S1093(O)S4176 V10 B1080(open)S10 R1287(\(2\),)S10 B(dup)168 1455 A10 R1623(\(2\),)S10 B1791(lseek)S10 R2004(\(2\),)S10 B2172(ftruncate)S10 R2571(\(3\),)S10 B2739(int64)S10 R2957(\(3\).)S4344 V9 R720(D)S722(DI)S790(IA)S823(AG)S891(GN)S959(NO)S1027(OS)S1095(ST)S1147(TI)S1205(IC)S1238(CS)S1300(S)S4464 V10 B1080(Fcntl)S10 R1331(returns)S1637(a)S1709(\256le)S1865(descriptor,)S2320(\257ags,)S2562(or)S10 B2673(0)S10 R2750(to)S2855(indicate)S(success.)327 3201 A3580(On)S3730(error)S10 B-13954(-)S10 B4011(1)S10 R4088(is)S4182(returned,)S4570(with)S10 B(errno)241 4776 A10 R5044(set)S5183(to)S4584 V1080(the)S1228(appropriate)S1712(error)S1934(code.)S2199(The)S2381(most)S2601(notable)S2922(errors)S3183(are:)S4752 V10 B1080(EINTR)S4872 V10 R1330(If)S1423(a)S1493(blocked)S10 B(F_SETLKW)547 1836 A10 R2408(operation)S2813(is)S2905(interrupted)S3372(by)S3497(a)S3567(signal)S3832(that)S4008(is)S(caught.)293 4100 A5040 V10 B1080(EAGAIN)S5160 V10 R1330(By)S10 B(F_SETLK)447 1472 A10 R1944(if)S2031(a)S2101(segment)S(cannot)268 2461 A2754(be)S2874(locked.)S5328 V10 B1080(EBADF)S5448 V10 R1330(A)S1433(bad)S1609(\256le)S1769(descriptor)S2203(in)S2312(general,)S2665(or)S2780(an)S2906(attempt)S3239(to)S(place)213 3348 A3592(a)S3668(write)S3907(lock)S4111(on)S4242(a)S4318(\256le)S4478(that)S4660(is)S4758(not)S4917(open)S5143(for)S5568 V(writing,)316 1330 A1671(etc.)S5736 V10 B1080(ENOLCK)S5856 V10 R1330(No)S1478(locks)S1715(available,)S2129(the)S2277(\256le)S2431(system)S2735(code)S2950(has)S3109(run)S3268(out)S3421(of)S3530(internal)S3863(table)S(space.)249 4084 A6024 V9 R720(A)S722(AU)S790(UT)S858(TH)S916(HO)S984(OR)S1052(R)S6144 V10 R1080(Kees)S1307(J.)S1396(Bot)S1566(\(kjb@cs.vu.nl\))S7903 V720(September)S1176(13,)S(1996)200 1326 A4990(Page)S5211(2)S8143 VEP%%Trailer%%DocumentFonts: Times-Roman Times-Bold Times-Italic%%Pages: 2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -