Location:
Search - lseek
Search list
Description: 学会对文件的记录锁定,及解锁。#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main()
{
int fd
int i
struct {
char name[20]
uint ID
int age
} myrec
fd =open(\"name\", O_RDWR|O_CREAT, 0755)
if (fd == -1) return -1
printf(\"Input your name:\") scanf(\"%s\", myrec.name)
printf(\"Inpute your ID :\") scanf(\"%d\", &myrec.ID)
printf(\"Input your age :\") scanf(\"%d\", &myrec.age)
lseek(fd, 0,SEEK_END)
lockf(fd, 1, 0)
write(fd, (void *)&myrec, sizeof(myrec))
lockf(fd, 0 ,0)
return 0
}
执行命令cc lock.c –o lock.out
Chmod +x lock.out
./lock.out
Platform: |
Size: 9297 |
Author: 华羿 |
Hits:
Description: 这是一本讲解C语言的书,是英文编写,十分经典,是大部分公司的新职员入职之前必须要看的书籍之一,很多公司都以它作为培训教材,帮助你更快了解C语言的奥妙。 Contents l Preface l Preface to the first edition l Introduction 1. Chapter 1: A Tutorial Introduction 1. Getting Started 2. Variables and Arithmetic Expressions 3. The for statement 4. Symbolic Constants 5. Character Input and Output 1. File Copying 2. Character Counting 3. Line Counting 4. Word Counting 6. Arrays 7. Functions 8. Arguments - Call by Value 9. Character Arrays 10. External Variables and Scope 2. Chapter 2: Types, Operators and Expressions 1. Variable Names 2. Data Types and Sizes 3. Constants 4. Declarations 5. Arithmetic Operators 6. Relational and Logical Operators 7. Type Conversions 8. Increment and Decrement Operators 9. Bitwise Operators 10. Assignment Operators and Expressions 11. Conditional Expressions 12. Precedence and Order of Evaluation 3. Chapter 3: Control Flow 1. Statements and Blocks 2. If-Else 3. Else-If 4. Switch 5. Loops - While and For 6. Loops - Do-While 7. Break and Continue 8. Goto and labels 4. Chapter 4: Functions and Program Structure 1. Basics of Functions 2. Functions Returning Non-integers 3. External Variables 4. Scope Rules 5. Header Files 6. Static Variables 7. Register Variables 8. Block Structure 9. Initialization 10. Recursion 11. The C Preprocessor 1. File Inclusion 2. Macro Substitution 3. Conditional Inclusion 5. Chapter 5: Pointers and Arrays 1. Pointers and Addresses 2. Pointers and Function Arguments 3. Pointers and Arrays 4. Address Arithmetic 5. Character Pointers and Functions 6. Pointer Arrays; Pointers to Pointers 7. Multi-dimensional Arrays 8. Initialization of Pointer Arrays 9. Pointers vs. Multi-dimensional Arrays 10. Command-line Arguments 11. Pointers to Functions 12. Complicated Declarations 6. Chapter 6: Structures 1. Basics of Structures 2. Structures and Functions 3. Arrays of Structures 4. Pointers to Structures 5. Self-referential Structures 6. Table Lookup 7. Typedef 8. Unions 9. Bit-fields 7. Chapter 7: Input and Output 1. Standard Input and Output 2. Formatted Output - printf 3. Variable-length Argument Lists 4. Formatted Input - Scanf 5. File Access 6. Error Handling - Stderr and Exit 7. Line Input and Output 8. Miscellaneous Functions 1. String Operations 2. Character Class Testing and Conversion 3. Ungetc 4. Command Execution 5. Storage Management 6. Mathematical Functions 7. Random Number generation 8. Chapter 8: The UNIX System Interface 1. File Descriptors 2. Low Level I/O - Read and Write 3. Open, Creat, Close, Unlink 4. Random Access - Lseek 5. Example - An implementation of Fopen and Getc 6. Example - Listing Directories 7. Example - A Storage Allocator l Appendix A: Reference Manual 1. Introduction 2. Lexical Conventions 3. Syntax Notation 4. Meaning of Identifiers 5. Objects and Lvalues 6. Conversions 7. Expressions 8. Declarations 9. Statements 10. External Declarations 11. Scope and Linkage 12. Preprocessor 13. Grammar l Appendix B: Standard Library 1. Input and Output: 1. File Operations 2. Formatted Output 3. Formatted Input 4. Character Input and Output Functions 5. Direct Input and Output Functions 6. File Positioning Functions 7. Error Functions 2. Character Class Tests: 3. String Functions: 4. Mathematical Functions: 5. Utility Functions: 6. Diagnostics: 7. Variable Argument Lists: 8. Non-local Jumps: 9. Signals: 10. Date and Time Functions: 11. Implementation-defined Limits: and l Appendix C: Summary of Changes
Platform: |
Size: 570630 |
Author: wukoo0901@qq.com |
Hits:
Description: 学会对文件的记录锁定,及解锁。#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main()
{
int fd
int i
struct {
char name[20]
uint ID
int age
} myrec
fd =open("name", O_RDWR|O_CREAT, 0755)
if (fd == -1) return -1
printf("Input your name:") scanf("%s", myrec.name)
printf("Inpute your ID :") scanf("%d", &myrec.ID)
printf("Input your age :") scanf("%d", &myrec.age)
lseek(fd, 0,SEEK_END)
lockf(fd, 1, 0)
write(fd, (void *)&myrec, sizeof(myrec))
lockf(fd, 0 ,0)
return 0
}
执行命令cc lock.c –o lock.out
Chmod +x lock.out
./lock.out
Platform: |
Size: 9216 |
Author: 华羿 |
Hits:
Description: 该程序是在linux下执行,首先创建一个文件,然后对此文件进行读写操作。接着,写入“Hello,I m writing to this file!”,此时文件指针位于文件尾部。接着再使用lseek函数将文件指针移到文件开始处,并读出10个字节并将其打印出来。-The program is run under linux, first of all to create a document, and then read and write operations on this file. Then, write " Hello, I' m writing to this file!" , At this time a document file pointer is located in the rear. Lseek function and then use the file pointer to the beginning of a document, and read out 10 bytes and print them out.
Platform: |
Size: 1024 |
Author: 牛志强 |
Hits:
Description: 分布文件系统
Ceph是基于California大学存储系统研究中心研究成果的LGPL项目-v0.13 released
We’ve made a v0.13 release. This mostly fixes bugs with v0.12 that have come up over the past couple weeks:
* [ku]lcient: fix sync read vs eof, lseek(…, SEEK_END)
* mds: misc bug fixes for multiclient file access
But also a few other big things:
* osd: stay active during backlog generation
* osdmap: override mappings (pg_temp)
* kclient: some improvements in kmalloc, memory preallocation
The OSD changes mean that the storage cluster can temporarily delegate authority for a placement group to the node that has the complete data while an index is being generated for recovery (that can take a while). Once that’s ready, control will fall back to the new/correct node and the usual recovery will kick in.
The disk format and wire protocols have changed with this version.
We’re continuing to work on the security infrastructure… hopefully will be ready for v0.14.
Here are the relevant URLs:
* Git tree at git://ceph.newdream.n
Platform: |
Size: 4090880 |
Author: whoami |
Hits:
Description: 实验二 同步与异步write的效率比较设置输入缓冲区时需要知道输入文件的长度。除了使用系统调用stat外,更简单的方法是利用lseek的返回值来获取文件的长度。在按每一个给定大小的输出缓冲区计算写文件时间时,应当在开始写之前调用times(),记录下开始时间,然后在整个输入缓冲区都复制到输出文件之后,再调用times(),两次调用times()的时间间隔,就是在这个给定大小的输出缓冲区的限制下,复制整个输入文件所耗费的写时间。-Experiment two synchronous and asynchronous write efficiency set input buffer need to know the length of the input file. In addition to using the system call stat, the easier way is to use the return value of lseek to get the length of the file. Per one calculation to write the file time to set the size of the output buffer, it should be called before you start writing times (), record the start time, then the entire input buffer are copied to the output file, and then call times () call times (twice) time interval, is the limitations of a given size of the output buffer, write the time-consuming to copy the entire input file....
Platform: |
Size: 37888 |
Author: 林素素 |
Hits:
Description: linux共享内存,mmap,lseek-linux share memory,mmap,lseek
Platform: |
Size: 1024 |
Author: rockman1982 |
Hits:
Description: The Mini Filesystem POSIX example demonstrates the implementation of a POSIX
interface to a simple filesystem style device. The mini filesystem is stored in
a single file on the host and POSIX I/O functions such as open, close, read,
write, remove, lseek and fstat can be used on it. -The Mini Filesystem POSIX example demonstrates the implementation of a POSIX
interface to a simple filesystem style device. The mini filesystem is stored in
a single file on the host and POSIX I/O functions such as open, close, read,
write, remove, lseek and fstat can be used on it.
Platform: |
Size: 7168 |
Author: zscd |
Hits:
Description: linux系统编程lseek函数的实现,偏移操作-linux system programming lseek function implementation, offset operation
Platform: |
Size: 1024 |
Author: SHIJY |
Hits:
Description: 简要说明了read,write,lseek函数的功能,同时还有说明呢-it describe lseek and read and write function
Platform: |
Size: 1024 |
Author: 刘奇 |
Hits:
Description: lseek system call emulation for 4.2BSD and BRL PDP-11 UNIX.
-lseek system call emulation for 4.2BSD and BRL PDP-11 UNIX.
Platform: |
Size: 1024 |
Author: knmgsou |
Hits:
Description: 编写带缓存的文件操作类
从执行体程序库中的CLLogger类可知,通过缓存要写入文件中的数据,能够提高读写磁盘的性能
请编写一个文件操作的封装类,其要求如下:
需要提供open/read/write/lseek/close等函数的封装函数
该类要提供数据缓存服务。
调用该类的写操作接口时,数据要首先写到缓存,然后再根据策略写到文件中。
调用该类的读操作接口时,该类能根据策略缓存读出的数据
读写缓存要保持一致性
-From the implementation of the CLLogger class library, we can know, through the cache to write data in the file, you can improve the performance of the read and write disk
Please write a package for the operation of the class, and its requirements are as follows:
The encapsulation function of open/read/write/lseek/close and other functions is required.
The class to provide data cache services.
When the write operation interface of the class is called, the data must first be written to the cache, and then the policy is written to the file.
When a read operation interface of the class is called, the class can read the data according to the policy cache.
Read/write cache to maintain consistency
Platform: |
Size: 5120 |
Author: 张文强 |
Hits:
Description: open打开方式.lseek(fd,200,SEEK_SET);//从文件头往后面偏移200个字节(Open open.Lseek (FD, 200, SEEK_SET); / / from the file header behind 200 byte offset)
Platform: |
Size: 2048 |
Author: 句与句
|
Hits:
Description: the use of lseek in linux
Platform: |
Size: 3072 |
Author: ick
|
Hits: