]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/cmd/largest_file/largest_file.c
5e6a1866059b1aed0a2dbe41c8625e69695b5155
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 * Copyright (c) 2012 by Delphix. All rights reserved.
31 #include "../file_common.h"
32 #include <sys/param.h>
36 #include <sys/types.h>
39 typedef long long offset_t
;
40 #define MAXOFFSET_T LLONG_MAX
43 * --------------------------------------------------------------
46 * The last byte of the largest file size can be
47 * accessed without any errors. Also, the writing
48 * beyond the last byte of the largest file size
49 * will produce an errno of EFBIG.
51 * --------------------------------------------------------------
52 * If the write() system call below returns a "1",
53 * then the last byte can be accessed.
54 * --------------------------------------------------------------
56 static void sigxfsz(int);
57 static void usage(char *);
60 main(int argc
, char **argv
)
63 offset_t offset
= (MAXOFFSET_T
- 1);
64 offset_t llseek_ret
= 0;
67 char mybuf
[5] = "aaaa\0";
69 mode_t mode
= S_IRUSR
| S_IWUSR
| S_IRGRP
| S_IROTH
;
75 (void) sigset(SIGXFSZ
, sigxfsz
);
77 testfile
= strdup(argv
[1]);
79 fd
= open(testfile
, O_CREAT
| O_RDWR
, mode
);
82 perror("Failed to create testfile");
87 llseek_ret
= lseek64(fd
, offset
, SEEK_SET
);
90 perror("Failed to seek to end of testfile");
94 write_ret
= write(fd
, mybuf
, 1);
97 perror("Failed to write to end of file");
102 llseek_ret
= lseek64(fd
, offset
, SEEK_CUR
);
103 if (llseek_ret
< 0) {
105 perror("Failed to seek to end of file");
109 write_ret
= write(fd
, mybuf
, 1);
111 if (errno
== EFBIG
|| errno
== EINVAL
) {
112 (void) printf("write errno=EFBIG|EINVAL: success\n");
116 perror("Did not receive EFBIG");
119 (void) printf("write completed successfully, test failed\n");
124 (void) unlink(testfile
);
133 (void) printf("%s <testfile>\n", name
);
141 (void) printf("\nlargest_file: sigxfsz() caught SIGXFSZ\n");