VirtualBox

source: kBuild/trunk/src/kmk/kmkbuiltin/solfakes.c@ 1713

Last change on this file since 1713 was 1713, checked in by bird, 16 years ago

kmk_chmod: made it build on solaris (no lchmod or ALLPERMS).

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1/* $Id: $ */
2/** @file
3 *
4 * Fake Unix stuff for Solaris.
5 *
6 * Copyright (c) 2005-2007 knut st. osmundsen <[email protected]>
7 *
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with This program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25
26#include <errno>
27#include <stdio.h>
28#include <stdarg.h>
29#include <stdlib.h>
30#include <sys/stat.h>
31#include "solfakes.h"
32
33
34int asprintf(char **strp, const char *fmt, ...)
35{
36 int rc;
37 va_list va;
38 va_start(va, fmt);
39 rc = vasprintf(strp, fmt, va);
40 va_end(va);
41 return rc;
42}
43
44
45int vasprintf(char **strp, const char *fmt, va_list va)
46{
47 int rc;
48 char *psz;
49 size_t cb = 1024;
50
51 *strp = NULL;
52 for (;;)
53 {
54 va_list va2;
55
56 psz = malloc(cb);
57 if (!psz)
58 return -1;
59
60#ifdef va_copy
61 va_copy(va2, va);
62 rc = snprintf(psz, cb, fmt, va2);
63 va_end(va2);
64#else
65 va2 = va;
66 rc = snprintf(psz, cb, fmt, va2);
67#endif
68 if (rc < 0 || (size_t)rc < cb)
69 break;
70 cb *= 2;
71 free(psz);
72 }
73
74 *strp = psz;
75 return rc;
76}
77
78
79
80int sol_lchmod(const char *pszPath, mode_t mode)
81{
82 /*
83 * Weed out symbolic links.
84 */
85 struct stat s;
86 if ( !lstat(pszPath, &s)
87 && S_ISLNK(s.st_mode))
88 {
89 errno = -ENOSYS;
90 return -1;
91 }
92
93 return chmod(pszPath, mode);
94}
95
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette