Fix Solaris bug where chmod fails if we don't have PRIV_SYS_LINKDIR
[tar.git] / src / testpad.c
blob12d96e348a29358e4d90570e6262887efa82fdf7
1 /* Find out if we need the pad field in the header for this machine
2 Copyright (C) 1991 Free Software Foundation
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2, or (at
7 your option) any later version.
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include <stdio.h>
21 struct inc
23 char a[20];
24 char b[20];
27 struct test1
29 char a;
30 struct inc in[5];
33 struct test2
35 char a;
36 char b;
37 struct inc in[5];
40 void
41 main ()
43 struct test1 t1;
44 struct test2 t2;
45 int t1diff, t2diff;
46 FILE *fp = fopen ("testpad.h", "w");
48 if (fp == 0)
50 fprintf (stderr, "testpad: cannot open ");
51 fflush (stderr);
52 perror ("testpad.h");
53 exit (1);
56 t1diff = (char *) &t1.in[0] - (char *) &t1;
57 t2diff = (char *) &t2.in[0] - (char *) &t2;
59 if (t2diff == t1diff + 1)
60 fprintf (fp, "#define NEEDPAD\n");
61 else if (t1diff != t2diff)
62 fprintf (stderr, "Cannot determine padding for tar struct, \n\
63 will try with none.\n");
65 fclose (fp);
66 exit (0);