Changeset 462 for branches/samba-3.3.x/source/lib
- Timestamp:
- Jun 9, 2010, 6:20:03 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.3.x/source/lib/os2helper.c
r460 r462 1 /* This file contains helper functions for OS/2 - don't try and compile on other platforms */ 1 /* This file contains helper functions for OS/2 - 2 do not try to compile on other platforms! */ 2 3 3 4 #ifdef __OS2__ … … 20 21 #include <malloc.h> 21 22 22 / * these define the attribute byte as seen by DOS */23 #define aRONLY (1L<<0) 24 #define aHIDDEN (1L<<1) 25 #define aSYSTEM (1L<<2) 26 #define aVOLID (1L<<3) 27 #define aDIR (1L<<4) 28 #define aARCH (1L<<5) 23 // these define the attribute byte as seen by DOS 24 #define aRONLY (1L<<0) /* 0x01 */ 25 #define aHIDDEN (1L<<1) /* 0x02 */ 26 #define aSYSTEM (1L<<2) /* 0x04 */ 27 #define aVOLID (1L<<3) /* 0x08 */ 28 #define aDIR (1L<<4) /* 0x10 */ 29 #define aARCH (1L<<5) /* 0x20 */ 29 30 30 31 #ifndef TESTING … … 49 50 int os2_ftruncate(int fd, off_t size) 50 51 { 51 // We call there __libc_Back_ioFileSizeSet directly instead of 52 // ftruncate to force it not to zero expanding files to optimize 53 // samba performance when copying files 52 /* We call __libc_Back_ioFileSizeSet directly instead of 53 ftruncate to force it not to zero expanding files to 54 optimize Samba performance when copying files */ 55 54 56 int rc = __libc_Back_ioFileSizeSet(fd, size, 0); 55 57 if (rc < 0) … … 63 65 int os2_isattribute(char *path, unsigned short attr) 64 66 { 65 HDIR hdirFindHandle = HDIR_CREATE; 66 FILEFINDBUF3 FindBuffer = {0}; /* Returned from FindFirst/Next */ 67 USHORT dosattr; /* attribute to search for */ 68 ULONG ulResultBufLen = sizeof(FILEFINDBUF3); 69 ULONG ulFindCount = 1; /* Look for 1 file at a time */ 70 APIRET rc = NO_ERROR; /* Return code */ 71 if (attr==aARCH) 72 dosattr=MUST_HAVE_ARCHIVED; 73 else if (attr==aRONLY) 74 dosattr=MUST_HAVE_READONLY; 75 else if (attr==aSYSTEM) 76 dosattr=MUST_HAVE_SYSTEM; 77 else if (attr==aHIDDEN) 78 dosattr=MUST_HAVE_HIDDEN; 79 80 rc = DosFindFirst( path, /* File pattern - all files */ 81 &hdirFindHandle, /* Directory search handle */ 82 dosattr, 83 &FindBuffer, /* Result buffer */ 84 ulResultBufLen, /* Result buffer length */ 85 &ulFindCount, /* Number of entries to find */ 86 FIL_STANDARD); /* Return Level 1 file info */ 87 88 if (rc != NO_ERROR) { 89 rc = DosFindClose(hdirFindHandle); /* Close our directory handle */ 90 return 1; 91 92 } else { 93 rc = DosFindClose(hdirFindHandle); /* Close our directory handle */ 94 return 0; 95 96 } /* endif */ 97 67 HDIR hdirFindHandle = HDIR_CREATE; 68 FILEFINDBUF3 FindBuffer = {0}; /* Returned from FindFirst/Next */ 69 USHORT dosattr; /* attribute to search for */ 70 ULONG ulResultBufLen = sizeof(FILEFINDBUF3); 71 ULONG ulFindCount = 1; /* Look for 1 file at a time */ 72 APIRET rc = NO_ERROR; /* Return code */ 73 if (attr==aARCH) 74 dosattr=MUST_HAVE_ARCHIVED; 75 else if (attr==aRONLY) 76 dosattr=MUST_HAVE_READONLY; 77 else if (attr==aSYSTEM) 78 dosattr=MUST_HAVE_SYSTEM; 79 else if (attr==aHIDDEN) 80 dosattr=MUST_HAVE_HIDDEN; 81 82 rc = DosFindFirst( path, /* File pattern - all files */ 83 &hdirFindHandle, /* Directory search handle */ 84 dosattr, 85 &FindBuffer, /* Result buffer */ 86 ulResultBufLen, /* Result buffer length */ 87 &ulFindCount, /* Number of entries to find */ 88 FIL_STANDARD); /* Return Level 1 file info */ 89 90 if (rc != NO_ERROR) { 91 rc = DosFindClose(hdirFindHandle); /* Close our directory handle */ 92 return 1; 93 } else { 94 rc = DosFindClose(hdirFindHandle); /* Close our directory handle */ 95 return 0; 96 } /* endif */ 98 97 } 99 98 … … 129 128 } 130 129 131 /* os2 specific random functions. this functions used to be based on APR random code.132 but we discovered some nasty problems with it on fast hardware (especially on quadcore) and133 decided to rewrite it with libc random() */130 /* OS/2-specific random functions. these functions used to be based on APR 131 random code, but we discovered some nasty problems with it on fast hardware 132 (especially on quadcore) and decided to rewrite it with libc random() */ 134 133 135 134 void os2_randget(char * buffer, int length) 136 135 { 137 138 139 140 136 UCHAR randbyte(); 137 unsigned int idx; 138 139 for (idx=0; idx<length; idx++) 141 140 buffer[idx] = randbyte(); 142 141 … … 145 144 UCHAR randbyte() 146 145 { 147 148 149 146 int c; 147 UCHAR byte; 148 ULONG ulrandom; 150 149 ulrandom = random(); 150 151 151 for (c = 0; c < sizeof(ulrandom); c++) { 152 152 byte ^= ((UCHAR *)&ulrandom)[c]; 153 153 } 154 154 155 155 return byte; 156 156 } 157 157
Note:
See TracChangeset
for help on using the changeset viewer.