caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* file permission integer
@ 1999-03-26 20:33 Manuel Fahndrich
  1999-03-29 16:10 ` Xavier Leroy
  0 siblings, 1 reply; 4+ messages in thread
From: Manuel Fahndrich @ 1999-03-26 20:33 UTC (permalink / raw)
  To: 'caml-list@inria.fr'


The OCAML core contains a function

	open_out_gen : open_flag list -> int -> string -> out_channel

where the integer corresponds to the file permissions set when a new file is
created. How is this integer interpreted? Does it vary from platform to
platform? (Unix vs Windows).

Similarly, under the Unix module, there is the type file_perm = int, serving
the same purpose. Are these integers interpreted with the standard Unix
octal file permission bits? How about under Windows?

If this information is described in the doc, I apologize, but I couldn't
find it.

-Manuel




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: file permission integer
  1999-03-26 20:33 file permission integer Manuel Fahndrich
@ 1999-03-29 16:10 ` Xavier Leroy
  1999-03-30  7:33   ` Friedman Roy
  0 siblings, 1 reply; 4+ messages in thread
From: Xavier Leroy @ 1999-03-29 16:10 UTC (permalink / raw)
  To: Manuel Fahndrich, 'caml-list@inria.fr'

> The OCAML core contains a function
> 	open_out_gen : open_flag list -> int -> string -> out_channel
> where the integer corresponds to the file permissions set when a new file is
> created. How is this integer interpreted? Does it vary from platform to
> platform? (Unix vs Windows).
> If this information is described in the doc, I apologize, but I couldn't
> find it.

No need to apologize, this is indeed not documented (oops!).

The integer argument to open_*_gen follows the Unix semantics,
i.e. 0oABC, where A are the user permissions, B the group permissions,
C the permissions for others.  A, B, C are single octal digits
obtained by or-ing individual permission bits: 1 for execute permission,
2 for write permission, and 4 for read permission.

Under Windows, only the "write permission" bit of the "user
permission" digit is consulted, and determines if the file is created
read-write or read-only.  (The other permission bits don't have any
equivalent in Win32, at least on a FAT file system.)

So, if you pass the correct permissions for Unix, your code should
work just fine under Windows.

In Caml Light, we used to have symbolic names for the various
permission bits.  I removed them in OCaml after realizing that the
Unix bit-patterns work just fine in Windows as well.  However, the
Unix encoding is a bit cryptic, so maybe those symbolic names were a
good idea after all.

All the best,

- Xavier Leroy




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: file permission integer
  1999-03-29 16:10 ` Xavier Leroy
@ 1999-03-30  7:33   ` Friedman Roy
  0 siblings, 0 replies; 4+ messages in thread
From: Friedman Roy @ 1999-03-30  7:33 UTC (permalink / raw)
  To: Xavier Leroy; +Cc: Manuel Fahndrich, 'caml-list@inria.fr'

The only caveat is that in Unix this also sets the user/group/other
permissions, and the equivalent in NT involves writing a C function that
sets the ACL attributes for the file.

Roy

On Mon, 29 Mar 1999, Xavier Leroy wrote:

> > The OCAML core contains a function
> > 	open_out_gen : open_flag list -> int -> string -> out_channel
> > where the integer corresponds to the file permissions set when a new file is
> > created. How is this integer interpreted? Does it vary from platform to
> > platform? (Unix vs Windows).
> > If this information is described in the doc, I apologize, but I couldn't
> > find it.
> 
> No need to apologize, this is indeed not documented (oops!).
> 
> The integer argument to open_*_gen follows the Unix semantics,
> i.e. 0oABC, where A are the user permissions, B the group permissions,
> C the permissions for others.  A, B, C are single octal digits
> obtained by or-ing individual permission bits: 1 for execute permission,
> 2 for write permission, and 4 for read permission.
> 
> Under Windows, only the "write permission" bit of the "user
> permission" digit is consulted, and determines if the file is created
> read-write or read-only.  (The other permission bits don't have any
> equivalent in Win32, at least on a FAT file system.)
> 
> So, if you pass the correct permissions for Unix, your code should
> work just fine under Windows.
> 
> In Caml Light, we used to have symbolic names for the various
> permission bits.  I removed them in OCaml after realizing that the
> Unix bit-patterns work just fine in Windows as well.  However, the
> Unix encoding is a bit cryptic, so maybe those symbolic names were a
> good idea after all.
> 
> All the best,
> 
> - Xavier Leroy
> 
> 




^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: file permission integer
@ 1999-03-30 18:13 Manuel Fahndrich
  0 siblings, 0 replies; 4+ messages in thread
From: Manuel Fahndrich @ 1999-03-30 18:13 UTC (permalink / raw)
  To: 'caml-list@inria.fr'


Thanks for the reply.

I thought about the bit encoding vs. datatype as well. What would be useful
is simply a function that creates the correct bit pattern from a more
descriptive data type list. Then power users can give the bit-pattern
directly, and standard users can go through the encoding function.

-Manuel 

-----Original Message-----
From: Xavier Leroy [mailto:Xavier.Leroy@inria.fr]
Sent: Monday, March 29, 1999 8:11 AM
To: Manuel Fahndrich; 'caml-list@inria.fr'
Subject: Re: file permission integer


> The OCAML core contains a function
> 	open_out_gen : open_flag list -> int -> string -> out_channel
> where the integer corresponds to the file permissions set when a new file
is
> created. How is this integer interpreted? Does it vary from platform to
> platform? (Unix vs Windows).
> If this information is described in the doc, I apologize, but I couldn't
> find it.

No need to apologize, this is indeed not documented (oops!).

The integer argument to open_*_gen follows the Unix semantics,
i.e. 0oABC, where A are the user permissions, B the group permissions,
C the permissions for others.  A, B, C are single octal digits
obtained by or-ing individual permission bits: 1 for execute permission,
2 for write permission, and 4 for read permission.

Under Windows, only the "write permission" bit of the "user
permission" digit is consulted, and determines if the file is created
read-write or read-only.  (The other permission bits don't have any
equivalent in Win32, at least on a FAT file system.)

So, if you pass the correct permissions for Unix, your code should
work just fine under Windows.

In Caml Light, we used to have symbolic names for the various
permission bits.  I removed them in OCaml after realizing that the
Unix bit-patterns work just fine in Windows as well.  However, the
Unix encoding is a bit cryptic, so maybe those symbolic names were a
good idea after all.

All the best,

- Xavier Leroy




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-03-31  7:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-26 20:33 file permission integer Manuel Fahndrich
1999-03-29 16:10 ` Xavier Leroy
1999-03-30  7:33   ` Friedman Roy
1999-03-30 18:13 Manuel Fahndrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).