Operating System - HP-UX
1752595 Members
3355 Online
108788 Solutions
New Discussion юеВ

Problems regarding fixed file size on Unix

 
kamlesh33
New Member

Problems regarding fixed file size on Unix

Hi All,

How can i restrict writing the data beyond fixed file size?

i.e. suppose my file is of 1024 bytes. So, i want to restrict writing the data only of 1024 bytes. Beyond 1024 bytes no data to be written on that file. How can I do this?
6 REPLIES 6
Steven Schweda
Honored Contributor

Re: Problems regarding fixed file size on Unix

Disk quotas?

Why do you care? Is there some actual
problem which you are trying to solve?


Discarding your previous thread on this topic
may not be the best way to accumulate useful
information.
kamlesh33
New Member

Re: Problems regarding fixed file size on Unix

as we can use

dd if=/home2/kamlesh/ of=kk.txt count=1024

for creating kk.txt file of 1024 byte.

Now, i want to restrict the data upto 1024 bytes only. How can I do that?
James R. Ferguson
Acclaimed Contributor

Re: Problems regarding fixed file size on Unix

Hi:

> dd if=/home2/kamlesh/ of=kk.txt count=1024

You need to add a block size; the default is 512. A read of the 'dd(1)' manpages might be beneficial.

Depending upon your objective, you could change the permissions of the file, once created, to disallow writes to it.

Regards!

...JRF...

Hein van den Heuvel
Honored Contributor

Re: Problems regarding fixed file size on Unix




Steven replied...>>> Discarding your previous thread on this topic
may not be the best way to accumulate useful
information.

Yeah, that was my knee-jerk reaction as well.

So i looked back for the topic and found:

http://h30499.www3.hp.com/t5/System-Administration/Creating-Fixed-size-file-on-unix/m-p/2794533#M80618


This is from 'way-back' and I think that's the topic Steven referred to ann myself and others replied to.

So I think what happened is that 'kamlesh33' at first continued an old conversation. This was noticed by the 'powers that be' and a new topic was forced.

I for one, and others, had not noticed the old topic and we made an effort to help.

Our replies and work appear to be deleted without a warning or bounce-back.
Why not just leave well enough alone, or LOCK the old topic.

I find it extremely disrespectful for my work to be thrown away without cause or recourse.

I don't need that treatment.

I'm pissed! (not at kamlesh33)

Hein.

:-(.

Dennis Handly
Acclaimed Contributor

Re: Problems regarding fixed file size on Unix

>How can I restrict writing the data beyond fixed file size?

Possibly by setting up the file security so only a specific application (possibly SETUID) can write to the file and it will know about your size limitation.
TwoProc
Honored Contributor

Re: Problems regarding fixed file size on Unix

About the only thing I can think of that you could create an lvol the size of the file that you want, and use that /dev/vgxxx/lvolxxx as the file name for your program(s).
We are the people our parents warned us about --Jimmy Buffett