generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / lib / write_log.c
index d6c81a77d58a86f9bc06ddc55da62657940cc2dc..cdc72593b9dcc3932161e6da1265254ad681c4f5 100644 (file)
@@ -1,33 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * 
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
- * For further information regarding this notice, see: 
- * 
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
+ * Copyright (c) 2000 Silicon Graphics, Inc.
+ * All Rights Reserved.
  */
 /*
  * This module contains code for logging writes to files, and for
@@ -87,7 +61,8 @@
 /*#define PATH_MAX pathconf("/", _PC_PATH_MAX)*/
 #endif
 
-char   Wlog_Error_String[256];
+#define ERROR_STRING_LEN 1280
+char   Wlog_Error_String[ERROR_STRING_LEN];
 
 #if __STDC__
 static int     wlog_rec_pack(struct wlog_rec *wrec, char *buf, int flag);
@@ -134,7 +109,7 @@ int                 mode;
        umask(omask);
 
        if (wfile->w_afd == -1) {
-               sprintf(Wlog_Error_String,
+               snprintf(Wlog_Error_String, ERROR_STRING_LEN,
                        "Could not open write_log - open(%s, %#o, %#o) failed:  %s\n",
                        wfile->w_file, oflags, mode, strerror(errno));
                return -1;
@@ -146,7 +121,7 @@ int                 mode;
 
        oflags = O_RDWR;
        if ((wfile->w_rfd = open(wfile->w_file, oflags)) == -1) {
-               sprintf(Wlog_Error_String,
+               snprintf(Wlog_Error_String, ERROR_STRING_LEN,
                        "Could not open write log - open(%s, %#o) failed:  %s\n",
                        wfile->w_file, oflags, strerror(errno));
                close(wfile->w_afd);