l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
October 20: Web Application Hacking: How to Make and Break Security on the Web
Next Installfest:
TBD
Latest News:
Oct. 10: LUGOD Installfests coming again soon
Page last updated:
2002 Jun 13 20:57

The following is an archive of a post made to our 'vox mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox] cat and >> - how does it know?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox] cat and >> - how does it know?



begin nbs <nbs@sonic.net> 
> On Thu, Jun 13, 2002 at 04:21:53PM -0700, Mark K. Kim wrote:
> > File locking?
> > 
> 
> Who locks the file?
> 
> And just because some file that "cat" is opening for read is "locked,"
> why should that mean that it's the same file (input == output)
> 
> :)
 
bill,

here is what happens behind the scenes (i deleted memory managing and shared
library stuff):

  execve("/bin/cat", ["cat", "ron.tmp"], [/* 25 vars */]) = 0
  uname({sys="Linux", node="satan", ...}) = 0
  brk(0)                                  = 0x804b048
  
  ...
  
  fstat64(1, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
  open("ron.tmp", O_RDONLY|O_LARGEFILE)   = 3
  fstat64(3, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
  write(2, "cat: ", 5)                    = 5
  write(2, "ron.tmp: input file is output fi"..., 34) = 34
  write(2, "\n", 1)                       = 1
  close(3)                                = 0
  close(1)                                = 0
  _exit(1)                                = ?

before erroring out, 2 calls to fstat64 are made.

now if you look at man fstat, you'll see a field called "inode".

you know what an inode is, so you can infer the rest...   :-)

pete

ps- i was under the impression that this sort of thing killed the temp
file.  i'm surprised the check is made.

pps- there's no significance to "ron.tmp".  i had a a text file named
"ron" and made a copy of it, ron.tmp to do this experiment with since i
was expecting the file to be blown away.
_______________________________________________
vox mailing list
vox@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
EDGE Tech Corp.
For donating some give-aways for our meetings.