equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
209 { |
209 { |
210 int result; |
210 int result; |
211 RESTARTABLE(ftruncate64(fd, length), result); |
211 RESTARTABLE(ftruncate64(fd, length), result); |
212 return result; |
212 return result; |
213 } |
213 } |
214 |
|
215 size_t |
|
216 getLastErrorString(char *buf, size_t len) |
|
217 { |
|
218 if (errno == 0 || len < 1) return 0; |
|
219 |
|
220 const char *err = strerror(errno); |
|
221 size_t n = strlen(err); |
|
222 if (n >= len) |
|
223 n = len - 1; |
|
224 |
|
225 strncpy(buf, err, n); |
|
226 buf[n] = '\0'; |
|
227 return n; |
|
228 } |
|