int main( void )
{
int fd,size,positio n;
char buf[20];
char lkl[] = "hello,worl d!";
fd = creat( "test",0644 );
size = write( fd,lkl,sizeof(l kl) );
close(fd);
fd = open( "test",O_RD WR );
size = read( fd,buf,sizeof(b uf) );
printf( "fd is %s,the length is %d\n\n",buf,siz e );
position = lseek( fd,70000000,SEE K_END);
size = write( fd,lk,sizeof(lk l) );
close(fd);
return 1;
}
This is just test code, I wanna see what the file will be if I make
the file pointer point to the end and move it by API lseek. That is
what you can see in the code. After a lot of tests, I found that the
file's size which can be saw by the command "ls -ls" will change
according to the lseek's second parameter distance.
For example:
If the dist is 4000 or less than 4000, the block which is filled by
file "test" will be 4K, it's reasonable for the minimal size of block
is 4K.
If the dist is 5000-480000, the block which is filled by file "test"
will be 8K, it's reasonable for the position where the second string
lk be written is out of block 1, so maybe we need two block to save
file "test".
But the follow is something I can not understand. If the dist is more
than 480000, such as 700000, the block which is filled by file "test"
will be 8.5K.
I change the dist to 7000000 direct, the block which is filled by file
"test" will be 15K. And if it is changed to 70000000, the block will
be 75K.
In my opnion, there only have two string in the file, so although
length of file will increase as I increase the distance moved by
lseek, the ACTUAL block size filled by "test" file will keep to be 8K.
But actually I am wrong. So who can explain it for me ?
Thanks very much! 3 1772
windstorm <li************ @gmail.comwrote :
int main( void )
{
int fd,size,positio n;
char buf[20];
char lkl[] = "hello,worl d!";
fd = creat( "test",0644 );
This is not ISO C, which is the subject of this newsgroup. It's POSIX,
or something very like it, and your question is about the POSIX parts,
not about the C parts. You need to ask this question in
comp.unix.progr ammer.
Richard
windstorm wrote:
>
int main( void )
{
[... POSIX code to write() a string at the start of a file, ...]
[... followed by an lseek() to 70000000 and another write(). ...]
}
This is just test code, I wanna see what the file will be if I make
the file pointer point to the end and move it by API lseek. That is
what you can see in the code. After a lot of tests, I found that the
file's size which can be saw by the command "ls -ls" will change
according to the lseek's second parameter distance.
[...]
In my opnion, there only have two string in the file, so although
length of file will increase as I increase the distance moved by
lseek, the ACTUAL block size filled by "test" file will keep to be 8K.
But actually I am wrong. So who can explain it for me ?
This isn't strictly C, as your results are really O/S and filesystem
dependent. However, search for "sparse files" (with quotes) to find
out more about what's going on, and if you need more help you need to
go to a group such as comp.unix.progr ammer where this might be on-topic.
--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer .h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th***** ********@gmail. com>
On 6 14 , 8 54 , r...@hoekstra-uitgeverij.nl (Richard Bos) wrote:
windstorm <likunarmstr... @gmail.comwrote :
int main( void )
{
int fd,size,positio n;
char buf[20];
char lkl[] = "hello,worl d!";
fd = creat( "test",0644 );
This is not ISO C, which is the subject of this newsgroup. It's POSIX,
or something very like it, and your question is about the POSIX parts,
not about the C parts. You need to ask this question in
comp.unix.progr ammer.
Richard
oh,I am sorry about it. I have post this to comp.unix.progr ammer,
thanks! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dave |
last post by:
Hi,
If anyone could help with this, I would greatly appreciate it!
I've created my own WSDL file and referenced an XSD file too. I've generated
a service side interface using wsdl /server, and created an ASMX file from
this. I've then set the Binding for the class and methods and set the
Location to my WSDL file. If I put the wsdl:service element in the WSDL file
that points to my endpoint, I can go to Add Web Reference and my methods...
|
by: Firehawk® |
last post by:
Hi,
I have a great experience with DB (Oracle and others) and I am using DB2
now.
Then, I have few questions:
1. How drop a schema (user) and all objects of this schema, like a Oracle
"drop user cascade" ?
2. Suposing, 2 Databases, DB1 and DB2, each one with a schema, schema1 in
DB1 and schema2 in DB2.
|
by: suresh |
last post by:
Hello All,
Iam writing a wsdl file using the Servicedescription
class.The document I get is a well formed xml document.But
some how when I try to add this wsdl file as a webrefernce
to another project in VisualStudio.NET it gives me the
following error
"
c:\inetpub\wwwroot\WebApplication3\Web
References\WebReference\Reference.map(1): Custom tool
error: Unable to import WebService/Schema. Cannot find
|
by: moonriver |
last post by:
In a xml file, can we make reference to another xml file so that all contents
of the latter xml file will be included into the first xml file?
Had better give me an example for details.
|
by: Lalatendu Das |
last post by:
Dear friends,
I am getting a problem in the code while interacting with a nested
Do-while loop
It is skipping a scanf () function which it should not. I have written
the whole code below. Please help me in finding why such thing is
happening and what the remedy to it is. Kindly bear with my English.
int
main ()
| |
by: spacehopper_man |
last post by:
no "rename" operation in C# !!!
- this has been covered in this group before, but I can't find any good
answers.
what I am trying to do is refresh the content in a file with minimum
performance impact on any read operations to that file - a common task
right....
in the unix world the way to do this is to create a temporary file with
|
by: Rajkiran R.B. |
last post by:
I have written a program in C#...
Now the requirement is that I want an assembly code to be the output rather
than the regular executable output..
Can anyone say how to do it..
|
by: Primo |
last post by:
I have 3 files and I want all of them to go to the bank and one of them will go to both the bank and a vendor.
this is a code we have:
<process name="FD_Generic_Outbound_banksplit">
<sequence name="Sequence Start">
<assign to="SetExtractionArchiveFolder" from="'..inbound'"></assign>
|
by: matt |
last post by:
Hello group,
I'm trying to become familiar with the information hiding design rules, and I
have a lot (3) of questions for all you experts. AFAIK, a generic module has 2
files:
================
module.h
================
#ifndef __MODULE_HDR_INCLUDED__
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |