~zulcss/samba/server-dailies-3.4

« back to all changes in this revision

Viewing changes to tests/ftruncate.c

  • Committer: Chuck Short
  • Date: 2010-09-28 20:38:39 UTC
  • Revision ID: zulcss@ubuntu.com-20100928203839-pgjulytsi9ue63x1
Initial version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* test whether ftruncte() can extend a file */
 
2
 
 
3
#if defined(HAVE_UNISTD_H)
 
4
#include <unistd.h>
 
5
#endif
 
6
 
 
7
#include <sys/types.h>
 
8
#include <sys/stat.h>
 
9
#include <fcntl.h>
 
10
 
 
11
#define DATA "conftest.trunc"
 
12
#define LEN 7663
 
13
 
 
14
main()
 
15
{
 
16
        int *buf;
 
17
        int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666);
 
18
 
 
19
        if (fd == -1) {
 
20
                exit(1);
 
21
        }
 
22
 
 
23
        ftruncate(fd, LEN);
 
24
 
 
25
        unlink(DATA);
 
26
 
 
27
        if (lseek(fd, 0, SEEK_END) == LEN) {
 
28
                exit(0);
 
29
        }
 
30
        exit(1);
 
31
}