File: nixmode.i

package info (click to toggle)
zoo 2.10-21
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 852 kB
  • ctags: 1,258
  • sloc: ansic: 8,944; asm: 793; makefile: 179
file content (42 lines) | stat: -rw-r--r-- 1,127 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef LINT
/* @(#) nixmode.i 1.2 88/01/24 12:48:57 */
static char modeid[]="@(#) nixmode.i 1.2 88/01/24 12:48:57";
#endif

/*
(C) Copyright 1988 Rahul Dhesi -- All rights reserved

UNIX-specific routines to get and set file attribute.  These might be 
usable on other systems that have the following identical things:
fileno(), fstat(), chmod(), sys/types.h and sys/stat.h.
*/

/*
Get file attributes.  Currently only the lowest nine of the
**IX mode bits are used.  Also we return bit 23=0 and bit 22=1,
which means use portable attribute format, and use attribute
value instead of using default at extraction time.
*/

unsigned long getfattr (f)
ZOOFILE f;
{
	int fd;
   struct stat buf;           /* buffer to hold file information */
	fd = fileno(f);
   if (fstat (fd, &buf) == -1)
      return (NO_FATTR);      /* inaccessible -- no attributes */
	else
		return (unsigned long) (buf.st_mode & 0x1ffL) | (1L << 22);
}

/*
Set file attributes.  Only the lowest nine bits are used.
*/

int setfattr (f, a)
char *f;							/* filename */
unsigned long a;				/* atributes to set */
{
	return (chmod (f, (int) (a & 0x1ff)));
}