head 1.120; access; symbols netbsd-10-0-RELEASE:1.119 netbsd-10-0-RC6:1.119 netbsd-10-0-RC5:1.119 netbsd-10-0-RC4:1.119 netbsd-10-0-RC3:1.119 netbsd-10-0-RC2:1.119 netbsd-10-0-RC1:1.119 netbsd-10:1.119.0.6 netbsd-10-base:1.119 netbsd-9-3-RELEASE:1.118.18.1 cjep_sun2x-base1:1.119 cjep_sun2x:1.119.0.4 cjep_sun2x-base:1.119 cjep_staticlib_x-base1:1.119 netbsd-9-2-RELEASE:1.118.18.1 cjep_staticlib_x:1.119.0.2 cjep_staticlib_x-base:1.119 netbsd-9-1-RELEASE:1.118 phil-wifi-20200421:1.119 phil-wifi-20200411:1.119 is-mlppp:1.118.0.20 is-mlppp-base:1.118 phil-wifi-20200406:1.119 netbsd-8-2-RELEASE:1.118 netbsd-9-0-RELEASE:1.118 netbsd-9-0-RC2:1.118 netbsd-9-0-RC1:1.118 phil-wifi-20191119:1.118 netbsd-9:1.118.0.18 netbsd-9-base:1.118 phil-wifi-20190609:1.118 netbsd-8-1-RELEASE:1.118 netbsd-8-1-RC1:1.118 pgoyette-compat-merge-20190127:1.118 pgoyette-compat-20190127:1.118 pgoyette-compat-20190118:1.118 pgoyette-compat-1226:1.118 pgoyette-compat-1126:1.118 pgoyette-compat-1020:1.118 pgoyette-compat-0930:1.118 pgoyette-compat-0906:1.118 netbsd-7-2-RELEASE:1.115 pgoyette-compat-0728:1.118 netbsd-8-0-RELEASE:1.118 phil-wifi:1.118.0.16 phil-wifi-base:1.118 pgoyette-compat-0625:1.118 netbsd-8-0-RC2:1.118 pgoyette-compat-0521:1.118 pgoyette-compat-0502:1.118 pgoyette-compat-0422:1.118 netbsd-8-0-RC1:1.118 pgoyette-compat-0415:1.118 pgoyette-compat-0407:1.118 pgoyette-compat-0330:1.118 pgoyette-compat-0322:1.118 pgoyette-compat-0315:1.118 netbsd-7-1-2-RELEASE:1.115 pgoyette-compat:1.118.0.14 pgoyette-compat-base:1.118 netbsd-7-1-1-RELEASE:1.115 matt-nb8-mediatek:1.118.0.12 matt-nb8-mediatek-base:1.118 perseant-stdc-iso10646:1.118.0.10 perseant-stdc-iso10646-base:1.118 netbsd-8:1.118.0.8 netbsd-8-base:1.118 prg-localcount2-base3:1.118 prg-localcount2-base2:1.118 prg-localcount2-base1:1.118 prg-localcount2:1.118.0.6 prg-localcount2-base:1.118 pgoyette-localcount-20170426:1.118 bouyer-socketcan-base1:1.118 pgoyette-localcount-20170320:1.118 netbsd-7-1:1.115.0.10 netbsd-7-1-RELEASE:1.115 netbsd-7-1-RC2:1.115 netbsd-7-nhusb-base-20170116:1.115 bouyer-socketcan:1.118.0.4 bouyer-socketcan-base:1.118 pgoyette-localcount-20170107:1.118 netbsd-7-1-RC1:1.115 pgoyette-localcount-20161104:1.118 netbsd-7-0-2-RELEASE:1.115 localcount-20160914:1.118 netbsd-7-nhusb:1.115.0.8 netbsd-7-nhusb-base:1.115 pgoyette-localcount-20160806:1.118 pgoyette-localcount-20160726:1.118 pgoyette-localcount:1.118.0.2 pgoyette-localcount-base:1.118 netbsd-7-0-1-RELEASE:1.115 netbsd-7-0:1.115.0.6 netbsd-7-0-RELEASE:1.115 netbsd-7-0-RC3:1.115 netbsd-7-0-RC2:1.115 netbsd-7-0-RC1:1.115 netbsd-5-2-3-RELEASE:1.101.12.4 netbsd-5-1-5-RELEASE:1.101.12.4 netbsd-6-0-6-RELEASE:1.112 netbsd-6-1-5-RELEASE:1.112 netbsd-7:1.115.0.4 netbsd-7-base:1.115 yamt-pagecache-base9:1.115 yamt-pagecache-tag8:1.112.2.2 netbsd-6-1-4-RELEASE:1.112 netbsd-6-0-5-RELEASE:1.112 tls-earlyentropy:1.115.0.2 tls-earlyentropy-base:1.115 riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.115 riastradh-drm2-base3:1.115 netbsd-6-1-3-RELEASE:1.112 netbsd-6-0-4-RELEASE:1.112 netbsd-5-2-2-RELEASE:1.101.12.4 netbsd-5-1-4-RELEASE:1.101.12.4 netbsd-6-1-2-RELEASE:1.112 netbsd-6-0-3-RELEASE:1.112 netbsd-5-2-1-RELEASE:1.101.12.4 netbsd-5-1-3-RELEASE:1.101.12.4 netbsd-6-1-1-RELEASE:1.112 riastradh-drm2-base2:1.114 riastradh-drm2-base1:1.114 riastradh-drm2:1.114.0.4 riastradh-drm2-base:1.114 netbsd-6-1:1.112.0.10 netbsd-6-0-2-RELEASE:1.112 netbsd-6-1-RELEASE:1.112 khorben-n900:1.114.0.8 netbsd-6-1-RC4:1.112 netbsd-6-1-RC3:1.112 agc-symver:1.114.0.6 agc-symver-base:1.114 netbsd-6-1-RC2:1.112 netbsd-6-1-RC1:1.112 yamt-pagecache-base8:1.114 netbsd-5-2:1.101.12.4.0.6 netbsd-6-0-1-RELEASE:1.112 yamt-pagecache-base7:1.114 netbsd-5-2-RELEASE:1.101.12.4 netbsd-5-2-RC1:1.101.12.4 matt-nb6-plus-nbase:1.112 yamt-pagecache-base6:1.114 netbsd-6-0:1.112.0.8 netbsd-6-0-RELEASE:1.112 netbsd-6-0-RC2:1.112 tls-maxphys:1.114.0.2 tls-maxphys-base:1.115 matt-nb6-plus:1.112.0.6 matt-nb6-plus-base:1.112 netbsd-6-0-RC1:1.112 yamt-pagecache-base5:1.113 yamt-pagecache-base4:1.113 netbsd-6:1.112.0.4 netbsd-6-base:1.112 netbsd-5-1-2-RELEASE:1.101.12.4 netbsd-5-1-1-RELEASE:1.101.12.4 yamt-pagecache-base3:1.112 yamt-pagecache-base2:1.112 yamt-pagecache:1.112.0.2 yamt-pagecache-base:1.112 cherry-xenmp:1.109.0.4 cherry-xenmp-base:1.109 bouyer-quota2-nbase:1.109 bouyer-quota2:1.109.0.2 bouyer-quota2-base:1.109 matt-mips64-premerge-20101231:1.109 matt-nb5-mips64-premerge-20101231:1.101.12.2.4.1 matt-nb5-pq3:1.101.12.4.0.4 matt-nb5-pq3-base:1.101.12.4 netbsd-5-1:1.101.12.4.0.2 netbsd-5-1-RELEASE:1.101.12.4 netbsd-5-1-RC4:1.101.12.4 matt-nb5-mips64-k15:1.101.12.2.4.1 netbsd-5-1-RC3:1.101.12.4 netbsd-5-1-RC2:1.101.12.4 netbsd-5-1-RC1:1.101.12.4 netbsd-5-0-2-RELEASE:1.101.12.2.2.1 matt-nb5-mips64-premerge-20091211:1.101.12.2 matt-premerge-20091211:1.105 matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.101.12.2 matt-nb4-mips64-k7-u2a-k9b:1.101.12.2 matt-nb5-mips64-u1-k1-k5:1.101.12.2 matt-nb5-mips64:1.101.12.2.0.4 netbsd-5-0-1-RELEASE:1.101.12.2 jym-xensuspend-nbase:1.104 netbsd-5-0:1.101.12.2.0.2 netbsd-5-0-RELEASE:1.101.12.2 netbsd-5-0-RC4:1.101.12.2 netbsd-5-0-RC3:1.101.12.1 netbsd-5-0-RC2:1.101.12.1 jym-xensuspend:1.102.0.2 jym-xensuspend-base:1.104 netbsd-5-0-RC1:1.101.12.1 netbsd-5:1.101.0.12 netbsd-5-base:1.101 matt-mips64-base2:1.101 matt-mips64:1.100.0.6 mjf-devfs2:1.101.0.10 mjf-devfs2-base:1.101 netbsd-4-0-1-RELEASE:1.98 wrstuden-revivesa-base-3:1.101 wrstuden-revivesa-base-2:1.101 wrstuden-fixsa-newbase:1.98 wrstuden-revivesa-base-1:1.101 yamt-pf42-base4:1.101 yamt-pf42-base3:1.101 hpcarm-cleanup-nbase:1.101 yamt-pf42-baseX:1.101 yamt-pf42-base2:1.101 wrstuden-revivesa:1.101.0.8 wrstuden-revivesa-base:1.101 yamt-pf42:1.101.0.6 yamt-pf42-base:1.101 keiichi-mipv6:1.101.0.4 keiichi-mipv6-base:1.101 matt-armv6-nbase:1.101 matt-armv6-prevmlocking:1.100.4.1 wrstuden-fixsa-base-1:1.98 netbsd-4-0:1.98.0.6 netbsd-4-0-RELEASE:1.98 cube-autoconf:1.101.0.2 cube-autoconf-base:1.101 netbsd-4-0-RC5:1.98 netbsd-4-0-RC4:1.98 netbsd-4-0-RC3:1.98 netbsd-4-0-RC2:1.98 netbsd-4-0-RC1:1.98 matt-armv6:1.100.0.4 matt-armv6-base:1.101 matt-mips64-base:1.100 hpcarm-cleanup:1.100.0.2 hpcarm-cleanup-base:1.101 netbsd-3-1-1-RELEASE:1.83 netbsd-3-0-3-RELEASE:1.83 wrstuden-fixsa:1.98.0.4 wrstuden-fixsa-base:1.98 abandoned-netbsd-4-base:1.97 abandoned-netbsd-4:1.97.0.2 netbsd-3-1:1.83.0.6 netbsd-3-1-RELEASE:1.83 netbsd-3-0-2-RELEASE:1.83 netbsd-3-1-RC4:1.83 netbsd-3-1-RC3:1.83 netbsd-3-1-RC2:1.83 netbsd-3-1-RC1:1.83 netbsd-4:1.98.0.2 netbsd-4-base:1.98 netbsd-3-0-1-RELEASE:1.83 netbsd-3-0:1.83.0.4 netbsd-3-0-RELEASE:1.83 netbsd-3-0-RC6:1.83 netbsd-3-0-RC5:1.83 netbsd-3-0-RC4:1.83 netbsd-3-0-RC3:1.83 netbsd-3-0-RC2:1.83 netbsd-3-0-RC1:1.83 netbsd-2-0-3-RELEASE:1.73.2.1 netbsd-2-1:1.73.2.1.2.3.0.2 netbsd-2-1-RELEASE:1.73.2.1.2.3 netbsd-2-1-RC6:1.73.2.1.2.3 netbsd-2-1-RC5:1.73.2.1.2.3 netbsd-2-1-RC4:1.73.2.1.2.3 netbsd-2-1-RC3:1.73.2.1.2.3 netbsd-2-1-RC2:1.73.2.1.2.3 netbsd-2-1-RC1:1.73.2.1.2.3 netbsd-2-0-2-RELEASE:1.73.2.1 netbsd-3:1.83.0.2 netbsd-3-base:1.83 netbsd-2-0-1-RELEASE:1.73.2.1 netbsd-2:1.73.2.1.0.2 netbsd-2-base:1.73.2.1 netbsd-2-0-RELEASE:1.73.2.1 netbsd-2-0-RC5:1.73.2.1 netbsd-2-0-RC4:1.73.2.1 netbsd-2-0-RC3:1.73.2.1 netbsd-2-0-RC2:1.73.2.1 netbsd-2-0-RC1:1.73.2.1 netbsd-2-0:1.73.0.2 netbsd-2-0-base:1.73 netbsd-1-6-PATCH002-RELEASE:1.39 netbsd-1-6-PATCH002:1.39 netbsd-1-6-PATCH002-RC4:1.39 netbsd-1-6-PATCH002-RC3:1.39 netbsd-1-6-PATCH002-RC2:1.39 netbsd-1-6-PATCH002-RC1:1.39 netbsd-1-6-PATCH001:1.39 netbsd-1-6-PATCH001-RELEASE:1.39 netbsd-1-6-PATCH001-RC3:1.39 netbsd-1-6-PATCH001-RC2:1.39 netbsd-1-6-PATCH001-RC1:1.39 fvdl_fs64_base:1.57 netbsd-1-6-RELEASE:1.39 netbsd-1-6-RC3:1.39 netbsd-1-6-RC2:1.39 netbsd-1-6-RC1:1.39 netbsd-1-6:1.39.0.2 netbsd-1-6-base:1.39 netbsd-1-5-PATCH003:1.28 netbsd-1-5-PATCH002:1.28 netbsd-1-5-PATCH001:1.28 netbsd-1-5-RELEASE:1.28 netbsd-1-5-BETA2:1.28 netbsd-1-5-BETA:1.28 netbsd-1-4-PATCH003:1.19 netbsd-1-5-ALPHA2:1.28 netbsd-1-5:1.28.0.4 netbsd-1-5-base:1.28 minoura-xpg4dl:1.28.0.2 minoura-xpg4dl-base:1.28 netbsd-1-4-PATCH002:1.19 wrstuden-devbsize-19991221:1.25 wrstuden-devbsize:1.22.0.2 wrstuden-devbsize-base:1.25 comdex-fall-1999:1.25.0.2 comdex-fall-1999-base:1.25 netbsd-1-4-PATCH001:1.19 netbsd-1-4-RELEASE:1.19 netbsd-1-4:1.19.0.2 netbsd-1-4-base:1.19 netbsd-1-3-PATCH003:1.9 netbsd-1-3-PATCH003-CANDIDATE2:1.9 netbsd-1-3-PATCH003-CANDIDATE1:1.9 netbsd-1-3-PATCH003-CANDIDATE0:1.9 netbsd-1-3-PATCH002:1.9 netbsd-1-3-PATCH001:1.9 netbsd-1-3-RELEASE:1.9 netbsd-1-3-BETA:1.9 netbsd-1-3:1.9.0.2 netbsd-1-3-base:1.9 netbsd-1-2-PATCH001:1.6 netbsd-1-2-RELEASE:1.6 netbsd-1-2-BETA:1.6 netbsd-1-2-base:1.6 netbsd-1-2:1.6.0.4 netbsd-1-1-PATCH001:1.5 netbsd-1-1-RELEASE:1.5 netbsd-1-1:1.5.0.2 netbsd-1-1-base:1.5 lite-2:1.1.1.1 netbsd-1-0-PATCH06:1.4 netbsd-1-0-PATCH05:1.4 netbsd-1-0-PATCH04:1.4 netbsd-1-0-PATCH03:1.4 netbsd-1-0-PATCH02:1.4 netbsd-1-0-PATCH1:1.4 netbsd-1-0-PATCH0:1.4 netbsd-1-0-RELEASE:1.4 netbsd-1-0:1.4.0.2 netbsd-1-0-base:1.4 lite-1:1.1.1.1 CSRG:1.1.1; locks; strict; comment @ * @; 1.120 date 2023.07.20.20.09.49; author lukem; state Exp; branches; next 1.119; commitid BBSgD7xZTlBT1AxE; 1.119 date 2020.04.03.16.13.32; author joerg; state Exp; branches; next 1.118; commitid JExSym7HbmMioX2C; 1.118 date 2015.12.19.18.45.52; author christos; state Exp; branches 1.118.8.1 1.118.16.1 1.118.18.1; next 1.117; commitid dkpP2lw3c94mBANy; 1.117 date 2015.12.19.18.28.54; author christos; state Exp; branches; next 1.116; commitid M1ZZPVNBwOLwvANy; 1.116 date 2015.04.11.15.41.33; author christos; state Exp; branches; next 1.115; commitid PmQUYY9yEJTOFbhy; 1.115 date 2013.11.14.04.00.48; author christos; state Exp; branches; next 1.114; commitid heamWT6T5oSkicdx; 1.114 date 2012.08.09.11.05.59; author christos; state Exp; branches 1.114.2.1; next 1.113; 1.113 date 2012.03.20.18.42.28; author matt; state Exp; branches; next 1.112; 1.112 date 2011.08.31.16.24.54; author plunky; state Exp; branches 1.112.2.1; next 1.111; 1.111 date 2011.08.29.14.47.47; author joerg; state Exp; branches; next 1.110; 1.110 date 2011.06.18.23.07.04; author christos; state Exp; branches; next 1.109; 1.109 date 2010.08.31.03.16.06; author enami; state Exp; branches 1.109.4.1; next 1.108; 1.108 date 2010.08.25.21.36.02; author sjg; state Exp; branches; next 1.107; 1.107 date 2010.06.19.00.43.57; author christos; state Exp; branches; next 1.106; 1.106 date 2009.12.14.05.04.48; author dholland; state Exp; branches; next 1.105; 1.105 date 2009.07.13.19.05.39; author roy; state Exp; branches; next 1.104; 1.104 date 2009.04.07.19.52.35; author perry; state Exp; branches; next 1.103; 1.103 date 2009.02.14.08.10.06; author lukem; state Exp; branches; next 1.102; 1.102 date 2008.11.23.10.08.50; author dholland; state Exp; branches 1.102.2.1; next 1.101; 1.101 date 2007.10.26.16.38.12; author hira; state Exp; branches 1.101.12.1; next 1.100; 1.100 date 2007.04.23.18.40.22; author christos; state Exp; branches 1.100.4.1; next 1.99; 1.99 date 2007.01.16.19.06.41; author cbiere; state Exp; branches; next 1.98; 1.98 date 2006.10.16.00.11.22; author christos; state Exp; branches 1.98.2.1 1.98.6.1; next 1.97; 1.97 date 2006.04.16.16.20.21; author christos; state Exp; branches; next 1.96; 1.96 date 2006.04.14.16.57.01; author christos; state Exp; branches; next 1.95; 1.95 date 2006.03.19.19.06.39; author christos; state Exp; branches; next 1.94; 1.94 date 2006.03.18.05.40.28; author christos; state Exp; branches; next 1.93; 1.93 date 2006.02.11.10.43.18; author dsl; state Exp; branches; next 1.92; 1.92 date 2005.09.16.16.48.18; author christos; state Exp; branches; next 1.91; 1.91 date 2005.09.13.20.09.55; author christos; state Exp; branches; next 1.90; 1.90 date 2005.09.13.15.50.17; author christos; state Exp; branches; next 1.89; 1.89 date 2005.06.29.02.21.27; author christos; state Exp; branches; next 1.88; 1.88 date 2005.06.01.15.25.51; author lukem; state Exp; branches; next 1.87; 1.87 date 2005.05.15.02.04.30; author christos; state Exp; branches; next 1.86; 1.86 date 2005.05.07.22.27.33; author christos; state Exp; branches; next 1.85; 1.85 date 2005.05.01.02.59.28; author christos; state Exp; branches; next 1.84; 1.84 date 2005.04.24.03.39.26; author christos; state Exp; branches; next 1.83; 1.83 date 2005.02.10.17.48.33; author jmc; state Exp; branches; next 1.82; 1.82 date 2004.10.26.16.11.49; author tron; state Exp; branches; next 1.81; 1.81 date 2004.10.22.21.00.18; author jmc; state Exp; branches; next 1.80; 1.80 date 2004.10.17.18.49.55; author dsl; state Exp; branches; next 1.79; 1.79 date 2004.10.10.22.05.26; author christos; state Exp; branches; next 1.78; 1.78 date 2004.09.26.23.46.00; author christos; state Exp; branches; next 1.77; 1.77 date 2004.09.22.14.52.00; author christos; state Exp; branches; next 1.76; 1.76 date 2004.06.20.22.20.14; author jmc; state Exp; branches; next 1.75; 1.75 date 2004.06.19.02.27.00; author christos; state Exp; branches; next 1.74; 1.74 date 2004.05.11.17.12.26; author christos; state Exp; branches; next 1.73; 1.73 date 2004.02.20.05.16.54; author uebayasi; state Exp; branches 1.73.2.1; next 1.72; 1.72 date 2004.02.06.18.59.14; author christos; state Exp; branches; next 1.71; 1.71 date 2004.01.05.23.23.32; author jmmv; state Exp; branches; next 1.70; 1.70 date 2004.01.05.17.27.46; author jmmv; state Exp; branches; next 1.69; 1.69 date 2003.10.27.00.12.41; author lukem; state Exp; branches; next 1.68; 1.68 date 2003.10.21.02.08.14; author fvdl; state Exp; branches; next 1.67; 1.67 date 2003.10.13.07.41.22; author agc; state Exp; branches; next 1.66; 1.66 date 2003.08.07.09.05.21; author agc; state Exp; branches; next 1.65; 1.65 date 2003.07.08.06.00.48; author simonb; state Exp; branches; next 1.64; 1.64 date 2003.04.08.15.13.10; author christos; state Exp; branches; next 1.63; 1.63 date 2003.03.31.20.10.08; author christos; state Exp; branches; next 1.62; 1.62 date 2003.02.25.13.37.00; author wiz; state Exp; branches; next 1.61; 1.61 date 2003.02.02.10.21.14; author wiz; state Exp; branches; next 1.60; 1.60 date 2003.01.19.01.13.46; author wiz; state Exp; branches; next 1.59; 1.59 date 2003.01.15.21.56.46; author kristerw; state Exp; branches; next 1.58; 1.58 date 2003.01.09.17.26.21; author christos; state Exp; branches; next 1.57; 1.57 date 2002.12.08.01.35.13; author mrg; state Exp; branches; next 1.56; 1.56 date 2002.11.27.18.40.34; author grant; state Exp; branches; next 1.55; 1.55 date 2002.10.18.13.45.05; author christos; state Exp; branches; next 1.54; 1.54 date 2002.10.17.00.42.02; author christos; state Exp; branches; next 1.53; 1.53 date 2002.10.16.23.37.49; author soren; state Exp; branches; next 1.52; 1.52 date 2002.10.16.23.22.59; author soren; state Exp; branches; next 1.51; 1.51 date 2002.10.16.22.38.36; author soren; state Exp; branches; next 1.50; 1.50 date 2002.10.16.21.45.31; author christos; state Exp; branches; next 1.49; 1.49 date 2002.10.16.18.53.40; author christos; state Exp; branches; next 1.48; 1.48 date 2002.10.16.03.46.08; author christos; state Exp; branches; next 1.47; 1.47 date 2002.10.15.16.16.29; author christos; state Exp; branches; next 1.46; 1.46 date 2002.10.15.14.58.53; author christos; state Exp; branches; next 1.45; 1.45 date 2002.10.15.14.51.04; author christos; state Exp; branches; next 1.44; 1.44 date 2002.10.14.15.04.41; author soren; state Exp; branches; next 1.43; 1.43 date 2002.10.13.17.23.40; author christos; state Exp; branches; next 1.42; 1.42 date 2002.10.13.11.31.02; author mrg; state Exp; branches; next 1.41; 1.41 date 2002.10.13.00.32.09; author mrg; state Exp; branches; next 1.40; 1.40 date 2002.10.12.15.39.29; author christos; state Exp; branches; next 1.39; 1.39 date 2002.02.02.12.34.39; author lukem; state Exp; branches 1.39.2.1; next 1.38; 1.38 date 2002.01.31.22.43.35; author tv; state Exp; branches; next 1.37; 1.37 date 2002.01.29.10.20.29; author tv; state Exp; branches; next 1.36; 1.36 date 2002.01.26.02.22.54; author lukem; state Exp; branches; next 1.35; 1.35 date 2002.01.24.07.45.33; author lukem; state Exp; branches; next 1.34; 1.34 date 2001.10.25.08.51.51; author lukem; state Exp; branches; next 1.33; 1.33 date 2001.10.25.05.33.33; author lukem; state Exp; branches; next 1.32; 1.32 date 2001.07.22.13.33.58; author wiz; state Exp; branches; next 1.31; 1.31 date 2000.07.04.17.28.47; author thorpej; state Exp; branches; next 1.30; 1.30 date 2000.07.04.17.24.47; author thorpej; state Exp; branches; next 1.29; 1.29 date 2000.07.04.17.17.49; author thorpej; state Exp; branches; next 1.28; 1.28 date 2000.04.14.05.52.58; author simonb; state Exp; branches; next 1.27; 1.27 date 2000.03.30.17.53.04; author thorpej; state Exp; branches; next 1.26; 1.26 date 2000.02.17.03.12.25; author itohy; state Exp; branches; next 1.25; 1.25 date 99.11.07.15.57.31; author mycroft; state Exp; branches 1.25.2.1; next 1.24; 1.24 date 99.11.01.01.35.59; author mrg; state Exp; branches; next 1.23; 1.23 date 99.10.22.20.59.08; author is; state Exp; branches; next 1.22; 1.22 date 99.08.24.08.02.27; author tron; state Exp; branches 1.22.2.1; next 1.21; 1.21 date 99.08.24.08.00.03; author tron; state Exp; branches; next 1.20; 1.20 date 99.08.24.07.57.06; author tron; state Exp; branches; next 1.19; 1.19 date 99.03.07.01.03.32; author mycroft; state Exp; branches; next 1.18; 1.18 date 99.02.07.00.56.55; author tv; state Exp; branches; next 1.17; 1.17 date 99.02.02.23.42.41; author tv; state Exp; branches; next 1.16; 1.16 date 99.02.02.23.31.52; author tv; state Exp; branches; next 1.15; 1.15 date 99.01.20.14.45.09; author mrg; state Exp; branches; next 1.14; 1.14 date 98.07.28.17.44.24; author mycroft; state Exp; branches; next 1.13; 1.13 date 98.07.28.11.41.50; author mycroft; state Exp; branches; next 1.12; 1.12 date 98.07.28.05.31.26; author mycroft; state Exp; branches; next 1.11; 1.11 date 98.06.09.10.53.55; author mrg; state Exp; branches; next 1.10; 1.10 date 98.03.06.09.13.02; author mrg; state Exp; branches; next 1.9; 1.9 date 97.09.14.14.54.34; author lukem; state Exp; branches; next 1.8; 1.8 date 97.07.20.20.32.35; author christos; state Exp; branches; next 1.7; 1.7 date 97.01.11.02.06.41; author tls; state Exp; branches; next 1.6; 1.6 date 96.03.26.23.54.18; author mrg; state Exp; branches; next 1.5; 1.5 date 95.03.21.09.07.30; author cgd; state Exp; branches; next 1.4; 1.4 date 94.06.14.01.16.10; author jtc; state Exp; branches; next 1.3; 1.3 date 94.06.14.00.42.47; author mycroft; state Exp; branches; next 1.2; 1.2 date 94.06.13.16.34.06; author jtc; state Exp; branches; next 1.1; 1.1 date 94.06.13.16.13.36; author jtc; state Exp; branches 1.1.1.1; next ; 1.118.8.1 date 2021.05.07.17.40.31; author martin; state Exp; branches; next ; commitid 9cBlF3CdlJ2Y2fSC; 1.118.16.1 date 2020.04.08.14.03.04; author martin; state Exp; branches; next 1.118.16.2; commitid Qli2aW9E74UFuA3C; 1.118.16.2 date 2020.04.21.18.41.05; author martin; state dead; branches; next 1.118.16.3; commitid 86tA4aEmdr3VCh5C; 1.118.16.3 date 2020.04.21.19.37.33; author martin; state Exp; branches; next ; commitid x6IB64bYH9UmWh5C; 1.118.18.1 date 2021.04.30.14.07.02; author martin; state Exp; branches; next ; commitid VxiDd550OItG5kRC; 1.114.2.1 date 2014.08.19.23.45.11; author tls; state Exp; branches; next ; commitid jTnpym9Qu0o4R1Nx; 1.112.2.1 date 2012.04.17.00.01.37; author yamt; state Exp; branches; next 1.112.2.2; 1.112.2.2 date 2012.10.30.18.46.07; author yamt; state Exp; branches; next 1.112.2.3; 1.112.2.3 date 2014.05.22.11.26.23; author yamt; state Exp; branches; next ; commitid OarWMuV9WFtzGwBx; 1.109.4.1 date 2011.06.23.14.17.47; author cherry; state Exp; branches; next ; 1.102.2.1 date 2009.05.13.19.15.50; author jym; state Exp; branches; next ; 1.101.12.1 date 2008.11.23.21.26.50; author riz; state Exp; branches; next 1.101.12.2; 1.101.12.2 date 2009.04.13.20.42.59; author snj; state Exp; branches 1.101.12.2.2.1 1.101.12.2.4.1; next 1.101.12.3; 1.101.12.3 date 2009.08.14.20.32.21; author snj; state Exp; branches; next 1.101.12.4; 1.101.12.4 date 2010.01.30.19.17.17; author snj; state Exp; branches; next ; 1.101.12.2.2.1 date 2009.08.14.20.39.03; author snj; state Exp; branches; next ; 1.101.12.2.4.1 date 2010.04.21.05.15.28; author matt; state Exp; branches; next ; 1.100.4.1 date 2007.11.06.23.07.18; author matt; state Exp; branches; next ; 1.98.2.1 date 2009.08.25.18.07.09; author snj; state Exp; branches; next ; 1.98.6.1 date 2009.08.25.18.11.15; author snj; state Exp; branches; next ; 1.73.2.1 date 2004.06.22.07.28.58; author tron; state Exp; branches 1.73.2.1.2.1; next ; 1.73.2.1.2.1 date 2005.01.30.13.20.27; author he; state Exp; branches; next 1.73.2.1.2.2; 1.73.2.1.2.2 date 2005.05.29.23.18.53; author riz; state Exp; branches; next 1.73.2.1.2.3; 1.73.2.1.2.3 date 2005.07.23.17.32.16; author snj; state Exp; branches; next ; 1.39.2.1 date 2004.04.07.06.58.00; author jmc; state Exp; branches; next 1.39.2.2; 1.39.2.2 date 2004.06.16.01.27.38; author jmc; state Exp; branches; next ; 1.25.2.1 date 99.11.07.15.57.31; author mycroft; state dead; branches; next 1.25.2.2; 1.25.2.2 date 99.11.07.15.57.32; author mycroft; state Exp; branches; next ; 1.22.2.1 date 99.12.27.18.27.08; author wrstuden; state Exp; branches; next ; 1.1.1.1 date 94.06.13.16.13.37; author jtc; state Exp; branches; next ; desc @@ 1.120 log @pax: need for ffs() Fixes warning as host tool on NetBSD 9.99 @ text @/* $NetBSD: options.c,v 1.119 2020/04/03 16:13:32 joerg Exp $ */ /*- * Copyright (c) 1992 Keith Muller. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if HAVE_NBTOOL_CONFIG_H #include "nbtool_config.h" #endif #include #if !defined(lint) #if 0 static char sccsid[] = "@@(#)options.c 8.2 (Berkeley) 4/18/94"; #else __RCSID("$NetBSD: options.c,v 1.119 2020/04/03 16:13:32 joerg Exp $"); #endif #endif /* not lint */ #include #include #include #include #include #include #if HAVE_NBTOOL_CONFIG_H #include "compat_getopt.h" #else #include #endif #include #include #include #include #include #include #include #include #include #include "pax.h" #include "options.h" #include "cpio.h" #include "tar.h" #include "extern.h" #ifndef SMALL #include "mtree.h" #endif /* SMALL */ char *chdname; #if !HAVE_NBTOOL_CONFIG_H int do_chroot; #endif /* * Routines which handle command line options */ struct stat tst; /* Timestamp to set if non-0 */ static int nopids; /* tar mode: suppress "pids" for -p option */ static char flgch[] = FLGCH; /* list of all possible flags (pax) */ static OPLIST *ophead = NULL; /* head for format specific options -x */ static OPLIST *optail = NULL; /* option tail */ static int opt_add(const char *); static int no_op(void); static void printflg(unsigned int); static int c_frmt(const void *, const void *); static off_t str_offt(char *); static char *get_line(FILE *fp); #ifndef SMALL static int set_tstamp(const char *, struct stat *); #endif static void pax_options(int, char **); __dead static void pax_usage(void); static void tar_options(int, char **); __dead static void tar_usage(void); #ifndef NO_CPIO static void cpio_options(int, char **); __dead static void cpio_usage(void); #endif /* errors from get_line */ #define GETLINE_FILE_CORRUPT 1 #define GETLINE_OUT_OF_MEM 2 static int get_line_error; #define BZIP2_CMD "bzip2" /* command to run as bzip2 */ #define GZIP_CMD "gzip" /* command to run as gzip */ #define XZ_CMD "xz" /* command to run as xz */ #define COMPRESS_CMD "compress" /* command to run as compress */ /* * Long options. */ #define OPT_USE_COMPRESS_PROGRAM 0 #define OPT_CHECKPOINT 1 #define OPT_UNLINK 2 #define OPT_HELP 3 #define OPT_ATIME_PRESERVE 4 #define OPT_IGNORE_FAILED_READ 5 #define OPT_REMOVE_FILES 6 #define OPT_NULL 7 #define OPT_TOTALS 8 #define OPT_VERSION 9 #define OPT_EXCLUDE 10 #define OPT_BLOCK_COMPRESS 11 #define OPT_NORECURSE 12 #define OPT_FORCE_LOCAL 13 #define OPT_INSECURE 14 #define OPT_STRICT 15 #define OPT_SPARSE 16 #define OPT_XZ 17 #define OPT_GNU 18 #define OPT_TIMESTAMP 19 #if !HAVE_NBTOOL_CONFIG_H #define OPT_CHROOT 20 #endif /* * Format specific routine table - MUST BE IN SORTED ORDER BY NAME * (see pax.h for description of each function) * * name, blksz, hdsz, udev, hlk, blkagn, inhead, id, st_read, * read, end_read, st_write, write, end_write, trail, * subtrail, rd_data, wr_data, options */ FSUB fsub[] = { #ifndef NO_CPIO /* 0: OLD BINARY CPIO */ { "bcpio", 5120, sizeof(HD_BCPIO), 1, 0, 0, 1, bcpio_id, cpio_strd, bcpio_rd, bcpio_endrd, cpio_stwr, bcpio_wr, cpio_endwr, NULL, cpio_subtrail, rd_wrfile, wr_rdfile, bad_opt }, /* 1: OLD OCTAL CHARACTER CPIO */ { "cpio", 5120, sizeof(HD_CPIO), 1, 0, 0, 1, cpio_id, cpio_strd, cpio_rd, cpio_endrd, cpio_stwr, cpio_wr, cpio_endwr, NULL, cpio_subtrail, rd_wrfile, wr_rdfile, bad_opt }, /* 2: SVR4 HEX CPIO */ { "sv4cpio", 5120, sizeof(HD_VCPIO), 1, 0, 0, 1, vcpio_id, cpio_strd, vcpio_rd, vcpio_endrd, cpio_stwr, vcpio_wr, cpio_endwr, NULL, cpio_subtrail, rd_wrfile, wr_rdfile, bad_opt }, /* 3: SVR4 HEX CPIO WITH CRC */ { "sv4crc", 5120, sizeof(HD_VCPIO), 1, 0, 0, 1, crc_id, crc_strd, vcpio_rd, vcpio_endrd, crc_stwr, vcpio_wr, cpio_endwr, NULL, cpio_subtrail, rd_wrfile, wr_rdfile, bad_opt }, #endif /* 4: OLD TAR */ { "tar", 10240, BLKMULT, 0, 1, BLKMULT, 0, tar_id, no_op, tar_rd, tar_endrd, no_op, tar_wr, tar_endwr, tar_trail, NULL, rd_wrfile, wr_rdfile, tar_opt }, /* 5: POSIX USTAR */ { "ustar", 10240, BLKMULT, 0, 1, BLKMULT, 0, ustar_id, ustar_strd, ustar_rd, tar_endrd, ustar_stwr, ustar_wr, tar_endwr, tar_trail, NULL, rd_wrfile, wr_rdfile, bad_opt } }; #ifndef NO_CPIO #define F_BCPIO 0 /* old binary cpio format */ #define F_CPIO 1 /* old octal character cpio format */ #define F_SV4CPIO 2 /* SVR4 hex cpio format */ #define F_SV4CRC 3 /* SVR4 hex with crc cpio format */ #define F_TAR 4 /* old V7 UNIX tar format */ #define F_USTAR 5 /* ustar format */ #else #define F_TAR 0 /* old V7 UNIX tar format */ #define F_USTAR 1 /* ustar format */ #endif #define DEFLT F_USTAR /* default write format from list above */ /* * ford is the archive search order used by get_arc() to determine what kind * of archive we are dealing with. This helps to properly id archive formats * some formats may be subsets of others.... */ int ford[] = {F_USTAR, F_TAR, #ifndef NO_CPIO F_SV4CRC, F_SV4CPIO, F_CPIO, F_BCPIO, #endif -1}; /* * filename record separator */ int sep = '\n'; /* * Do we have -C anywhere? */ int havechd = 0; /* * options() * figure out if we are pax, tar or cpio. Call the appropriate options * parser */ void options(int argc, char **argv) { /* * Are we acting like pax, tar or cpio (based on argv[0]) */ if ((argv0 = strrchr(argv[0], '/')) != NULL) argv0++; else argv0 = argv[0]; if (strstr(argv0, NM_TAR)) { argv0 = NM_TAR; tar_options(argc, argv); #ifndef NO_CPIO } else if (strstr(argv0, NM_CPIO)) { argv0 = NM_CPIO; cpio_options(argc, argv); #endif } else { argv0 = NM_PAX; pax_options(argc, argv); } } struct option pax_longopts[] = { { "insecure", no_argument, 0, OPT_INSECURE }, { "force-local", no_argument, 0, OPT_FORCE_LOCAL }, { "use-compress-program", required_argument, 0, OPT_USE_COMPRESS_PROGRAM }, { "xz", no_argument, 0, OPT_XZ }, { "gnu", no_argument, 0, OPT_GNU }, { "timestamp", required_argument, 0, OPT_TIMESTAMP }, { 0, 0, 0, 0 }, }; /* * pax_options() * look at the user specified flags. set globals as required and check if * the user specified a legal set of flags. If not, complain and exit */ static void pax_options(int argc, char **argv) { int c; size_t i; u_int64_t flg = 0; u_int64_t bflg = 0; char *pt; FSUB tmp; /* * process option flags */ while ((c = getopt_long(argc, argv, "0ab:cdf:ijklno:p:rs:tuvwx:zAB:DE:G:HLMN:OPT:U:VXYZ", pax_longopts, NULL)) != -1) { switch (c) { case '0': sep = '\0'; break; case 'a': /* * append */ flg |= AF; break; case 'b': /* * specify blocksize */ flg |= BF; if ((wrblksz = (int)str_offt(optarg)) <= 0) { tty_warn(1, "Invalid block size %s", optarg); pax_usage(); } break; case 'c': /* * inverse match on patterns */ cflag = 1; flg |= CF; break; case 'd': /* * match only dir on extract, not the subtree at dir */ dflag = 1; flg |= DF; break; case 'f': /* * filename where the archive is stored */ arcname = optarg; flg |= FF; break; case 'i': /* * interactive file rename */ iflag = 1; flg |= IF; break; case 'j': /* * pass through bzip2 */ gzip_program = BZIP2_CMD; break; case 'k': /* * do not clobber files that exist */ kflag = 1; flg |= KF; break; case 'l': /* * try to link src to dest with copy (-rw) */ lflag = 1; flg |= LF; break; case 'n': /* * select first match for a pattern only */ nflag = 1; flg |= NF; break; case 'o': /* * pass format specific options */ flg |= OF; if (opt_add(optarg) < 0) pax_usage(); break; case 'p': /* * specify file characteristic options */ for (pt = optarg; *pt != '\0'; ++pt) { switch(*pt) { case 'a': /* * do not preserve access time */ patime = 0; break; case 'e': /* * preserve user id, group id, file * mode, access/modification times * and file flags. */ pids = 1; pmode = 1; patime = 1; pmtime = 1; pfflags = 1; break; #if 0 case 'f': /* * do not preserve file flags */ pfflags = 0; break; #endif case 'm': /* * do not preserve modification time */ pmtime = 0; break; case 'o': /* * preserve uid/gid */ pids = 1; break; case 'p': /* * preserve file mode bits */ pmode = 1; break; default: tty_warn(1, "Invalid -p string: %c", *pt); pax_usage(); break; } } flg |= PF; break; case 'r': /* * read the archive */ flg |= RF; break; case 's': /* * file name substitution name pattern */ if (rep_add(optarg) < 0) { pax_usage(); break; } flg |= SF; break; case 't': /* * preserve access time on filesystem nodes we read */ tflag = 1; flg |= TF; break; case 'u': /* * ignore those older files */ uflag = 1; flg |= UF; break; case 'v': /* * verbose operation mode */ vflag = 1; flg |= VF; break; case 'w': /* * write an archive */ flg |= WF; break; case 'x': /* * specify an archive format on write */ tmp.name = optarg; frmt = (FSUB *)bsearch((void *)&tmp, (void *)fsub, sizeof(fsub)/sizeof(FSUB), sizeof(FSUB), c_frmt); if (frmt != NULL) { flg |= XF; break; } tty_warn(1, "Unknown -x format: %s", optarg); (void)fputs("pax: Known -x formats are:", stderr); for (i = 0; i < (sizeof(fsub)/sizeof(FSUB)); ++i) (void)fprintf(stderr, " %s", fsub[i].name); (void)fputs("\n\n", stderr); pax_usage(); break; case 'z': /* * use gzip. Non standard option. */ gzip_program = GZIP_CMD; break; case 'A': Aflag = 1; flg |= CAF; break; case 'B': /* * non-standard option on number of bytes written on a * single archive volume. */ if ((wrlimit = str_offt(optarg)) <= 0) { tty_warn(1, "Invalid write limit %s", optarg); pax_usage(); } if (wrlimit % BLKMULT) { tty_warn(1, "Write limit is not a %d byte multiple", BLKMULT); pax_usage(); } flg |= CBF; break; case 'D': /* * On extraction check file inode change time before the * modification of the file name. Non standard option. */ Dflag = 1; flg |= CDF; break; case 'E': /* * non-standard limit on read faults * 0 indicates stop after first error, values * indicate a limit, "none" try forever */ flg |= CEF; if (strcmp(none, optarg) == 0) maxflt = -1; else if ((maxflt = atoi(optarg)) < 0) { tty_warn(1, "Error count value must be positive"); pax_usage(); } break; case 'G': /* * non-standard option for selecting files within an * archive by group (gid or name) */ if (grp_add(optarg) < 0) { pax_usage(); break; } flg |= CGF; break; case 'H': /* * follow command line symlinks only */ Hflag = 1; flg |= CHF; break; case 'L': /* * follow symlinks */ Lflag = 1; flg |= CLF; break; #ifdef SMALL case 'M': case 'N': tty_warn(1, "Support for -%c is not compiled in", c); exit(1); #else /* !SMALL */ case 'M': /* * Treat list of filenames on stdin as an * mtree(8) specfile. Non standard option. */ Mflag = 1; flg |= CMF; break; case 'N': /* * Use alternative directory for user db lookups. */ if (!setup_getid(optarg)) { tty_warn(1, "Unable to use user and group databases in `%s'", optarg); pax_usage(); } break; #endif /* !SMALL */ case 'O': /* * Force one volume. Non standard option. */ force_one_volume = 1; break; case 'P': /* * do NOT follow symlinks (default) */ Lflag = 0; flg |= CPF; break; case 'T': /* * non-standard option for selecting files within an * archive by modification time range (lower,upper) */ if (trng_add(optarg) < 0) { pax_usage(); break; } flg |= CTF; break; case 'U': /* * non-standard option for selecting files within an * archive by user (uid or name) */ if (usr_add(optarg) < 0) { pax_usage(); break; } flg |= CUF; break; case 'V': /* * somewhat verbose operation mode (no listing) */ Vflag = 1; flg |= VSF; break; case 'X': /* * do not pass over mount points in the file system */ Xflag = 1; flg |= CXF; break; case 'Y': /* * On extraction check file inode change time after the * modification of the file name. Non standard option. */ Yflag = 1; flg |= CYF; break; case 'Z': /* * On extraction check modification time after the * modification of the file name. Non standard option. */ Zflag = 1; flg |= CZF; break; case OPT_INSECURE: secure = 0; break; case OPT_FORCE_LOCAL: forcelocal = 1; break; case OPT_USE_COMPRESS_PROGRAM: gzip_program = optarg; break; case OPT_XZ: gzip_program = XZ_CMD; break; case OPT_GNU: is_gnutar = 1; break; #ifndef SMALL case OPT_TIMESTAMP: if (set_tstamp(optarg, &tst) == -1) { tty_warn(1, "Invalid timestamp `%s'", optarg); tar_usage(); } break; #endif case '?': default: pax_usage(); break; } } /* * figure out the operation mode of pax read,write,extract,copy,append * or list. check that we have not been given a bogus set of flags * for the operation mode. */ if (ISLIST(flg)) { act = LIST; listf = stdout; bflg = flg & BDLIST; } else if (ISEXTRACT(flg)) { act = EXTRACT; bflg = flg & BDEXTR; } else if (ISARCHIVE(flg)) { act = ARCHIVE; bflg = flg & BDARCH; } else if (ISAPPND(flg)) { act = APPND; bflg = flg & BDARCH; } else if (ISCOPY(flg)) { act = COPY; bflg = flg & BDCOPY; } else pax_usage(); if (bflg) { printflg(flg); pax_usage(); } /* * if we are writing (ARCHIVE) we use the default format if the user * did not specify a format. when we write during an APPEND, we will * adopt the format of the existing archive if none was supplied. */ if (!(flg & XF) && (act == ARCHIVE)) frmt = &(fsub[DEFLT]); /* * process the args as they are interpreted by the operation mode */ switch (act) { case LIST: case EXTRACT: for (; optind < argc; optind++) if (pat_add(argv[optind], NULL, 0) < 0) pax_usage(); break; case COPY: if (optind >= argc) { tty_warn(0, "Destination directory was not supplied"); pax_usage(); } --argc; dirptr = argv[argc]; if (mkpath(dirptr) < 0) exit(1); /* FALLTHROUGH */ case ARCHIVE: case APPND: for (; optind < argc; optind++) if (ftree_add(argv[optind], 0) < 0) pax_usage(); /* * no read errors allowed on updates/append operation! */ maxflt = 0; break; } } /* * tar_options() * look at the user specified flags. set globals as required and check if * the user specified a legal set of flags. If not, complain and exit */ struct option tar_longopts[] = { { "block-size", required_argument, 0, 'b' }, { "bunzip2", no_argument, 0, 'j' }, { "bzip2", no_argument, 0, 'j' }, { "create", no_argument, 0, 'c' }, /* F */ /* -e -- no corresponding long option */ { "file", required_argument, 0, 'f' }, { "dereference", no_argument, 0, 'h' }, { "keep-old-files", no_argument, 0, 'k' }, { "one-file-system", no_argument, 0, 'l' }, { "modification-time", no_argument, 0, 'm' }, { "old-archive", no_argument, 0, 'o' }, { "portability", no_argument, 0, 'o' }, { "same-permissions", no_argument, 0, 'p' }, { "preserve-permissions", no_argument, 0, 'p' }, { "preserve", no_argument, 0, 'p' }, { "fast-read", no_argument, 0, 'q' }, { "append", no_argument, 0, 'r' }, /* F */ { "update", no_argument, 0, 'u' }, /* F */ { "list", no_argument, 0, 't' }, /* F */ { "verbose", no_argument, 0, 'v' }, { "interactive", no_argument, 0, 'w' }, { "confirmation", no_argument, 0, 'w' }, { "extract", no_argument, 0, 'x' }, /* F */ { "get", no_argument, 0, 'x' }, /* F */ { "gzip", no_argument, 0, 'z' }, { "gunzip", no_argument, 0, 'z' }, { "read-full-blocks", no_argument, 0, 'B' }, { "directory", required_argument, 0, 'C' }, { "xz", no_argument, 0, 'J' }, { "to-stdout", no_argument, 0, 'O' }, { "absolute-paths", no_argument, 0, 'P' }, { "sparse", no_argument, 0, 'S' }, { "files-from", required_argument, 0, 'T' }, { "summary", no_argument, 0, 'V' }, { "stats", no_argument, 0, 'V' }, { "exclude-from", required_argument, 0, 'X' }, { "compress", no_argument, 0, 'Z' }, { "uncompress", no_argument, 0, 'Z' }, { "strict", no_argument, 0, OPT_STRICT }, { "atime-preserve", no_argument, 0, OPT_ATIME_PRESERVE }, { "unlink", no_argument, 0, OPT_UNLINK }, { "use-compress-program", required_argument, 0, OPT_USE_COMPRESS_PROGRAM }, { "force-local", no_argument, 0, OPT_FORCE_LOCAL }, { "insecure", no_argument, 0, OPT_INSECURE }, { "exclude", required_argument, 0, OPT_EXCLUDE }, { "no-recursion", no_argument, 0, OPT_NORECURSE }, #if !HAVE_NBTOOL_CONFIG_H { "chroot", no_argument, 0, OPT_CHROOT }, #endif { "timestamp", required_argument, 0, OPT_TIMESTAMP }, #if 0 /* Not implemented */ { "catenate", no_argument, 0, 'A' }, /* F */ { "concatenate", no_argument, 0, 'A' }, /* F */ { "diff", no_argument, 0, 'd' }, /* F */ { "compare", no_argument, 0, 'd' }, /* F */ { "checkpoint", no_argument, 0, OPT_CHECKPOINT }, { "help", no_argument, 0, OPT_HELP }, { "info-script", required_argument, 0, 'F' }, { "new-volume-script", required_argument, 0, 'F' }, { "incremental", no_argument, 0, 'G' }, { "listed-incremental", required_argument, 0, 'g' }, { "ignore-zeros", no_argument, 0, 'i' }, { "ignore-failed-read", no_argument, 0, OPT_IGNORE_FAILED_READ }, { "starting-file", no_argument, 0, 'K' }, { "tape-length", required_argument, 0, 'L' }, { "multi-volume", no_argument, 0, 'M' }, { "after-date", required_argument, 0, 'N' }, { "newer", required_argument, 0, 'N' }, { "record-number", no_argument, 0, 'R' }, { "remove-files", no_argument, 0, OPT_REMOVE_FILES }, { "same-order", no_argument, 0, 's' }, { "preserve-order", no_argument, 0, 's' }, { "null", no_argument, 0, OPT_NULL }, { "totals", no_argument, 0, OPT_TOTALS }, { "volume-name", required_argument, 0, 'V' }, /* XXX */ { "label", required_argument, 0, 'V' }, /* XXX */ { "version", no_argument, 0, OPT_VERSION }, { "verify", no_argument, 0, 'W' }, { "block-compress", no_argument, 0, OPT_BLOCK_COMPRESS }, #endif { 0, 0, 0, 0 }, }; static void tar_set_action(int op) { if (act != ERROR && act != op) tar_usage(); act = op; } static void tar_options(int argc, char **argv) { int c; int fstdin = 0; int Oflag = 0; int nincfiles = 0; int incfiles_max = 0; struct incfile { char *file; char *dir; }; struct incfile *incfiles = NULL; /* * Set default values. */ rmleadslash = 1; is_gnutar = 1; /* * process option flags */ while ((c = getoldopt(argc, argv, "+b:cef:hjklmopqrs:tuvwxzBC:HI:JOPST:X:Z014578", tar_longopts, NULL)) != -1) { switch(c) { case 'b': /* * specify blocksize in 512-byte blocks */ if ((wrblksz = (int)str_offt(optarg)) <= 0) { tty_warn(1, "Invalid block size %s", optarg); tar_usage(); } wrblksz *= 512; /* XXX - check for int oflow */ break; case 'c': /* * create an archive */ tar_set_action(ARCHIVE); break; case 'e': /* * stop after first error */ maxflt = 0; break; case 'f': /* * filename where the archive is stored */ if ((optarg[0] == '-') && (optarg[1]== '\0')) { /* * treat a - as stdin */ fstdin = 1; arcname = NULL; break; } fstdin = 0; arcname = optarg; break; case 'h': /* * follow symlinks */ Lflag = 1; break; case 'j': /* * pass through bzip2. not a standard option */ gzip_program = BZIP2_CMD; break; case 'k': /* * do not clobber files that exist */ kflag = 1; break; case 'l': /* * do not pass over mount points in the file system */ Xflag = 1; break; case 'm': /* * do not preserve modification time */ pmtime = 0; break; case 'o': /* * This option does several things based on whether * this is a create or extract operation. */ if (act == ARCHIVE) { /* GNU tar: write V7 format archives. */ Oflag = 1; /* 4.2BSD: don't add directory entries. */ if (opt_add("write_opt=nodir") < 0) tar_usage(); } else { /* SUS: don't preserve owner/group. */ pids = 0; nopids = 1; } break; case 'p': /* * preserve user id, group id, file * mode, access/modification times */ if (!nopids) pids = 1; pmode = 1; patime = 1; pmtime = 1; break; case 'q': /* * select first match for a pattern only */ nflag = 1; break; case 'r': case 'u': /* * append to the archive */ tar_set_action(APPND); break; case 's': /* * file name substitution name pattern */ if (rep_add(optarg) < 0) { tar_usage(); break; } break; case 't': /* * list contents of the tape */ tar_set_action(LIST); break; case 'v': /* * verbose operation mode */ vflag = 1; break; case 'w': /* * interactive file rename */ iflag = 1; break; case 'x': /* * extract an archive, preserving mode, * and mtime if possible. */ tar_set_action(EXTRACT); pmtime = 1; break; case 'z': /* * use gzip. Non standard option. */ gzip_program = GZIP_CMD; break; case 'B': /* * Nothing to do here, this is pax default */ break; case 'C': havechd++; chdname = optarg; break; case 'H': /* * follow command line symlinks only */ Hflag = 1; break; case 'I': case 'T': if (++nincfiles > incfiles_max) { incfiles_max = nincfiles + 3; incfiles = realloc(incfiles, sizeof(*incfiles) * incfiles_max); if (incfiles == NULL) { tty_warn(0, "Unable to allocate space " "for option list"); exit(1); } } incfiles[nincfiles - 1].file = optarg; incfiles[nincfiles - 1].dir = chdname; break; case 'J': gzip_program = XZ_CMD; break; case 'O': Oflag = 1; break; case 'P': /* * do not remove leading '/' from pathnames */ rmleadslash = 0; Aflag = 1; break; case 'S': /* do nothing; we already generate sparse files */ break; case 'V': /* * semi-verbose operation mode (no listing) */ Vflag = 1; break; case 'X': /* * GNU tar compat: exclude the files listed in optarg */ if (tar_gnutar_X_compat(optarg) != 0) tar_usage(); break; case 'Z': /* * use compress. */ gzip_program = COMPRESS_CMD; break; case '0': arcname = DEV_0; break; case '1': arcname = DEV_1; break; case '4': arcname = DEV_4; break; case '5': arcname = DEV_5; break; case '7': arcname = DEV_7; break; case '8': arcname = DEV_8; break; case OPT_ATIME_PRESERVE: patime = 1; break; case OPT_UNLINK: /* Just ignore -- we always unlink first. */ break; case OPT_USE_COMPRESS_PROGRAM: gzip_program = optarg; break; case OPT_FORCE_LOCAL: forcelocal = 1; break; case OPT_INSECURE: secure = 0; break; case OPT_STRICT: /* disable gnu extensions */ is_gnutar = 0; break; case OPT_EXCLUDE: if (tar_gnutar_minus_minus_exclude(optarg) != 0) tar_usage(); break; case OPT_NORECURSE: dflag = 1; break; #if !HAVE_NBTOOL_CONFIG_H case OPT_CHROOT: do_chroot = 1; break; #endif #ifndef SMALL case OPT_TIMESTAMP: if (set_tstamp(optarg, &tst) == -1) { tty_warn(1, "Invalid timestamp `%s'", optarg); tar_usage(); } break; #endif default: tar_usage(); break; } } argc -= optind; argv += optind; /* Tar requires an action. */ if (act == ERROR) tar_usage(); /* Traditional tar behaviour (pax uses stderr unless in list mode) */ if (fstdin == 1 && act == ARCHIVE) listf = stderr; else listf = stdout; /* Traditional tar behaviour (pax wants to read file list from stdin) */ if ((act == ARCHIVE || act == APPND) && argc == 0 && nincfiles == 0) exit(0); /* * if we are writing (ARCHIVE) specify tar, otherwise run like pax * (unless -o specified) */ if (act == ARCHIVE || act == APPND) frmt = &(fsub[Oflag ? F_TAR : F_USTAR]); else if (Oflag) { if (act == EXTRACT) to_stdout = 1; else { tty_warn(1, "The -O/-o options are only valid when " "writing or extracting an archive"); tar_usage(); } } /* * process the args as they are interpreted by the operation mode */ switch (act) { case LIST: case EXTRACT: default: { int sawpat = 0; int dirisnext = 0; char *file, *dir = NULL; int mustfreedir = 0; while (nincfiles || *argv != NULL) { /* * If we queued up any include files, * pull them in now. Otherwise, check * for -I and -C positional flags. * Anything else must be a file to * extract. */ if (nincfiles) { file = incfiles->file; dir = incfiles->dir; mustfreedir = 0; incfiles++; nincfiles--; } else if (strcmp(*argv, "-I") == 0) { if (*++argv == NULL) break; file = *argv++; dir = chdname; mustfreedir = 0; } else { file = NULL; dir = NULL; mustfreedir = 0; } if (file != NULL) { FILE *fp; char *str; if (strcmp(file, "-") == 0) fp = stdin; else if ((fp = fopen(file, "r")) == NULL) { tty_warn(1, "Unable to open file '%s' for read", file); tar_usage(); } while ((str = get_line(fp)) != NULL) { if (dirisnext) { if (dir && mustfreedir) free(dir); dir = str; mustfreedir = 1; dirisnext = 0; continue; } if (strcmp(str, "-C") == 0) { havechd++; dirisnext = 1; free(str); continue; } if (strncmp(str, "-C ", 3) == 0) { havechd++; if (dir && mustfreedir) free(dir); dir = strdup(str + 3); mustfreedir = 1; free(str); continue; } if (pat_add(str, dir, NOGLOB_MTCH) < 0) tar_usage(); sawpat = 1; } /* Bomb if given -C w/out a dir. */ if (dirisnext) tar_usage(); if (dir && mustfreedir) free(dir); if (strcmp(file, "-") != 0) fclose(fp); if (get_line_error) { tty_warn(1, "Problem with file '%s'", file); tar_usage(); } } else if (strcmp(*argv, "-C") == 0) { if (*++argv == NULL) break; chdname = *argv++; havechd++; } else if (pat_add(*argv++, chdname, 0) < 0) tar_usage(); else sawpat = 1; } /* * if patterns were added, we are doing chdir() * on a file-by-file basis, else, just one * global chdir (if any) after opening input. */ if (sawpat > 0) chdname = NULL; } break; case ARCHIVE: case APPND: if (chdname != NULL) { /* initial chdir() */ if (ftree_add(chdname, 1) < 0) tar_usage(); } while (nincfiles || *argv != NULL) { char *file, *dir; /* * If we queued up any include files, pull them in * now. Otherwise, check for -I and -C positional * flags. Anything else must be a file to include * in the archive. */ if (nincfiles) { file = incfiles->file; dir = incfiles->dir; incfiles++; nincfiles--; } else if (strcmp(*argv, "-I") == 0) { if (*++argv == NULL) break; file = *argv++; dir = NULL; } else { file = NULL; dir = NULL; } if (file != NULL) { FILE *fp; char *str; int dirisnext = 0; /* Set directory if needed */ if (dir) { if (ftree_add(dir, 1) < 0) tar_usage(); } if (strcmp(file, "-") == 0) fp = stdin; else if ((fp = fopen(file, "r")) == NULL) { tty_warn(1, "Unable to open file '%s' for read", file); tar_usage(); } while ((str = get_line(fp)) != NULL) { if (dirisnext) { if (ftree_add(str, 1) < 0) tar_usage(); dirisnext = 0; continue; } if (strcmp(str, "-C") == 0) { dirisnext = 1; continue; } if (strncmp(str, "-C ", 3) == 0) { if (ftree_add(str + 3, 1) < 0) tar_usage(); continue; } if (ftree_add(str, 0) < 0) tar_usage(); } /* Bomb if given -C w/out a dir. */ if (dirisnext) tar_usage(); if (strcmp(file, "-") != 0) fclose(fp); if (get_line_error) { tty_warn(1, "Problem with file '%s'", file); tar_usage(); } } else if (strcmp(*argv, "-C") == 0) { if (*++argv == NULL) break; if (ftree_add(*argv++, 1) < 0) tar_usage(); } else if (ftree_add(*argv++, 0) < 0) tar_usage(); } /* * no read errors allowed on updates/append operation! */ maxflt = 0; break; } if (!fstdin && ((arcname == NULL) || (*arcname == '\0'))) { arcname = getenv("TAPE"); if ((arcname == NULL) || (*arcname == '\0')) arcname = _PATH_DEFTAPE; } } int mkpath(char *path) { char *slash; int done = 0; slash = path; while (!done) { slash += strspn(slash, "/"); slash += strcspn(slash, "/"); done = (*slash == '\0'); *slash = '\0'; if (domkdir(path, 0777) == -1) goto out; if (!done) *slash = '/'; } return 0; out: /* Can't create or or not a directory */ syswarn(1, errno, "Cannot create directory `%s'", path); return -1; } #ifndef NO_CPIO struct option cpio_longopts[] = { { "reset-access-time", no_argument, 0, 'a' }, { "make-directories", no_argument, 0, 'd' }, { "nonmatching", no_argument, 0, 'f' }, { "extract", no_argument, 0, 'i' }, { "link", no_argument, 0, 'l' }, { "preserve-modification-time", no_argument, 0, 'm' }, { "create", no_argument, 0, 'o' }, { "pass-through", no_argument, 0, 'p' }, { "rename", no_argument, 0, 'r' }, { "list", no_argument, 0, 't' }, { "unconditional", no_argument, 0, 'u' }, { "verbose", no_argument, 0, 'v' }, { "append", no_argument, 0, 'A' }, { "pattern-file", required_argument, 0, 'E' }, { "file", required_argument, 0, 'F' }, { "force-local", no_argument, 0, OPT_FORCE_LOCAL }, { "format", required_argument, 0, 'H' }, { "dereference", no_argument, 0, 'L' }, { "swap-halfwords", no_argument, 0, 'S' }, { "summary", no_argument, 0, 'V' }, { "stats", no_argument, 0, 'V' }, { "insecure", no_argument, 0, OPT_INSECURE }, { "sparse", no_argument, 0, OPT_SPARSE }, { "xz", no_argument, 0, OPT_XZ }, #ifdef notyet /* Not implemented */ { "null", no_argument, 0, '0' }, { "swap", no_argument, 0, 'b' }, { "numeric-uid-gid", no_argument, 0, 'n' }, { "swap-bytes", no_argument, 0, 's' }, { "message", required_argument, 0, 'M' }, { "owner", required_argument, 0 'R' }, { "dot", no_argument, 0, 'V' }, /* xxx */ { "block-size", required_argument, 0, OPT_BLOCK_SIZE }, { "no-absolute-pathnames", no_argument, 0, OPT_NO_ABSOLUTE_PATHNAMES }, { "no-preserve-owner", no_argument, 0, OPT_NO_PRESERVE_OWNER }, { "only-verify-crc", no_argument, 0, OPT_ONLY_VERIFY_CRC }, { "rsh-command", required_argument, 0, OPT_RSH_COMMAND }, { "version", no_argument, 0, OPT_VERSION }, #endif { 0, 0, 0, 0 }, }; static void cpio_set_action(int op) { if ((act == APPND && op == ARCHIVE) || (act == ARCHIVE && op == APPND)) act = APPND; else if (act == EXTRACT && op == LIST) act = op; else if (act != ERROR && act != op) cpio_usage(); else act = op; } /* * cpio_options() * look at the user specified flags. set globals as required and check if * the user specified a legal set of flags. If not, complain and exit */ static void cpio_options(int argc, char **argv) { FSUB tmp; u_int64_t flg = 0; u_int64_t bflg = 0; int c; size_t i; FILE *fp; char *str; uflag = 1; kflag = 1; pids = 1; pmode = 1; pmtime = 0; arcname = NULL; dflag = 1; nodirs = 1; /* * process option flags */ while ((c = getoldopt(argc, argv, "+abcdfiklmoprstuvzABC:E:F:H:I:LM:O:R:SVZ6", cpio_longopts, NULL)) != -1) { switch(c) { case 'a': /* * preserve access time on filesystem nodes we read */ tflag = 1; flg |= TF; break; #ifdef notyet case 'b': /* * swap bytes and half-words when reading data */ break; #endif case 'c': /* * ASCII cpio header */ frmt = &fsub[F_SV4CPIO]; break; case 'd': /* * create directories as needed * pax does this by default .. */ nodirs = 0; break; case 'f': /* * inverse match on patterns */ cflag = 1; flg |= CF; break; case 'i': /* * read the archive */ cpio_set_action(EXTRACT); flg |= RF; break; #ifdef notyet case 'k': break; #endif case 'l': /* * try to link src to dest with copy (-rw) */ lflag = 1; flg |= LF; break; case 'm': /* * preserve mtime */ flg |= PF; pmtime = 1; break; case 'o': /* * write an archive */ cpio_set_action(ARCHIVE); frmt = &(fsub[F_SV4CRC]); flg |= WF; break; case 'p': /* * cpio -p is like pax -rw */ cpio_set_action(COPY); flg |= RF | WF; break; case 'r': /* * interactive file rename */ iflag = 1; flg |= IF; break; #ifdef notyet case 's': /* * swap bytes after reading data */ break; #endif case 't': /* * list contents of archive */ cpio_set_action(LIST); listf = stdout; flg &= ~RF; break; case 'u': /* * don't ignore those older files */ uflag = 0; kflag = 0; flg |= UF; break; case 'v': /* * verbose operation mode */ vflag = 1; flg |= VF; break; case 'z': /* * use gzip. Non standard option. */ gzip_program = GZIP_CMD; break; case 'A': /* * append to an archive */ cpio_set_action(APPND); flg |= AF; break; case 'B': /* * set blocksize to 5120 */ blksz = 5120; break; case 'C': /* * specify blocksize */ if ((blksz = (int)str_offt(optarg)) <= 0) { tty_warn(1, "Invalid block size %s", optarg); cpio_usage(); } break; case 'E': /* * file with patterns to extract or list */ if ((fp = fopen(optarg, "r")) == NULL) { tty_warn(1, "Unable to open file '%s' for read", optarg); cpio_usage(); } while ((str = get_line(fp)) != NULL) { pat_add(str, NULL, 0); } fclose(fp); if (get_line_error) { tty_warn(1, "Problem with file '%s'", optarg); cpio_usage(); } break; case 'H': /* * specify an archive format on write */ tmp.name = optarg; frmt = (FSUB *)bsearch((void *)&tmp, (void *)fsub, sizeof(fsub)/sizeof(FSUB), sizeof(FSUB), c_frmt); if (frmt != NULL) { flg |= XF; break; } tty_warn(1, "Unknown -H format: %s", optarg); (void)fputs("cpio: Known -H formats are:", stderr); for (i = 0; i < (sizeof(fsub)/sizeof(FSUB)); ++i) (void)fprintf(stderr, " %s", fsub[i].name); (void)fputs("\n\n", stderr); cpio_usage(); break; case 'F': case 'I': case 'O': /* * filename where the archive is stored */ if ((optarg[0] == '-') && (optarg[1]== '\0')) { /* * treat a - as stdin */ arcname = NULL; break; } arcname = optarg; break; case 'L': /* * follow symlinks */ Lflag = 1; flg |= CLF; break; #ifdef notyet case 'M': arg = optarg; break; case 'R': arg = optarg; break; #endif case 'S': /* * swap halfwords after reading data */ cpio_swp_head = 1; break; #ifdef notyet case 'V': /* print a '.' for each file processed */ break; #endif case 'V': /* * semi-verbose operation mode (no listing) */ Vflag = 1; flg |= VF; break; case 'Z': /* * use compress. Non standard option. */ gzip_program = COMPRESS_CMD; break; case '6': /* * process Version 6 cpio format */ frmt = &(fsub[F_BCPIO]); break; case OPT_FORCE_LOCAL: forcelocal = 1; break; case OPT_INSECURE: secure = 0; break; case OPT_SPARSE: /* do nothing; we already generate sparse files */ break; case OPT_XZ: gzip_program = XZ_CMD; break; default: cpio_usage(); break; } } /* * figure out the operation mode of cpio. check that we have not been * given a bogus set of flags for the operation mode. */ if (ISLIST(flg)) { act = LIST; bflg = flg & BDLIST; } else if (ISEXTRACT(flg)) { act = EXTRACT; bflg = flg & BDEXTR; } else if (ISARCHIVE(flg)) { act = ARCHIVE; bflg = flg & BDARCH; } else if (ISAPPND(flg)) { act = APPND; bflg = flg & BDARCH; } else if (ISCOPY(flg)) { act = COPY; bflg = flg & BDCOPY; } else cpio_usage(); if (bflg) { cpio_usage(); } /* * if we are writing (ARCHIVE) we use the default format if the user * did not specify a format. when we write during an APPEND, we will * adopt the format of the existing archive if none was supplied. */ if (!(flg & XF) && (act == ARCHIVE)) frmt = &(fsub[F_BCPIO]); /* * process the args as they are interpreted by the operation mode */ switch (act) { case LIST: case EXTRACT: for (; optind < argc; optind++) if (pat_add(argv[optind], NULL, 0) < 0) cpio_usage(); break; case COPY: if (optind >= argc) { tty_warn(0, "Destination directory was not supplied"); cpio_usage(); } --argc; dirptr = argv[argc]; /* FALLTHROUGH */ case ARCHIVE: case APPND: if (argc != optind) { for (; optind < argc; optind++) if (ftree_add(argv[optind], 0) < 0) cpio_usage(); break; } /* * no read errors allowed on updates/append operation! */ maxflt = 0; while ((str = get_line(stdin)) != NULL) { ftree_add(str, 0); } if (get_line_error) { tty_warn(1, "Problem while reading stdin"); cpio_usage(); } break; default: cpio_usage(); break; } } #endif /* * printflg() * print out those invalid flag sets found to the user */ static void printflg(unsigned int flg) { int nxt; (void)fprintf(stderr,"%s: Invalid combination of options:", argv0); while ((nxt = ffs(flg)) != 0) { flg &= ~(1 << (nxt - 1)); (void)fprintf(stderr, " -%c", flgch[nxt - 1]); } (void)putc('\n', stderr); } /* * c_frmt() * comparison routine used by bsearch to find the format specified * by the user */ static int c_frmt(const void *a, const void *b) { return strcmp(((const FSUB *)a)->name, ((const FSUB *)b)->name); } /* * opt_next() * called by format specific options routines to get each format specific * flag and value specified with -o * Return: * pointer to next OPLIST entry or NULL (end of list). */ OPLIST * opt_next(void) { OPLIST *opt; if ((opt = ophead) != NULL) ophead = ophead->fow; return opt; } /* * bad_opt() * generic routine used to complain about a format specific options * when the format does not support options. */ int bad_opt(void) { OPLIST *opt; if (ophead == NULL) return 0; /* * print all we were given */ tty_warn(1," These format options are not supported for %s", frmt->name); while ((opt = opt_next()) != NULL) (void)fprintf(stderr, "\t%s = %s\n", opt->name, opt->value); if (strcmp(NM_TAR, argv0) == 0) tar_usage(); #ifndef NO_CPIO else if (strcmp(NM_CPIO, argv0) == 0) cpio_usage(); #endif else pax_usage(); return 0; } /* * opt_add() * breaks the value supplied to -o into a option name and value. options * are given to -o in the form -o name-value,name=value * multiple -o may be specified. * Return: * 0 if format in name=value format, -1 if -o is passed junk */ int opt_add(const char *str) { OPLIST *opt; char *frpt; char *pt; char *endpt; char *dstr; if ((str == NULL) || (*str == '\0')) { tty_warn(0, "Invalid option name"); return -1; } if ((dstr = strdup(str)) == NULL) { tty_warn(0, "Unable to allocate space for option list"); return -1; } frpt = endpt = dstr; /* * break into name and values pieces and stuff each one into a * OPLIST structure. When we know the format, the format specific * option function will go through this list */ while ((frpt != NULL) && (*frpt != '\0')) { if ((endpt = strchr(frpt, ',')) != NULL) *endpt = '\0'; if ((pt = strchr(frpt, '=')) == NULL) { tty_warn(0, "Invalid options format"); free(dstr); return -1; } if ((opt = (OPLIST *)malloc(sizeof(OPLIST))) == NULL) { tty_warn(0, "Unable to allocate space for option list"); free(dstr); return -1; } *pt++ = '\0'; opt->name = frpt; opt->value = pt; opt->fow = NULL; if (endpt != NULL) frpt = endpt + 1; else frpt = NULL; if (ophead == NULL) { optail = ophead = opt; continue; } optail->fow = opt; optail = opt; } return 0; } /* * str_offt() * Convert an expression of the following forms to an off_t > 0. * 1) A positive decimal number. * 2) A positive decimal number followed by a b (mult by 512). * 3) A positive decimal number followed by a k (mult by 1024). * 4) A positive decimal number followed by a m (mult by 512). * 5) A positive decimal number followed by a w (mult by sizeof int) * 6) Two or more positive decimal numbers (with/without k,b or w). * separated by x (also * for backwards compatibility), specifying * the product of the indicated values. * Return: * 0 for an error, a positive value o.w. */ static off_t str_offt(char *val) { char *expr; off_t num, t; num = STRTOOFFT(val, &expr, 0); if ((num == OFFT_MAX) || (num <= 0) || (expr == val)) return 0; switch(*expr) { case 'b': t = num; num *= 512; if (t > num) return 0; ++expr; break; case 'k': t = num; num *= 1024; if (t > num) return 0; ++expr; break; case 'm': t = num; num *= 1048576; if (t > num) return 0; ++expr; break; case 'w': t = num; num *= sizeof(int); if (t > num) return 0; ++expr; break; } switch(*expr) { case '\0': break; case '*': case 'x': t = num; num *= str_offt(expr + 1); if (t > num) return 0; break; default: return 0; } return num; } static char * get_line(FILE *f) { char *name, *temp; size_t len; name = fgetln(f, &len); if (!name) { get_line_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0; return 0; } if (name[len-1] != '\n') len++; temp = malloc(len); if (!temp) { get_line_error = GETLINE_OUT_OF_MEM; return 0; } memcpy(temp, name, len-1); temp[len-1] = 0; return temp; } #ifndef SMALL /* * set_tstamp() * Use a specific timestamp for all individual files created in the * archive */ static int set_tstamp(const char *b, struct stat *st) { time_t when; char *eb; long long l; if (stat(b, st) != -1) return 0; #ifndef HAVE_NBTOOL_CONFIG_H errno = 0; if ((when = parsedate(b, NULL, NULL)) == -1 && errno != 0) #endif { errno = 0; l = strtoll(b, &eb, 0); if (b == eb || *eb || errno) return -1; when = (time_t)l; } st->st_ino = 1; #if HAVE_STRUCT_STAT_BIRTHTIME st->st_birthtime = #endif st->st_mtime = st->st_ctime = st->st_atime = when; return 0; } #endif /* * no_op() * for those option functions where the archive format has nothing to do. * Return: * 0 */ static int no_op(void) { return 0; } /* * pax_usage() * print the usage summary to the user */ static void pax_usage(void) { fprintf(stderr, "usage: pax [-0cdjnvzVO] [-E limit] [-f archive] [-N dbdir] [-s replstr] ...\n" " [-U user] ... [-G group] ... [-T [from_date][,to_date]] ...\n" " [pattern ...]\n"); fprintf(stderr, " pax -r [-cdijknuvzADOVYZ] [-E limit] [-f archive] [-N dbdir]\n" " [-o options] ... [-p string] ... [-s replstr] ... [-U user] ...\n" " [-G group] ... [-T [from_date][,to_date]] ... [pattern ...]\n"); fprintf(stderr, " pax -w [-dijtuvzAHLMOPVX] [-b blocksize] [[-a] [-f archive]] [-x format]\n" " [-B bytes] [-N dbdir] [-o options] ... [-s replstr] ...\n" " [-U user] ... [-G group] ...\n" " [-T [from_date][,to_date][/[c][m]]] ... [file ...]\n"); fprintf(stderr, " pax -r -w [-dijklntuvzADHLMOPVXYZ] [-N dbdir] [-p string] ...\n" " [-s replstr] ... [-U user] ... [-G group] ...\n" " [-T [from_date][,to_date][/[c][m]]] ... [file ...] directory\n"); exit(1); /* NOTREACHED */ } /* * tar_usage() * print the usage summary to the user */ static void tar_usage(void) { (void)fputs("usage: tar [-]{crtux}[-befhjklmopqvwzHJOPSXZ014578] " "[archive] [blocksize]\n" " [-C directory] [-T file] [-s replstr] " "[file ...]\n", stderr); exit(1); /* NOTREACHED */ } #ifndef NO_CPIO /* * cpio_usage() * print the usage summary to the user */ static void cpio_usage(void) { (void)fputs("usage: cpio -o [-aABcLvzZ] [-C bytes] [-F archive] " "[-H format] [-O archive]\n" " < name-list [> archive]\n" " cpio -i [-bBcdfmrsStuvzZ6] [-C bytes] [-E file] " "[-F archive] [-H format] \n" " [-I archive] " "[pattern ...] [< archive]\n" " cpio -p [-adlLmuv] destination-directory " "< name-list\n", stderr); exit(1); /* NOTREACHED */ } #endif @ 1.119 log @Move definition of chdname and do_chroot to options.c @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.118 2015/12/19 18:45:52 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.118 2015/12/19 18:45:52 christos Exp $"); d64 1 @ 1.118 log @Add the timestamp option to the pax front end. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.117 2015/12/19 18:28:54 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.117 2015/12/19 18:28:54 christos Exp $"); d77 5 @ 1.118.8.1 log @Pull up following revision(s) (requested by mrg in ticket #1678): bin/pax/options.c: revision 1.119 usr.bin/config/scan.l: revision 1.32 usr.bin/make/main.c: revision 1.274 bin/pax/extern.h: revision 1.60 usr.bin/config/defs.h: revision 1.106 usr.bin/make/make.h: revision 1.105 sbin/newfs_udf/udf_create.c: revision 1.27 (patch) sbin/newfs_udf/newfs_udf.h: revision 1.7 (patch) usr.bin/config/main.c: revision 1.100 usr.sbin/installboot/Makefile: revisions 1.53,1.54 (patch) usr.sbin/installboot/installboot.h: revision 1.41 (patch) usr.sbin/installboot/machines.c: revisisons 1.41,1.42 (patch) Avoid depending on common symbols. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.118 2015/12/19 18:45:52 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.118 2015/12/19 18:45:52 christos Exp $"); a76 5 char *chdname; #if !HAVE_NBTOOL_CONFIG_H int do_chroot; #endif @ 1.118.18.1 log @Pull up following revision(s) (requested by mrg in ticket #1263): bin/pax/options.c: revision 1.119 usr.bin/config/scan.l: revision 1.32 usr.bin/make/main.c: revision 1.274 bin/pax/extern.h: revision 1.60 usr.bin/config/defs.h: revision 1.106 usr.bin/make/make.h: revision 1.105 sbin/newfs_udf/udf_create.c: revision 1.27 (patch) sbin/newfs_udf/newfs_udf.h: revision 1.7 (patch) usr.bin/config/main.c: revision 1.100 Avoid depending on common symbols. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.118 2015/12/19 18:45:52 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.118 2015/12/19 18:45:52 christos Exp $"); a76 5 char *chdname; #if !HAVE_NBTOOL_CONFIG_H int do_chroot; #endif @ 1.118.16.1 log @Merge changes from current as of 20200406 @ text @d1 1 a1 1 /* $NetBSD$ */ d45 1 a45 1 __RCSID("$NetBSD$"); a76 5 char *chdname; #if !HAVE_NBTOOL_CONFIG_H int do_chroot; #endif @ 1.118.16.2 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.118.16.1 2020/04/08 14:03:04 martin Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.118.16.1 2020/04/08 14:03:04 martin Exp $"); @ 1.118.16.3 log @Ooops, restore accidently removed files from merge mishap @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.119 2020/04/03 16:13:32 joerg Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.119 2020/04/03 16:13:32 joerg Exp $"); @ 1.117 log @PR/50119: Thomas Klausner: Add --timestamp option to tar. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.116 2015/04/11 15:41:33 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.116 2015/04/11 15:41:33 christos Exp $"); d260 2 d672 8 @ 1.116 log @Add -J/--xz to specifically decompress xz compressed files. We don't really need this because -z autodetects the compression format; this is for syntax compatibility with other tar implementations. From Joachim Henke @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.115 2013/11/14 04:00:48 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.115 2013/11/14 04:00:48 christos Exp $"); d67 1 d80 1 d93 3 d137 1 d139 1 a139 1 #define OPT_CHROOT 19 d812 2 d1155 8 d2102 37 @ 1.115 log @add --gnu for pax. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.114 2012/08/09 11:05:59 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.114 2012/08/09 11:05:59 christos Exp $"); d776 1 a801 2 { "xz", no_argument, 0, OPT_XZ }, d879 1 a879 1 "+b:cef:hjklmopqrs:tuvwxzBC:HI:OPST:X:Z014578", a967 3 case 'O': Oflag = 1; break; d1063 6 a1146 3 case OPT_XZ: gzip_program = XZ_CMD; break; d2136 2 a2137 2 (void)fputs("usage: tar [-]{crtux}[-befhjklmopqvwzHOPSXZ014578] [archive] " "[blocksize]\n" @ 1.114 log @add missing include files @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.113 2012/03/20 18:42:28 matt Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.113 2012/03/20 18:42:28 matt Exp $"); d131 1 d133 1 a133 1 #define OPT_CHROOT 18 d252 2 d661 3 @ 1.114.2.1 log @Rebase to HEAD as of a few days ago. @ text @d1 1 a1 1 /* $NetBSD$ */ d45 1 a45 1 __RCSID("$NetBSD$"); a130 1 #define OPT_GNU 18 d132 1 a132 1 #define OPT_CHROOT 19 a250 2 { "gnu", no_argument, 0, OPT_GNU }, a657 3 case OPT_GNU: is_gnutar = 1; break; @ 1.113 log @Use C89 function definitions @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.112 2011/08/31 16:24:54 plunky Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.112 2011/08/31 16:24:54 plunky Exp $"); d65 1 @ 1.112 log @NULL does not need a cast @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.111 2011/08/29 14:47:47 joerg Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.111 2011/08/29 14:47:47 joerg Exp $"); d1382 1 a1382 2 mkpath(path) char *path; @ 1.112.2.1 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.112 2011/08/31 16:24:54 plunky Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.112 2011/08/31 16:24:54 plunky Exp $"); d1382 2 a1383 1 mkpath(char *path) @ 1.112.2.2 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.112.2.1 2012/04/17 00:01:37 yamt Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.112.2.1 2012/04/17 00:01:37 yamt Exp $"); a64 1 #include @ 1.112.2.3 log @sync with head. for a reference, the tree before this commit was tagged as yamt-pagecache-tag8. this commit was splitted into small chunks to avoid a limitation of cvs. ("Protocol error: too many arguments") @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.112.2.2 2012/10/30 18:46:07 yamt Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.112.2.2 2012/10/30 18:46:07 yamt Exp $"); a130 1 #define OPT_GNU 18 d132 1 a132 1 #define OPT_CHROOT 19 a250 2 { "gnu", no_argument, 0, OPT_GNU }, a657 3 case OPT_GNU: is_gnutar = 1; break; @ 1.111 log @static + __dead @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.110 2011/06/18 23:07:04 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.110 2011/06/18 23:07:04 christos Exp $"); d1374 1 a1374 1 if (!fstdin && ((arcname == (char *)NULL) || (*arcname == '\0'))) { @ 1.110 log @add --xz @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.109 2010/08/31 03:16:06 enami Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.109 2010/08/31 03:16:06 enami Exp $"); d84 1 d91 1 a91 1 static void pax_usage(void); d93 1 a93 1 static void tar_usage(void); d96 1 a96 1 static void cpio_usage(void); d2058 1 a2058 1 char * d2099 1 a2099 1 void d2128 1 a2128 1 void d2145 1 a2145 1 void @ 1.109 log @- Raise an error rather than silently creating broken archive if user don't specify --force-local but opened file is actually a local file. - Make cpio to accept -F option as described in manpage. - Make pax to set forcelocal flag if requested to do so. - Add missing break statement. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.108 2010/08/25 21:36:02 sjg Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.108 2010/08/25 21:36:02 sjg Exp $"); d105 1 d128 1 d130 1 a130 1 #define OPT_CHROOT 17 d247 2 a326 1 jflag = 1; a481 1 zflag = 1; a650 1 zflag = 1; d653 3 d793 2 a922 1 jflag = 1; a1026 1 zflag = 1; a1085 1 zflag = 1; a1112 1 zflag = 1; d1137 3 d1439 2 d1755 3 @ 1.109.4.1 log @Catchup with rmind-uvmplock merge. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.110 2011/06/18 23:07:04 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.110 2011/06/18 23:07:04 christos Exp $"); a104 1 #define XZ_CMD "xz" /* command to run as xz */ a126 1 #define OPT_XZ 17 d128 1 a128 1 #define OPT_CHROOT 18 a244 2 { "xz", no_argument, 0, OPT_XZ }, d323 1 d479 1 d649 1 a651 3 case OPT_XZ: gzip_program = XZ_CMD; break; a788 2 { "xz", no_argument, 0, OPT_XZ }, d917 1 d1022 1 d1082 1 d1110 1 a1134 3 case OPT_XZ: gzip_program = XZ_CMD; break; a1433 2 { "xz", no_argument, 0, OPT_XZ }, a1747 3 case OPT_XZ: gzip_program = XZ_CMD; break; @ 1.108 log @Do not throw a usage message for -i followed by -t since 'cpio -itv' is a valid command. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.107 2010/06/19 00:43:57 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.107 2010/06/19 00:43:57 christos Exp $"); d646 1 a646 1 forcelocal = 0; d1680 1 d1738 1 a1744 1 @ 1.107 log @add --use-compress-program to pax, requested by mrg. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.106 2009/12/14 05:04:48 dholland Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.106 2009/12/14 05:04:48 dholland Exp $"); d1465 2 @ 1.106 log @Don't use NOGLOB_MTCH for pax, only for tar. Fixes fix for PR 41167 and closes PR 42301. Since the 41167 fix was pulled up to -5, this needs to be too. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.105 2009/07/13 19:05:39 roy Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.105 2009/07/13 19:05:39 roy Exp $"); d243 2 d479 1 d648 4 @ 1.105 log @Rename internal getline() function to get_line() so it does conflict with the soon to be added getline(3) libc function. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.104 2009/04/07 19:52:35 perry Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.104 2009/04/07 19:52:35 perry Exp $"); d695 1 a695 1 if (pat_add(argv[optind], NULL, NOGLOB_MTCH) < 0) @ 1.104 log @Fixes from christos for pr-41167 XXX -X is still broken, but that wasn't part of this PR. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.103 2009/02/14 08:10:06 lukem Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.103 2009/02/14 08:10:06 lukem Exp $"); d88 1 a88 1 static char *getline(FILE *fp); d98 1 a98 1 /* errors from getline */ d101 1 a101 1 static int getline_error; d1213 1 a1213 1 while ((str = getline(fp)) != NULL) { d1248 1 a1248 1 if (getline_error) { d1318 1 a1318 1 while ((str = getline(fp)) != NULL) { d1342 1 a1342 1 if (getline_error) { d1644 1 a1644 1 while ((str = getline(fp)) != NULL) { d1648 1 a1648 1 if (getline_error) { d1807 1 a1807 1 while ((str = getline(stdin)) != NULL) { d1810 1 a1810 1 if (getline_error) { d2038 1 a2038 1 getline(FILE *f) d2045 1 a2045 1 getline_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0; d2052 1 a2052 1 getline_error = GETLINE_OUT_OF_MEM; @ 1.103 log @fix -Wsign-compare issues @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.102 2008/11/23 10:08:50 dholland Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.102 2008/11/23 10:08:50 dholland Exp $"); d695 1 a695 1 if (pat_add(argv[optind], NULL) < 0) d1237 1 a1237 1 if (pat_add(str, dir) < 0) d1257 1 a1257 1 } else if (pat_add(*argv++, chdname) < 0) d1645 1 a1645 1 pat_add(str, NULL); d1784 1 a1784 1 if (pat_add(argv[optind], 0) < 0) @ 1.102 log @Don't pass strings from argv[] to free(). Fixes PR 39992. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.101 2007/10/26 16:38:12 hira Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.101 2007/10/26 16:38:12 hira Exp $"); d257 1 a257 1 int i; d1476 2 a1477 1 int c, i; @ 1.102.2.1 log @Sync with HEAD. Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.104 2009/04/07 19:52:35 perry Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.104 2009/04/07 19:52:35 perry Exp $"); d257 1 a257 1 size_t i; d695 1 a695 1 if (pat_add(argv[optind], NULL, NOGLOB_MTCH) < 0) d1237 1 a1237 1 if (pat_add(str, dir, NOGLOB_MTCH) < 0) d1257 1 a1257 1 } else if (pat_add(*argv++, chdname, 0) < 0) d1476 1 a1476 2 int c; size_t i; d1644 1 a1644 1 pat_add(str, NULL, 0); d1783 1 a1783 1 if (pat_add(argv[optind], NULL, 0) < 0) @ 1.101 log @ - Add -0 and -V to pax_usage(). - Add -k to tar_usage(). @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.100 2007/04/23 18:40:22 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.100 2007/04/23 18:40:22 christos Exp $"); d1176 1 d1189 1 d1197 1 d1201 1 d1215 1 a1215 1 if (dir) d1218 1 d1230 1 a1230 1 if (dir) d1233 1 d1244 1 a1244 1 if (dir) @ 1.101.12.1 log @Pull up following revision(s) (requested by dholland in ticket #114): bin/pax/options.c: revision 1.102 Don't pass strings from argv[] to free(). Fixes PR 39992. @ text @d1 1 a1 1 /* $NetBSD$ */ d45 1 a45 1 __RCSID("$NetBSD$"); a1175 1 int mustfreedir = 0; a1187 1 mustfreedir = 0; a1194 1 mustfreedir = 0; a1197 1 mustfreedir = 0; d1211 1 a1211 1 if (dir && mustfreedir) a1213 1 mustfreedir = 1; d1225 1 a1225 1 if (dir && mustfreedir) a1227 1 mustfreedir = 1; d1238 1 a1238 1 if (dir && mustfreedir) @ 1.101.12.2 log @Pull up following revision(s) (requested by christo in ticket #678): bin/pax/extern.h: revision 1.56 bin/pax/file_subs.c: revision 1.62 bin/pax/options.c: revision 1.104 bin/pax/pat_rep.c: revision 1.29 bin/pax/pax.h: revision 1.30 Fixes from christos for pr-41167 XXX -X is still broken, but that wasn't part of this PR. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.101.12.1 2008/11/23 21:26:50 riz Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.101.12.1 2008/11/23 21:26:50 riz Exp $"); d695 1 a695 1 if (pat_add(argv[optind], NULL, NOGLOB_MTCH) < 0) d1237 1 a1237 1 if (pat_add(str, dir, NOGLOB_MTCH) < 0) d1257 1 a1257 1 } else if (pat_add(*argv++, chdname, 0) < 0) d1644 1 a1644 1 pat_add(str, NULL, 0); d1783 1 a1783 1 if (pat_add(argv[optind], NULL, 0) < 0) @ 1.101.12.2.4.1 log @sync to netbsd-5 @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.101.12.4 2010/01/30 19:17:17 snj Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.101.12.4 2010/01/30 19:17:17 snj Exp $"); d88 1 a88 1 static char *get_line(FILE *fp); d98 1 a98 1 /* errors from get_line */ d101 1 a101 1 static int get_line_error; d695 1 a695 1 if (pat_add(argv[optind], NULL, 0) < 0) d1213 1 a1213 1 while ((str = get_line(fp)) != NULL) { d1248 1 a1248 1 if (get_line_error) { d1318 1 a1318 1 while ((str = get_line(fp)) != NULL) { d1342 1 a1342 1 if (get_line_error) { d1643 1 a1643 1 while ((str = get_line(fp)) != NULL) { d1647 1 a1647 1 if (get_line_error) { d1806 1 a1806 1 while ((str = get_line(stdin)) != NULL) { d1809 1 a1809 1 if (get_line_error) { d2037 1 a2037 1 get_line(FILE *f) d2044 1 a2044 1 get_line_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0; d2051 1 a2051 1 get_line_error = GETLINE_OUT_OF_MEM; @ 1.101.12.2.2.1 log @Pull up following revision(s) (requested by roy in ticket #885): bin/pax/options.c: revision 1.105 dist/nawk/maketab.c: revision 1.12 dist/nawk/proctab.c: revision 1.11 dist/nawk/proto.h: revision 1.9 dist/nawk/run.c: revision 1.29 usr.bin/ctags/C.c: revision 1.19 usr.bin/ctags/ctags.h: revision 1.9 usr.bin/ctags/fortran.c: revision 1.11 usr.bin/ctags/lisp.c: revision 1.11 usr.bin/ctags/print.c: revision 1.10 usr.bin/ctags/yacc.c: revision 1.12 usr.bin/gencat/gencat.c: revision 1.30 Rename internal getline() function to get_line() so it does conflict with the soon to be added getline(3) libc function. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.101.12.2 2009/04/13 20:42:59 snj Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.101.12.2 2009/04/13 20:42:59 snj Exp $"); d88 1 a88 1 static char *get_line(FILE *fp); d98 1 a98 1 /* errors from get_line */ d101 1 a101 1 static int get_line_error; d1213 1 a1213 1 while ((str = get_line(fp)) != NULL) { d1248 1 a1248 1 if (get_line_error) { d1318 1 a1318 1 while ((str = get_line(fp)) != NULL) { d1342 1 a1342 1 if (get_line_error) { d1643 1 a1643 1 while ((str = get_line(fp)) != NULL) { d1647 1 a1647 1 if (get_line_error) { d1806 1 a1806 1 while ((str = get_line(stdin)) != NULL) { d1809 1 a1809 1 if (get_line_error) { d2037 1 a2037 1 get_line(FILE *f) d2044 1 a2044 1 get_line_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0; d2051 1 a2051 1 get_line_error = GETLINE_OUT_OF_MEM; @ 1.101.12.3 log @Pull up following revision(s) (requested by roy in ticket #885): bin/pax/options.c: revision 1.105 dist/nawk/maketab.c: revision 1.12 dist/nawk/proctab.c: revision 1.11 dist/nawk/proto.h: revision 1.9 dist/nawk/run.c: revision 1.29 usr.bin/ctags/C.c: revision 1.19 usr.bin/ctags/ctags.h: revision 1.9 usr.bin/ctags/fortran.c: revision 1.11 usr.bin/ctags/lisp.c: revision 1.11 usr.bin/ctags/print.c: revision 1.10 usr.bin/ctags/yacc.c: revision 1.12 usr.bin/gencat/gencat.c: revision 1.30 Rename internal getline() function to get_line() so it does conflict with the soon to be added getline(3) libc function. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.101.12.2 2009/04/13 20:42:59 snj Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.101.12.2 2009/04/13 20:42:59 snj Exp $"); d88 1 a88 1 static char *get_line(FILE *fp); d98 1 a98 1 /* errors from get_line */ d101 1 a101 1 static int get_line_error; d1213 1 a1213 1 while ((str = get_line(fp)) != NULL) { d1248 1 a1248 1 if (get_line_error) { d1318 1 a1318 1 while ((str = get_line(fp)) != NULL) { d1342 1 a1342 1 if (get_line_error) { d1643 1 a1643 1 while ((str = get_line(fp)) != NULL) { d1647 1 a1647 1 if (get_line_error) { d1806 1 a1806 1 while ((str = get_line(stdin)) != NULL) { d1809 1 a1809 1 if (get_line_error) { d2037 1 a2037 1 get_line(FILE *f) d2044 1 a2044 1 get_line_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0; d2051 1 a2051 1 get_line_error = GETLINE_OUT_OF_MEM; @ 1.101.12.4 log @Pull up following revision(s) (requested by dholland in ticket #1272): bin/pax/options.c: revision 1.106 Don't use NOGLOB_MTCH for pax, only for tar. Fixes fix for PR 41167 and closes PR 42301. Since the 41167 fix was pulled up to -5, this needs to be too. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.101.12.3 2009/08/14 20:32:21 snj Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.101.12.3 2009/08/14 20:32:21 snj Exp $"); d695 1 a695 1 if (pat_add(argv[optind], NULL, 0) < 0) @ 1.100 log @PR/36194: Greg A. Woods: add a '-V' flag to pax for verbose summary without listing (and other minor fixes) @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.99 2007/01/16 19:06:41 cbiere Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.99 2007/01/16 19:06:41 cbiere Exp $"); d2075 1 a2075 1 "usage: pax [-cdjnvzO] [-E limit] [-f archive] [-N dbdir] [-s replstr] ...\n" d2079 1 a2079 1 " pax -r [-cdijknuvzADOYZ] [-E limit] [-f archive] [-N dbdir]\n" d2083 1 a2083 1 " pax -w [-dijtuvzAHLMOPX] [-b blocksize] [[-a] [-f archive]] [-x format]\n" d2088 1 a2088 1 " pax -r -w [-dijklntuvzADHLMOPXYZ] [-N dbdir] [-p string] ...\n" d2103 1 a2103 1 (void)fputs("usage: tar [-]{crtux}[-befhjlmopqvwzHOPSXZ014578] [archive] " @ 1.100.4.1 log @sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.101 2007/10/26 16:38:12 hira Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.101 2007/10/26 16:38:12 hira Exp $"); d2075 1 a2075 1 "usage: pax [-0cdjnvzVO] [-E limit] [-f archive] [-N dbdir] [-s replstr] ...\n" d2079 1 a2079 1 " pax -r [-cdijknuvzADOVYZ] [-E limit] [-f archive] [-N dbdir]\n" d2083 1 a2083 1 " pax -w [-dijtuvzAHLMOPVX] [-b blocksize] [[-a] [-f archive]] [-x format]\n" d2088 1 a2088 1 " pax -r -w [-dijklntuvzADHLMOPVXYZ] [-N dbdir] [-p string] ...\n" d2103 1 a2103 1 (void)fputs("usage: tar [-]{crtux}[-befhjklmopqvwzHOPSXZ014578] [archive] " @ 1.99 log @Fix for PR bin/35432: * The flags "crtux" are mutually exclusive for tar. * The flags "ipt" and "oA" are mutually exclusive for cpio. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.98 2006/10/16 00:11:22 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.98 2006/10/16 00:11:22 christos Exp $"); d258 2 a259 2 unsigned int flg = 0; unsigned int bflg = 0; d267 1 a267 1 "0ab:cdf:ijklno:p:rs:tuvwx:zAB:DE:G:HLMN:OPT:U:XYZ", d609 7 d761 2 d816 2 a817 2 { "volume-name", required_argument, 0, 'V' }, { "label", required_argument, 0, 'V' }, d1058 6 d1415 2 d1430 1 a1430 1 { "dot", no_argument, 0, 'V' }, d1468 2 a1469 2 unsigned int flg = 0; unsigned int bflg = 0; d1700 3 d1704 5 a1709 1 #endif @ 1.98 log @add missing inititializer @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.97 2006/04/16 16:20:21 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.97 2006/04/16 16:20:21 christos Exp $"); d819 8 d868 1 a868 1 act = ARCHIVE; d965 1 a965 1 act = APPND; d980 1 a980 1 act = LIST; d999 1 a999 1 act = EXTRACT; d1430 11 d1510 1 a1510 1 act = EXTRACT; d1535 1 a1535 1 act = ARCHIVE; d1543 1 a1543 1 act = COPY; d1564 1 a1564 1 act = LIST; d1593 1 a1593 1 act = APPND; @ 1.98.6.1 log @Pull up following revision(s) (requested by plunky in ticket #1354): bin/pax/options.c: revision 1.105 via patch usr.bin/ctags/C.c: revision 1.19 usr.bin/ctags/ctags.h: revision 1.9 usr.bin/ctags/fortran.c: revision 1.11 usr.bin/ctags/lisp.c: revision 1.11 usr.bin/ctags/print.c: revision 1.10 usr.bin/ctags/yacc.c: revision 1.12 usr.bin/gencat/gencat.c: revision 1.30 via patch Rename internal getline() function to get_line() so it does not conflict with the soon to be added getline(3) libc function. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.98 2006/10/16 00:11:22 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.98 2006/10/16 00:11:22 christos Exp $"); d88 1 a88 1 static char *get_line(FILE *fp); d98 1 a98 1 /* errors from get_line */ d101 1 a101 1 static int get_line_error; d1186 1 a1186 1 while ((str = get_line(fp)) != NULL) { d1219 1 a1219 1 if (get_line_error) { d1289 1 a1289 1 while ((str = get_line(fp)) != NULL) { d1313 1 a1313 1 if (get_line_error) { d1601 1 a1601 1 while ((str = get_line(fp)) != NULL) { d1605 1 a1605 1 if (get_line_error) { d1757 1 a1757 1 while ((str = get_line(stdin)) != NULL) { d1760 1 a1760 1 if (get_line_error) { d1988 1 a1988 1 get_line(FILE *f) d1995 1 a1995 1 get_line_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0; d2002 1 a2002 1 get_line_error = GETLINE_OUT_OF_MEM; @ 1.98.2.1 log @Pull up following revision(s) (requested by plunky in ticket #1354): bin/pax/options.c: revision 1.105 via patch usr.bin/ctags/C.c: revision 1.19 usr.bin/ctags/ctags.h: revision 1.9 usr.bin/ctags/fortran.c: revision 1.11 usr.bin/ctags/lisp.c: revision 1.11 usr.bin/ctags/print.c: revision 1.10 usr.bin/ctags/yacc.c: revision 1.12 usr.bin/gencat/gencat.c: revision 1.30 via patch Rename internal getline() function to get_line() so it does conflict with the soon to be added getline(3) libc function. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.98 2006/10/16 00:11:22 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.98 2006/10/16 00:11:22 christos Exp $"); d88 1 a88 1 static char *get_line(FILE *fp); d98 1 a98 1 /* errors from get_line */ d101 1 a101 1 static int get_line_error; d1186 1 a1186 1 while ((str = get_line(fp)) != NULL) { d1219 1 a1219 1 if (get_line_error) { d1289 1 a1289 1 while ((str = get_line(fp)) != NULL) { d1313 1 a1313 1 if (get_line_error) { d1601 1 a1601 1 while ((str = get_line(fp)) != NULL) { d1605 1 a1605 1 if (get_line_error) { d1757 1 a1757 1 while ((str = get_line(stdin)) != NULL) { d1760 1 a1760 1 if (get_line_error) { d1988 1 a1988 1 get_line(FILE *f) d1995 1 a1995 1 get_line_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0; d2002 1 a2002 1 get_line_error = GETLINE_OUT_OF_MEM; @ 1.97 log @PR/22995: Sergey Svishchev: If we are cd'ing around and we have directories with relative paths, convert the directories to absolute paths, so that restoring timestamps does not fail. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.96 2006/04/14 16:57:01 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.96 2006/04/14 16:57:01 christos Exp $"); d243 2 a244 1 { 0, 0, 0 }, @ 1.96 log @Don't free str; it is used in pat_add. Noted by: Kouichirou Hiratsuka @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.95 2006/03/19 19:06:39 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.95 2006/03/19 19:06:39 christos Exp $"); d202 5 d1006 1 d1194 1 d1200 1 d1226 1 @ 1.95 log @Coverity CID 2734, 2731: Use after free; resource leak @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.94 2006/03/18 05:40:28 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.94 2006/03/18 05:40:28 christos Exp $"); a1200 1 free(str); @ 1.94 log @Coverity CID 345: Add missing free's. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.93 2006/02/11 10:43:18 dsl Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.93 2006/02/11 10:43:18 dsl Exp $"); d1145 1 a1145 1 char *file, *dir; d1181 2 d1193 2 a1200 1 free(dir); d1207 2 @ 1.93 log @Change all the 'return(x)' to 'return c'. Makes some other searches I want to do a bit easier. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.92 2005/09/16 16:48:18 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.92 2005/09/16 16:48:18 christos Exp $"); d1187 1 d1191 2 a1192 1 dir = str + 3; d1197 2 @ 1.92 log @Another missing mkdir() race pointed out by chuq. Factor out the mkdir code. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.91 2005/09/13 20:09:55 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.91 2005/09/13 20:09:55 christos Exp $"); d1781 1 a1781 1 return(strcmp(((const FSUB *)a)->name, ((const FSUB *)b)->name)); d1799 1 a1799 1 return(opt); d1814 1 a1814 1 return(0); d1830 1 a1830 1 return(0); d1853 1 a1853 1 return(-1); d1857 1 a1857 1 return(-1); d1872 1 a1872 1 return(-1); d1877 1 a1877 1 return(-1); d1894 1 a1894 1 return(0); d1920 1 a1920 1 return(0); d1927 1 a1927 1 return(0); d1934 1 a1934 1 return(0); d1941 1 a1941 1 return(0); d1948 1 a1948 1 return(0); d1961 1 a1961 1 return(0); d1964 1 a1964 1 return(0); d1966 1 a1966 1 return(num); d1978 1 a1978 1 return(0); d1985 1 a1985 1 return(0); d1989 1 a1989 1 return(temp); d2002 1 a2002 1 return(0); @ 1.91 log @use stat and not lstat to detect if we have a directory. refactor the mkpath() code. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.90 2005/09/13 15:50:17 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.90 2005/09/13 15:50:17 christos Exp $"); a1324 1 struct stat sb; d1326 1 a1326 1 int done = 0, sverrno; d1337 1 a1337 12 if (stat(path, &sb) == -1) { if ((sverrno = errno) != ENOENT) goto out; if (mkdir(path, 0777) == -1) { sverrno = errno; /* Check again, to avoid races */ if (stat(path, &sb) == -1 || !S_ISDIR(sb.st_mode)) goto out; } } else if (!S_ISDIR(sb.st_mode)) { sverrno = ENOTDIR; a1338 1 } d1347 1 a1347 1 syswarn(1, sverrno, "Cannot create directory `%s'", path); @ 1.90 log @when creating directories, check if the failure occured because someone else created the directory before we did to avoid races. From chuq. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.89 2005/06/29 02:21:27 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.89 2005/06/29 02:21:27 christos Exp $"); d1338 13 a1350 10 if (mkdir(path, 0777) == -1) { /* Check if it was created it for us in the meantime */ sverrno = errno; if (lstat(path, &sb) == -1 || !S_ISDIR(sb.st_mode)) { /* Can't create or or not a directory */ syswarn(1, sverrno, "Cannot create directory `%s'", path); return -1; } d1358 4 @ 1.89 log @Don't compile in cpio usage, if we are SMALL. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.88 2005/06/01 15:25:51 lukem Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.88 2005/06/01 15:25:51 lukem Exp $"); d693 1 a693 1 pax_usage(); d1327 1 a1327 1 int done = 0; d1338 10 a1347 8 if (stat(path, &sb)) { if (errno != ENOENT || mkdir(path, 0777)) { tty_warn(1, "%s", path); return (-1); } } else if (!S_ISDIR(sb.st_mode)) { syswarn(1, ENOTDIR, "%s", path); return (-1); d1354 1 a1354 1 return (0); @ 1.88 log @appease gcc -Wuninitialized @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.87 2005/05/15 02:04:30 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.87 2005/05/15 02:04:30 christos Exp $"); d93 1 d96 1 d141 1 d161 1 a161 1 d172 1 d179 4 d190 5 a194 1 int ford[] = {F_USTAR, F_TAR, F_SV4CRC, F_SV4CPIO, F_CPIO, F_BCPIO, -1}; d222 1 d226 1 d1356 1 d1756 1 d1828 1 d1831 1 d2054 1 d2076 1 @ 1.87 log @be more lenient on the comparison to argv[0] to determine our personality. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.86 2005/05/07 22:27:33 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.86 2005/05/07 22:27:33 christos Exp $"); d1151 1 a1151 1 } else d1153 2 d1236 1 a1236 1 } else d1238 2 @ 1.86 log @PR/30167: J.T. Conklin: NetBSD tar does not support GNU tar --no-recursion flag @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.85 2005/05/01 02:59:28 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.85 2005/05/01 02:59:28 christos Exp $"); d207 2 a208 1 if (strcmp(NM_TAR, argv0) == 0) d210 2 a211 1 else if (strcmp(NM_CPIO, argv0) == 0) d213 1 a213 1 else { @ 1.85 log @PR/29005: Jesse Off: nbpax requires sys/mtio.h which doesn't exist on Interix I added an ifdef called HAVE_MTIO_H and fixed the code to use it. It is always defined now, but you can change this for Interix. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.84 2005/04/24 03:39:26 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.84 2005/04/24 03:39:26 christos Exp $"); d749 2 a791 2 { "norecurse", no_argument, 0, OPT_NORECURSE }, d1074 3 @ 1.84 log @Pax longopts were not empty element terminated. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.83 2005/02/10 17:48:33 jmc Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.83 2005/02/10 17:48:33 jmc Exp $"); a51 1 #include @ 1.83 log @Fix from PR#29290. Properly terminate the cpio_longopts struct so an unknown option doesn't run off the end and core dump @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.82 2004/10/26 16:11:49 tron Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.82 2004/10/26 16:11:49 tron Exp $"); d223 1 @ 1.82 log @Fix broken cpio(1) option handling: - "cpio -i -t" should list the contents of a file, not extract it. - Don't extract a file when only option "-d" is given. Patch supplied by Paul Ripke in PR bin/26513. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.81 2004/10/22 21:00:18 jmc Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.81 2004/10/22 21:00:18 jmc Exp $"); d1381 1 @ 1.81 log @For HOSTTOOL builds, just exclude the chroot support as it's not needed and avoids having to platform check for fchroot(). Fixes PR#27336 @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.80 2004/10/17 18:49:55 dsl Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.80 2004/10/17 18:49:55 dsl Exp $"); a1439 1 flg |= RF; d1508 1 @ 1.80 log @Add an option --chroot to tar. Causes it to chroot(".") before doing an extract. With -h this will cause existing absolute symlinks to be treated as relative to the current directory. Helps sysinst handle existing symlinks in the target system. Remove 'L' from the usage (got spilt into 'h' and 'H' many moons ago) Add 'S' to usage, and put into correct place in options list. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.79 2004/10/10 22:05:26 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.79 2004/10/10 22:05:26 christos Exp $"); d126 1 d128 1 d749 1 d752 1 d1074 1 d1078 1 @ 1.79 log @PR/27212: Greg A. Woods: Accept "-C " inside filelists in addition to "-C\n". But we are not making it the default output option as the patch suggests. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.78 2004/09/26 23:46:00 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.78 2004/09/26 23:46:00 christos Exp $"); d126 1 d728 1 d747 2 a748 1 { "sparse", no_argument, 0, 'S' }, d1070 3 d2012 1 a2012 1 (void)fputs("usage: tar [-]{crtux}[-befhjlmopqvwzHLOPXZ014578] [archive] " @ 1.78 log @PR/19490: Julio Merino: Teach tar about --sparse, -S option. Do it for cpio too. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.77 2004/09/22 14:52:00 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.77 2004/09/22 14:52:00 christos Exp $"); d1156 4 d1247 5 @ 1.77 log @update the comment that documents the fields initialized in the array below. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.76 2004/06/20 22:20:14 jmc Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.76 2004/06/20 22:20:14 jmc Exp $"); d125 1 d745 1 a771 1 { "sparse", no_argument, 0, 'S' }, d813 1 a813 1 "+b:cef:hjklmopqrs:tuvwxzBC:HI:OPT:X:Z014578", d1008 3 d1335 2 a1356 2 { "sparce", no_argument, 0, OPT_SPARSE }, d1624 4 @ 1.76 log @Completely rework how tools/compat is done. Purge all uses/references to _NETBSD_SOURCE as this makes cross building from older/newer versions of NetBSD harder, not easier (and also makes the resulting tools 'different') Wrap all required code with the inclusion of nbtool_config.h, attempt to only use POSIX code in all places (or when reasonable test w. configure and provide definitions: ala u_int, etc). Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86 NetBSD current (x86 and amd64) and Solaris 9. Fixes PR's: PR#17762 PR#25944 @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.75 2004/06/19 02:27:00 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.75 2004/06/19 02:27:00 christos Exp $"); d132 1 a132 1 * rd_data, wr_data, options @ 1.75 log @add -0 argument to handle nul separated file lists. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.74 2004/05/11 17:12:26 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.74 2004/05/11 17:12:26 christos Exp $"); d56 3 d60 1 @ 1.74 log @Welcome to WARNS=3 @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.73 2004/02/20 05:16:54 uebayasi Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.73 2004/02/20 05:16:54 uebayasi Exp $"); d178 5 d237 1 a237 1 "ab:cdf:ijklno:p:rs:tuvwx:zAB:DE:G:HLMN:OPT:U:XYZ", d240 3 @ 1.73 log @Tar(1)'s -s option needs an argument. Correct option string (s -> s:). Reported and tested by Tomoaki Imamura. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.72 2004/02/06 18:59:14 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.72 2004/02/06 18:59:14 christos Exp $"); d77 1 a77 1 static char *flgch = FLGCH; /* list of all possible flags (pax) */ d474 1 a474 1 * indicate a limit, "NONE" try forever d477 1 a477 1 if (strcmp(NONE, optarg) == 0) d1718 1 a1718 1 return(strcmp(((FSUB *)a)->name, ((FSUB *)b)->name)); @ 1.73.2.1 log @Pull up revision 1.76 (requested by jmc in ticket #527): Completely rework how tools/compat is done. Purge all uses/references to _NETBSD_SOURCE as this makes cross building from older/newer versions of NetBSD harder, not easier (and also makes the resulting tools 'different') Wrap all required code with the inclusion of nbtool_config.h, attempt to only use POSIX code in all places (or when reasonable test w. configure and provide definitions: ala u_int, etc). Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86 NetBSD current (x86 and amd64) and Solaris 9. Fixes PR's: PR#17762 PR#25944 @ text @d1 1 a1 1 /* $NetBSD$ */ d45 1 a45 1 __RCSID("$NetBSD$"); a55 3 #if HAVE_NBTOOL_CONFIG_H #include "compat_getopt.h" #else a56 1 #endif @ 1.73.2.1.2.1 log @Pull up revision 1.82 (requested by tron in ticket #952): Fix broken cpio(1) option handling: o "cpio -i -t" should list the contents of a file, not extract it. o Don't extract a file when only option "-d" is given. Fixes PR#26513. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.73.2.1 2004/06/22 07:28:58 tron Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.73.2.1 2004/06/22 07:28:58 tron Exp $"); d1407 1 a1475 1 flg &= ~RF; @ 1.73.2.1.2.2 log @Pull up revision 1.83 (requested by kleink in ticket #1554): Fix from PR#29290. Properly terminate the cpio_longopts struct so an unknown option doesn't run off the end and core dump @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.73.2.1.2.1 2005/01/30 13:20:27 he Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.73.2.1.2.1 2005/01/30 13:20:27 he Exp $"); a1347 1 { 0, 0, 0, 0 }, @ 1.73.2.1.2.3 log @Apply patch (requested by riz in ticket #5512): Sync pax with HEAD of 2005-07-22. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.73.2.1.2.2 2005/05/29 23:18:53 riz Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.73.2.1.2.2 2005/05/29 23:18:53 riz Exp $"); d52 1 d81 1 a81 1 static char flgch[] = FLGCH; /* list of all possible flags (pax) */ a93 1 #ifndef NO_CPIO a95 1 #endif a124 4 #define OPT_SPARSE 16 #if !HAVE_NBTOOL_CONFIG_H #define OPT_CHROOT 17 #endif d132 1 a132 1 * subtrail, rd_data, wr_data, options a135 1 #ifndef NO_CPIO d155 1 a155 1 #endif a165 1 #ifndef NO_CPIO a171 4 #else #define F_TAR 0 /* old V7 UNIX tar format */ #define F_USTAR 1 /* ustar format */ #endif d179 1 a179 10 int ford[] = {F_USTAR, F_TAR, #ifndef NO_CPIO F_SV4CRC, F_SV4CPIO, F_CPIO, F_BCPIO, #endif -1}; /* * filename record separator */ int sep = '\n'; d199 1 a199 2 if (strstr(argv0, NM_TAR)) { argv0 = NM_TAR; d201 1 a201 3 #ifndef NO_CPIO } else if (strstr(argv0, NM_CPIO)) { argv0 = NM_CPIO; d203 1 a203 2 #endif } else { a213 1 { 0, 0, 0 }, d236 1 a236 1 "0ab:cdf:ijklno:p:rs:tuvwx:zAB:DE:G:HLMN:OPT:U:XYZ", a238 3 case '0': sep = '\0'; break; d478 1 a478 1 * indicate a limit, "none" try forever d481 1 a481 1 if (strcmp(none, optarg) == 0) a717 1 { "sparse", no_argument, 0, 'S' }, a735 6 { "no-recursion", no_argument, 0, OPT_NORECURSE }, #if !HAVE_NBTOOL_CONFIG_H { "chroot", no_argument, 0, OPT_CHROOT }, #endif d762 1 d774 2 d804 1 a804 1 "+b:cef:hjklmopqrs:tuvwxzBC:HI:OPST:X:Z014578", a998 3 case 'S': /* do nothing; we already generate sparse files */ break; a1054 8 case OPT_NORECURSE: dflag = 1; break; #if !HAVE_NBTOOL_CONFIG_H case OPT_CHROOT: do_chroot = 1; break; #endif d1122 1 a1122 1 } else { a1123 2 dir = NULL; } a1143 4 if (strncmp(str, "-C ", 3) == 0) { dir = str + 3; continue; } d1201 1 a1201 1 } else { a1202 2 dir = NULL; } a1230 5 if (strncmp(str, "-C ", 3) == 0) { if (ftree_add(str + 3, 1) < 0) tar_usage(); continue; } a1299 1 #ifndef NO_CPIO a1322 2 { "sparse", no_argument, 0, OPT_SPARSE }, d1343 2 a1612 4 case OPT_SPARSE: /* do nothing; we already generate sparse files */ break; a1694 1 #endif d1723 1 a1723 1 return(strcmp(((const FSUB *)a)->name, ((const FSUB *)b)->name)); a1765 1 #ifndef NO_CPIO a1767 1 #endif d1982 1 a1982 1 (void)fputs("usage: tar [-]{crtux}[-befhjlmopqvwzHOPSXZ014578] [archive] " a1989 1 #ifndef NO_CPIO a2010 1 #endif @ 1.72 log @recognize -k [--keep-old-files] short option. From hubertf. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.71 2004/01/05 23:23:32 jmmv Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.71 2004/01/05 23:23:32 jmmv Exp $"); d800 1 a800 1 "+b:cef:hjklmopqrstuvwxzBC:HI:OPT:X:Z014578", @ 1.71 log @Homogenize usage messages: make the 'usage' word all lowercase, as this seems to be the most common practice in our tree. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.70 2004/01/05 17:27:46 jmmv Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.70 2004/01/05 17:27:46 jmmv Exp $"); d800 1 a800 1 "+b:cef:hjlmopqrstuvwxzBC:HI:OPT:X:Z014578", @ 1.70 log @Rewrite the loop in printflg(): if passing -Z to pax with syntax errors (like executing "pax -Z" by itself), this caused a shr of 32 bits, which is undefined behavior (C99) if the variable is 32 bits wide, too. Also solves a problem where the flgch array could be indexed out of bounds. Thanks to uwe@@ and lha@@ for their suggestions... I just found the bug :p @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.69 2003/10/27 00:12:41 lukem Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.69 2003/10/27 00:12:41 lukem Exp $"); d1949 1 a1949 1 "Usage: pax [-cdjnvzO] [-E limit] [-f archive] [-N dbdir] [-s replstr] ...\n" d1977 1 a1977 1 (void)fputs("Usage: tar [-]{crtux}[-befhjlmopqvwzHLOPXZ014578] [archive] " d1994 1 a1994 1 (void)fputs("Usage: cpio -o [-aABcLvzZ] [-C bytes] [-F archive] " @ 1.69 log @Overhaul how `build.sh tools' are used: * Rename "config.h" to "nbtool_config.h" and HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H. This makes in more obvious in the source when we're using tools/compat/config.h versus "standard autoconf" config.h * Consistently move the inclusion of nbtool_config.h to before so that the former can provide __RCSID() (et al), and there's no need to protect those macros any more. These changes should make it easier to "tool-ify" a program by adding: #if HAVE_NBTOOL_CONFIG_H #include "nbtool_config.h" #endif to the top of the source files (for the general case). @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.68 2003/10/21 02:08:14 fvdl Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.68 2003/10/21 02:08:14 fvdl Exp $"); a1699 1 int pos = 0; d1703 2 a1704 3 flg = flg >> nxt; pos += nxt; (void)fprintf(stderr, " -%c", flgch[pos-1]); @ 1.68 log @Don't pass an integer as NULL. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.67 2003/10/13 07:41:22 agc Exp $ */ d36 4 d41 1 a41 1 #if defined(__RCSID) && !defined(lint) d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.67 2003/10/13 07:41:22 agc Exp $"); @ 1.67 log @Move Keith Muller's code from a 4-clause to a 3-clause licence by removing the advertising clause. Diffs provided in PR 22397 by Joel Baker, confirmed to the board by Keith Muller. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.66 2003/08/07 09:05:21 agc Exp $ */ d41 1 a41 1 __RCSID("$NetBSD: options.c,v 1.66 2003/08/07 09:05:21 agc Exp $"); d1674 1 a1674 1 ftree_add(str, NULL); @ 1.66 log @Move UCB-licensed code from 4-clause to 3-clause licence. Patches provided by Joel Baker in PR 22249, verified by myself. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.65 2003/07/08 06:00:48 simonb Exp $ */ d4 1 a35 35 /*- * Copyright (c) 1992 Keith Muller. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ d41 1 a41 1 __RCSID("$NetBSD: options.c,v 1.65 2003/07/08 06:00:48 simonb Exp $"); @ 1.65 log @Add support for gnutar's -O "extract to stdout" option. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.64 2003/04/08 15:13:10 christos Exp $ */ a3 1 * Copyright (c) 1992 Keith Muller. d18 31 d75 1 a75 1 __RCSID("$NetBSD: options.c,v 1.64 2003/04/08 15:13:10 christos Exp $"); @ 1.64 log @PR/21064: Perry Metzger: Re-add -k to tar (--keep-old-files) @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.63 2003/03/31 20:10:08 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.63 2003/03/31 20:10:08 christos Exp $"); d712 1 a752 1 { "to-stdout", no_argument, 0, 'O' }, d1079 7 a1085 2 tty_warn(1, "The -O/-o options are only valid when writing an archive"); tar_usage(); /* only valid when writing */ @ 1.63 log @PR/20495: Soren Jacobsen: Add -j [bzip2] compression to tar. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.62 2003/02/25 13:37:00 wiz Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.62 2003/02/25 13:37:00 wiz Exp $"); d691 1 a746 1 { "keep-old-files", no_argument, 0, 'k' }, d853 6 @ 1.62 log @Add support for '-j' to create (and extract, but -z already did that) bzip2 compressed tar files, for GNU tar compatibility. Patch from Soren Jacobsen in PR 19467, okayed by christos. Sync usage with options while here. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.61 2003/02/02 10:21:14 wiz Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.61 2003/02/02 10:21:14 wiz Exp $"); d232 1 a232 1 "ab:cdf:iklno:p:rs:tuvwx:zAB:DE:G:HLMN:OPT:U:XYZ", d279 7 d1940 1 a1940 1 "Usage: pax [-cdnvzO] [-E limit] [-f archive] [-N dbdir] [-s replstr] ...\n" d1944 1 a1944 1 " pax -r [-cdiknuvzADOYZ] [-E limit] [-f archive] [-N dbdir]\n" d1948 1 a1948 1 " pax -w [-dituvzAHLMOPX] [-b blocksize] [[-a] [-f archive]] [-x format]\n" d1953 1 a1953 1 " pax -r -w [-diklntuvzADHLMOPXYZ] [-N dbdir] [-p string] ...\n" @ 1.61 log @Fix various spelling, grammar, and punctuation problems in comments, from Sergey Svishchev in PR 20164. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.60 2003/01/19 01:13:46 wiz Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.60 2003/01/19 01:13:46 wiz Exp $"); d98 1 d678 2 d793 1 a793 1 "+b:cef:hlmopqrstuvwxzBC:HI:OPT:X:Z014578", d840 7 d1961 1 a1961 1 (void)fputs("Usage: tar [-]{crtux}[-befhmopqvwzHLOPXZ014578] [archive] " @ 1.60 log @tar(1) has no -L any longer. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.59 2003/01/15 21:56:46 kristerw Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.59 2003/01/15 21:56:46 kristerw Exp $"); d171 1 a171 1 * of archive we are dealing with. This helps to properly id archive formats @ 1.59 log @Correct which _usage function to use for some pax/cpio error cases. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.58 2003/01/09 17:26:21 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.58 2003/01/09 17:26:21 christos Exp $"); a737 1 /* XXX: Conflicts with current -L */ @ 1.58 log @PR/19757: Andreas Wrede: make tar's -h behave like pax's -L @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.57 2002/12/08 01:35:13 mrg Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.57 2002/12/08 01:35:13 mrg Exp $"); d653 1 a653 1 cpio_usage(); d1486 1 a1486 1 tar_usage(); d1523 1 a1523 1 tar_usage(); @ 1.57 log @add --exclude support. XXX: --exclude & --exclude-from are still not 100% compatible, but since rafal fixed --exclude-from's most annoying bug, they mostly work now. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.56 2002/11/27 18:40:34 grant Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.56 2002/11/27 18:40:34 grant Exp $"); d791 1 a791 1 "+b:cef:hlmopqrstuvwxzBC:HI:LOPT:X:Z014578", d834 1 a834 1 * follow command line symlinks only d836 1 a836 1 Hflag = 1; a964 6 break; case 'L': /* * follow symlinks */ Lflag = 1; @ 1.56 log @void functions should not return a value. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.55 2002/10/18 13:45:05 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.55 2002/10/18 13:45:05 christos Exp $"); d718 2 a758 2 { "exclude", required_argument, 0, OPT_EXCLUDE }, d1030 4 @ 1.55 log @Handle -C\ndir\n in a file containing a file list. From Eric Gillespie. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.54 2002/10/17 00:42:02 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.54 2002/10/17 00:42:02 christos Exp $"); d195 1 a195 1 return(tar_options(argc, argv)); d197 1 a197 1 return(cpio_options(argc, argv)); d200 1 a200 1 return(pax_options(argc, argv)); @ 1.54 log @Fix DEFOP botch. DEFOP == LIST so tar -tvf stopped working. (hi soren) @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.53 2002/10/16 23:37:49 soren Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.53 2002/10/16 23:37:49 soren Exp $"); d1072 1 d1106 9 d1119 3 d1177 1 d1192 10 d1205 3 @ 1.53 log @Tweak tar_usage(). @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.52 2002/10/16 23:22:59 soren Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.52 2002/10/16 23:22:59 soren Exp $"); d1040 1 a1040 1 if (act == DEFOP) a1316 1 act = -1; @ 1.52 log @Have tar require a specific action as documented. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.51 2002/10/16 22:38:36 soren Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.51 2002/10/16 22:38:36 soren Exp $"); d1928 1 a1928 1 (void)fputs("Usage: tar -{crtux}[-befhmopqvwzHLOPXZ014578] [archive] " @ 1.51 log @Sync cpio_usage() with cpio.1 as with pax and tar. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.50 2002/10/16 21:45:31 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.50 2002/10/16 21:45:31 christos Exp $"); d1038 4 @ 1.50 log @we need to have -force-local on pax. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.49 2002/10/16 18:53:40 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.49 2002/10/16 18:53:40 christos Exp $"); d1941 9 a1949 20 #if 1 (void)fputs( "Usage: cpio -i [-BcdfmrStuv] [ -C blksize ] [ -H header ]\n", stderr); (void)fputs(" [ -I file ] [ pattern ... ]\n", stderr); (void)fputs("Usage: cpio -o [-aABcLv] [ -C bufsize ] [ -H header ]\n", stderr); (void)fputs(" [ -O file ]\n", stderr); (void)fputs("Usage: cpio -p [ adlLmuv ] directory\n", stderr); #else /* no E, M, R, V, b, k or s */ (void)fputs("Usage: cpio -i [-bBcdfkmrsStuvV] [ -C bufsize ]\n", stderr); (void)fputs(" [ -E file ] [ -H header ] [ -I file [ -M message ] ]\n", stderr); (void)fputs(" [ -R id ] [ pattern ... ]\n", stderr); (void)fputs("Usage: cpio -o [-aABcLvV] [ -C bufsize ] [ -H header ]\n", stderr); (void)fputs(" [ -O file [ -M message ] ]\n", stderr); (void)fputs("Usage: cpio -p [ adlLmuvV ] [ -R id ] directory\n", stderr); #endif @ 1.49 log @turn gnu tar off by pax and cpio front ends. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.48 2002/10/16 03:46:08 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.48 2002/10/16 03:46:08 christos Exp $"); d207 2 d589 3 a700 1 { "tape-length", required_argument, 0, 'L' }, d736 2 @ 1.48 log @Support gnu long filename extensions by default for tar on create, list, and extract. We now generate GNU tar archives by default ("ustar ^@@" instead of "ustar^@@00"). GNU extensions can be disabled with --strict. XXX: long symlinks untested. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.47 2002/10/15 16:16:29 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.47 2002/10/15 16:16:29 christos Exp $"); d779 1 @ 1.47 log @PR/18663: Jeremy Reed: pax/tar/cpio allows ".." in names. We now disallow it by default on both archive creation and extraction. Add --insecure option to override. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.46 2002/10/15 14:58:53 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.46 2002/10/15 14:58:53 christos Exp $"); d119 1 d702 2 d849 2 a854 2 /* GNU tar: write V7 format archives. */ frmt = &(fsub[F_TAR]); d1020 4 d1695 2 a1696 1 tty_warn(1,"These format options are not supported"); d1699 6 a1704 1 pax_usage(); d1889 1 a1889 1 "usage: pax [-cdnvzO] [-E limit] [-f archive] [-N dbdir] [-s replstr] ...\n" d1917 1 a1917 1 (void)fputs("usage: tar -{crtux}[-befhmopqvwzHLOPXZ014578] [archive] " d1936 1 a1936 1 "usage: cpio -i [-BcdfmrStuv] [ -C blksize ] [ -H header ]\n", d1939 1 a1939 1 (void)fputs("usage: cpio -o [-aABcLv] [ -C bufsize ] [ -H header ]\n", d1942 1 a1942 1 (void)fputs("usage: cpio -p [ adlLmuv ] directory\n", stderr); d1945 1 a1945 1 (void)fputs("usage: cpio -i [-bBcdfkmrsStuvV] [ -C bufsize ]\n", stderr); d1949 1 a1949 1 (void)fputs("usage: cpio -o [-aABcLvV] [ -C bufsize ] [ -H header ]\n", d1952 1 a1952 1 (void)fputs("usage: cpio -p [ adlLmuvV ] [ -R id ] directory\n", stderr); @ 1.46 log @implement fast read. nothing to it really, it was already there as -q option. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.45 2002/10/15 14:51:04 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.45 2002/10/15 14:51:04 christos Exp $"); d102 19 d203 5 d227 3 a229 2 while ((c = getopt(argc, argv, "ab:cdf:iklno:p:rs:tuvwx:zAB:DE:G:HLMN:OPT:U:XYZ")) != -1) { d583 3 a668 15 #define OPT_USE_COMPRESS_PROGRAM 0 #define OPT_CHECKPOINT 1 #define OPT_UNLINK 2 #define OPT_HELP 3 #define OPT_ATIME_PRESERVE 4 #define OPT_IGNORE_FAILED_READ 5 #define OPT_REMOVE_FILES 6 #define OPT_NULL 7 #define OPT_TOTALS 8 #define OPT_VERSION 9 #define OPT_EXCLUDE 10 #define OPT_BLOCK_COMPRESS 11 #define OPT_NORECURSE 12 #define OPT_FORCE_LOCAL 13 d709 2 d1014 3 d1243 1 a1243 1 OPT_FORCE_LOCAL }, d1247 2 d1260 1 a1260 1 OPT_BLOCK_SIZE }, d1262 1 a1262 1 OPT_NO_ABSOLUTE_PATHNAMES }, d1264 1 a1264 1 OPT_NO_PRESERVE_OWNER }, d1266 1 a1266 1 OPT_ONLY_VERIFY_CRC }, d1268 1 a1268 1 OPT_RSH_COMMAND }, d1270 1 a1270 1 OPT_SPARSE }, d1272 1 a1272 1 OPT_VERSION }, d1305 1 a1305 1 "abcdfiklmoprstuvzABC:E:F:H:I:LM:O:R:SVZ6", d1535 3 @ 1.45 log @Add all the gnu cpio long options. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.44 2002/10/14 15:04:41 soren Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.44 2002/10/14 15:04:41 soren Exp $"); d646 9 a654 10 #define OPT_FAST_READ 5 #define OPT_IGNORE_FAILED_READ 6 #define OPT_REMOVE_FILES 7 #define OPT_NULL 8 #define OPT_TOTALS 9 #define OPT_VERSION 10 #define OPT_EXCLUDE 11 #define OPT_BLOCK_COMPRESS 12 #define OPT_NORECURSE 13 #define OPT_FORCE_LOCAL 14 d669 1 a706 2 { "fast-read", no_argument, 0, OPT_FAST_READ }, @ 1.44 log @Sync tar_usage() with tar.1. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.43 2002/10/13 17:23:40 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.43 2002/10/13 17:23:40 christos Exp $"); d1209 49 d1287 2 a1288 1 "abcdfiklmoprstuvzABC:E:F:H:I:LM:O:R:SVZ6", NULL, NULL)) != -1) { d1515 3 @ 1.43 log @-T expects an argument. From Eric Gillespie, thanks. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.42 2002/10/13 11:31:02 mrg Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.42 2002/10/13 11:31:02 mrg Exp $"); d1830 4 a1833 3 (void)fputs("usage: tar -{txru}[cevfbhlmopwBLPX014578] [tapefile] ", stderr); (void)fputs("[blocksize] [exclude-file] file1 file2...\n", stderr); @ 1.42 log @fix "pax -rw" processing. for some reason, it was now written to process "pax -rwvpe a b" as "pax -rwvpe b a", and "pax -rwvpe a b c" as "pax -rwvpe b c a". only the part of revision 1.40 that broken this has been reverted. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.41 2002/10/13 00:32:09 mrg Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.41 2002/10/13 00:32:09 mrg Exp $"); d768 1 a768 1 "+b:cef:hlmopqrstuvwxzBC:HI:LOPTX:Z014578", @ 1.41 log @add a "+" to the options string rather than setting POSIXLY_CORRECT @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.40 2002/10/12 15:39:29 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.40 2002/10/12 15:39:29 christos Exp $"); d616 2 a617 1 dirptr = argv[optind++]; @ 1.40 log @merge OpenBSD changes: - correct -C processing - add ability to read filenames and flags from a file - don't print dangerous escape sequences to the terminal - use strlcpy/strncpy properly. - handle tmpfile creation better. - improve documentation of options. - handle stdout/stderr list selection correctly. - kill gzip when we get interrupted. - simplify gzip setup. - add more flags to programs. additional changes: - librmt processing. - set POSIXLY_CORRECT in options parsing. - prevent more string overruns. - support -T we don't turn the switch on to replace tar and cpio yet. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.39 2002/02/02 12:34:39 lukem Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.39 2002/02/02 12:34:39 lukem Exp $"); d767 1 a767 1 "b:cef:hlmopqrstuvwxzBC:HI:LOPTX:Z014578", @ 1.39 log @- don't compile in support for -M (mtree specfile input) or -N dbdir (alternate directory for id info) if SMALL is defined - enable -DSMALL and remove unused objects if CRUNCHEDPROG is defined - minor cleanup in next_file() (preparation for future work) @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.38 2002/01/31 22:43:35 tv Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.38 2002/01/31 22:43:35 tv Exp $"); d55 1 d62 1 a75 2 int cpio_mode; /* set if we are in cpio mode */ a79 1 static char *firstminusC; /* first -C argument encountered. */ d85 1 d93 4 a96 1 static void checkpositionalminusC(char ***, int (*)(char *, int)); d175 1 a175 1 tar_options(argc, argv); d177 1 a177 1 cpio_options(argc, argv); d180 1 a180 1 pax_options(argc, argv); d330 2 a331 2 tty_warn(1, "Invalid -p string: %c", *pt); a402 1 zflag = 1; d572 1 d608 1 a608 1 if (pat_add(argv[optind], 0) < 0) d616 3 a618 2 --argc; dirptr = argv[argc]; d654 1 d683 1 d693 2 a724 1 { "files-from", no_argument, 0, 'T' }, d749 13 d766 2 a767 1 while ((c = getoldopt(argc, argv, "b:cef:hlmoprutvwxzBC:LPX:Z014578", d773 1 a773 1 * specify blocksize d779 1 a786 7 case 'C': /* * chdir here before extracting. * do so lazily, in case it's a list */ firstminusC = optarg; break; d802 1 a802 1 arcname = (char *)0; d844 3 d858 6 d871 9 d900 2 a901 1 * write an archive d904 1 d918 24 d949 4 d997 3 d1008 5 a1012 2 if (firstminusC && (opt_chdir(firstminusC) < 0)) tty_warn(1, "can't remember -C directory"); d1014 3 d1019 1 d1021 6 a1026 2 if (act == ARCHIVE && frmt == NULL) frmt = &(fsub[F_USTAR]); d1033 1 d1035 62 a1096 6 while (*argv != (char *)NULL) if (pat_add(*argv++, 0) < 0) tar_usage(); break; case EXTRACT: checkpositionalminusC(&argv, pat_add); d1100 61 a1160 1 checkpositionalminusC(&argv, ftree_add); d1169 34 a1202 2 if ((arcname == (char *)NULL) || (*arcname == '\0')) arcname = DEV_8; d1204 2 d1221 2 d1224 9 a1232 1 cpio_mode = uflag = 1; d1237 1 a1237 1 "ABC:E:H:I:LM:O:R:SVabcdfiklmoprstuv", NULL, NULL)) != -1) { a1238 81 case 'A': /* * append to an archive */ act = APPND; flg |= AF; break; case 'B': /* * set blocksize to 5120 */ blksz = 5120; break; case 'C': /* * specify blocksize */ if ((blksz = (int)str_offt(optarg)) <= 0) { tty_warn(1, "Invalid block size %s", optarg); tar_usage(); } break; #ifdef notyet case 'E': arg = optarg; break; #endif case 'H': /* * specify an archive format on write */ tmp.name = optarg; frmt = (FSUB *)bsearch((void *)&tmp, (void *)fsub, sizeof(fsub)/sizeof(FSUB), sizeof(FSUB), c_frmt); if (frmt != NULL) { flg |= XF; break; } tty_warn(1, "Unknown -H format: %s", optarg); (void)fputs("cpio: Known -H formats are:", stderr); for (i = 0; i < (sizeof(fsub)/sizeof(FSUB)); ++i) (void)fprintf(stderr, " %s", fsub[i].name); (void)fputs("\n\n", stderr); tar_usage(); break; case 'I': case 'O': /* * filename where the archive is stored */ if ((optarg[0] == '-') && (optarg[1]== '\0')) { /* * treat a - as stdin */ arcname = (char *)0; break; } arcname = optarg; break; case 'L': /* * follow symlinks */ Lflag = 1; flg |= CLF; break; #ifdef notyet case 'M': arg = optarg; break; case 'R': arg = optarg; break; #endif case 'S': cpio_swp_head = 1; break; #ifdef notyet case 'V': break; #endif d1248 3 d1254 3 d1261 1 d1264 1 d1278 1 d1303 2 d1311 1 d1323 3 d1329 3 d1333 1 d1340 1 d1350 114 d1523 6 a1528 3 for (; optind < argc; optind++) if (ftree_add(argv[optind], 0) < 0) cpio_usage(); d1533 10 d1636 1 d1642 5 a1646 1 frpt = endpt = strdup(str); d1658 1 d1663 1 d1756 23 a1866 45 } /* * opt_chdir * call ftree_add or pat_add, depending on archive type. * * Returns: -1 for listing, else what ftree_add or pat_add returned. */ int opt_chdir(char *name) { switch (act) { default: return (-1); break; case ARCHIVE: case APPND: return (ftree_add(name, 1)); break; case EXTRACT: return (pat_add(name, 1)); break; } } /* * checkpositionalminusC(argvp, addfunc) */ void checkpositionalminusC(char ***argvp, int (*addfunc)(char *, int)) { while (**argvp != (char *)NULL) { if (!strcmp(**argvp, "-C")) { /* XXX should be allow for positional -C/dir, too? */ if ((*addfunc)(*++*argvp, 1) < 0) { tar_usage(); } ++*argvp; continue; } if ((*addfunc)(*(*argvp)++, 0) < 0) tar_usage(); } @ 1.39.2.1 log @Pullup rev 1.40-1.73 (requested by rafal in ticket #1021) Pullup pax to current version on trunk. Includes many fixes. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.39 2002/02/02 12:34:39 lukem Exp $ */ d19 5 a23 1 * 3. Neither the name of the University nor the names of its contributors a39 4 #if HAVE_NBTOOL_CONFIG_H #include "nbtool_config.h" #endif d41 1 a41 1 #if !defined(lint) d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.39 2002/02/02 12:34:39 lukem Exp $"); a54 1 #include a60 1 #include d74 2 d80 1 a85 1 static char *getline(FILE *fp); d93 1 a93 4 /* errors from getline */ #define GETLINE_FILE_CORRUPT 1 #define GETLINE_OUT_OF_MEM 2 static int getline_error; a94 1 #define BZIP2_CMD "bzip2" /* command to run as bzip2 */ a98 20 * Long options. */ #define OPT_USE_COMPRESS_PROGRAM 0 #define OPT_CHECKPOINT 1 #define OPT_UNLINK 2 #define OPT_HELP 3 #define OPT_ATIME_PRESERVE 4 #define OPT_IGNORE_FAILED_READ 5 #define OPT_REMOVE_FILES 6 #define OPT_NULL 7 #define OPT_TOTALS 8 #define OPT_VERSION 9 #define OPT_EXCLUDE 10 #define OPT_BLOCK_COMPRESS 11 #define OPT_NORECURSE 12 #define OPT_FORCE_LOCAL 13 #define OPT_INSECURE 14 #define OPT_STRICT 15 /* d148 1 a148 1 * of archive we are dealing with. This helps to properly id archive formats a180 7 struct option pax_longopts[] = { { "insecure", no_argument, 0, OPT_INSECURE }, { "force-local", no_argument, 0, OPT_FORCE_LOCAL }, }; d200 2 a201 3 while ((c = getopt_long(argc, argv, "ab:cdf:ijklno:p:rs:tuvwx:zAB:DE:G:HLMN:OPT:U:XYZ", pax_longopts, NULL)) != -1) { a246 7 case 'j': /* * pass through bzip2 */ jflag = 1; gzip_program = BZIP2_CMD; break; d327 2 a328 2 tty_warn(1, "Invalid -p string: %c", *pt); d400 1 a555 6 case OPT_INSECURE: secure = 0; break; case OPT_FORCE_LOCAL: forcelocal = 0; break; a569 1 listf = stdout; d605 1 a605 1 if (pat_add(argv[optind], NULL) < 0) a614 2 if (mkpath(dirptr) < 0) pax_usage(); d636 15 a652 2 { "bunzip2", no_argument, 0, 'j' }, { "bzip2", no_argument, 0, 'j' }, a656 1 { "keep-old-files", no_argument, 0, 'k' }, a663 1 { "fast-read", no_argument, 0, 'q' }, d676 1 a676 1 { "to-stdout", no_argument, 0, 'O' }, a677 1 { "files-from", required_argument, 0, 'T' }, a680 2 { "strict", no_argument, 0, OPT_STRICT }, a686 6 { "force-local", no_argument, 0, OPT_FORCE_LOCAL }, { "insecure", no_argument, 0, OPT_INSECURE }, { "exclude", required_argument, 0, OPT_EXCLUDE }, d698 2 d705 1 a706 1 { "tape-length", required_argument, 0, 'L' }, d710 1 d717 1 d727 2 a741 14 int Oflag = 0; int nincfiles = 0; int incfiles_max = 0; struct incfile { char *file; char *dir; }; struct incfile *incfiles = NULL; /* * Set default values. */ rmleadslash = 1; is_gnutar = 1; d746 1 a746 2 while ((c = getoldopt(argc, argv, "+b:cef:hjklmopqrs:tuvwxzBC:HI:OPT:X:Z014578", d752 1 a752 1 * specify blocksize in 512-byte blocks a757 1 wrblksz *= 512; /* XXX - check for int oflow */ d765 7 d787 1 a787 1 arcname = NULL; d795 1 a795 1 * follow symlinks d797 1 a797 14 Lflag = 1; break; case 'j': /* * pass through bzip2. not a standard option */ jflag = 1; gzip_program = BZIP2_CMD; break; case 'k': /* * do not clobber files that exist */ kflag = 1; a816 2 /* GNU tar: write V7 format archives. */ Oflag = 1; d821 2 a828 3 case 'O': Oflag = 1; break; a839 6 case 'q': /* * select first match for a pattern only */ nflag = 1; break; a846 9 case 's': /* * file name substitution name pattern */ if (rep_add(optarg) < 0) { tar_usage(); break; } break; d867 1 a867 2 * extract an archive, preserving mode, * and mtime if possible. a869 1 pmtime = 1; d883 1 a883 4 case 'C': chdname = optarg; break; case 'H': d885 1 a885 1 * follow command line symlinks only d887 1 a887 16 Hflag = 1; break; case 'I': case 'T': if (++nincfiles > incfiles_max) { incfiles_max = nincfiles + 3; incfiles = realloc(incfiles, sizeof(*incfiles) * incfiles_max); if (incfiles == NULL) { tty_warn(0, "Unable to allocate space " "for option list"); exit(1); } } incfiles[nincfiles - 1].file = optarg; incfiles[nincfiles - 1].dir = chdname; a889 4 /* * do not remove leading '/' from pathnames */ rmleadslash = 0; a933 14 case OPT_FORCE_LOCAL: forcelocal = 1; break; case OPT_INSECURE: secure = 0; break; case OPT_STRICT: /* disable gnu extensions */ is_gnutar = 0; break; case OPT_EXCLUDE: if (tar_gnutar_minus_minus_exclude(optarg) != 0) tar_usage(); break; d942 2 a943 9 /* Tar requires an action. */ if (act == ERROR) tar_usage(); /* Traditional tar behaviour (pax uses stderr unless in list mode) */ if (fstdin == 1 && act == ARCHIVE) listf = stderr; else listf = stdout; a944 3 /* Traditional tar behaviour (pax wants to read file list from stdin) */ if ((act == ARCHIVE || act == APPND) && argc == 0 && nincfiles == 0) exit(0); a946 1 * (unless -o specified) d948 2 a949 11 if (act == ARCHIVE || act == APPND) frmt = &(fsub[Oflag ? F_TAR : F_USTAR]); else if (Oflag) { if (act == EXTRACT) to_stdout = 1; else { tty_warn(1, "The -O/-o options are only valid when " "writing or extracting an archive"); tar_usage(); } } d956 5 d962 1 a962 76 default: { int sawpat = 0; int dirisnext = 0; char *file, *dir; while (nincfiles || *argv != NULL) { /* * If we queued up any include files, * pull them in now. Otherwise, check * for -I and -C positional flags. * Anything else must be a file to * extract. */ if (nincfiles) { file = incfiles->file; dir = incfiles->dir; incfiles++; nincfiles--; } else if (strcmp(*argv, "-I") == 0) { if (*++argv == NULL) break; file = *argv++; dir = chdname; } else file = NULL; if (file != NULL) { FILE *fp; char *str; if (strcmp(file, "-") == 0) fp = stdin; else if ((fp = fopen(file, "r")) == NULL) { tty_warn(1, "Unable to open file '%s' for read", file); tar_usage(); } while ((str = getline(fp)) != NULL) { if (dirisnext) { dir = str; dirisnext = 0; continue; } if (strcmp(str, "-C") == 0) { dirisnext = 1; continue; } if (pat_add(str, dir) < 0) tar_usage(); sawpat = 1; } /* Bomb if given -C w/out a dir. */ if (dirisnext) tar_usage(); if (strcmp(file, "-") != 0) fclose(fp); if (getline_error) { tty_warn(1, "Problem with file '%s'", file); tar_usage(); } } else if (strcmp(*argv, "-C") == 0) { if (*++argv == NULL) break; chdname = *argv++; } else if (pat_add(*argv++, chdname) < 0) tar_usage(); else sawpat = 1; } /* * if patterns were added, we are doing chdir() * on a file-by-file basis, else, just one * global chdir (if any) after opening input. */ if (sawpat > 0) chdname = NULL; } d966 1 a966 75 if (chdname != NULL) { /* initial chdir() */ if (ftree_add(chdname, 1) < 0) tar_usage(); } while (nincfiles || *argv != NULL) { char *file, *dir; /* * If we queued up any include files, pull them in * now. Otherwise, check for -I and -C positional * flags. Anything else must be a file to include * in the archive. */ if (nincfiles) { file = incfiles->file; dir = incfiles->dir; incfiles++; nincfiles--; } else if (strcmp(*argv, "-I") == 0) { if (*++argv == NULL) break; file = *argv++; dir = NULL; } else file = NULL; if (file != NULL) { FILE *fp; char *str; int dirisnext = 0; /* Set directory if needed */ if (dir) { if (ftree_add(dir, 1) < 0) tar_usage(); } if (strcmp(file, "-") == 0) fp = stdin; else if ((fp = fopen(file, "r")) == NULL) { tty_warn(1, "Unable to open file '%s' for read", file); tar_usage(); } while ((str = getline(fp)) != NULL) { if (dirisnext) { if (ftree_add(str, 1) < 0) tar_usage(); dirisnext = 0; continue; } if (strcmp(str, "-C") == 0) { dirisnext = 1; continue; } if (ftree_add(str, 0) < 0) tar_usage(); } /* Bomb if given -C w/out a dir. */ if (dirisnext) tar_usage(); if (strcmp(file, "-") != 0) fclose(fp); if (getline_error) { tty_warn(1, "Problem with file '%s'", file); tar_usage(); } } else if (strcmp(*argv, "-C") == 0) { if (*++argv == NULL) break; if (ftree_add(*argv++, 1) < 0) tar_usage(); } else if (ftree_add(*argv++, 0) < 0) tar_usage(); } d975 2 a976 2 if ((arcname == NULL) || (*arcname == '\0')) arcname = _PATH_DEFTAPE; a979 85 int mkpath(path) char *path; { struct stat sb; char *slash; int done = 0; slash = path; while (!done) { slash += strspn(slash, "/"); slash += strcspn(slash, "/"); done = (*slash == '\0'); *slash = '\0'; if (stat(path, &sb)) { if (errno != ENOENT || mkdir(path, 0777)) { tty_warn(1, "%s", path); return (-1); } } else if (!S_ISDIR(sb.st_mode)) { syswarn(1, ENOTDIR, "%s", path); return (-1); } if (!done) *slash = '/'; } return (0); } struct option cpio_longopts[] = { { "reset-access-time", no_argument, 0, 'a' }, { "make-directories", no_argument, 0, 'd' }, { "nonmatching", no_argument, 0, 'f' }, { "extract", no_argument, 0, 'i' }, { "link", no_argument, 0, 'l' }, { "preserve-modification-time", no_argument, 0, 'm' }, { "create", no_argument, 0, 'o' }, { "pass-through", no_argument, 0, 'p' }, { "rename", no_argument, 0, 'r' }, { "list", no_argument, 0, 't' }, { "unconditional", no_argument, 0, 'u' }, { "verbose", no_argument, 0, 'v' }, { "append", no_argument, 0, 'A' }, { "pattern-file", required_argument, 0, 'E' }, { "file", required_argument, 0, 'F' }, { "force-local", no_argument, 0, OPT_FORCE_LOCAL }, { "format", required_argument, 0, 'H' }, { "dereference", no_argument, 0, 'L' }, { "swap-halfwords", no_argument, 0, 'S' }, { "insecure", no_argument, 0, OPT_INSECURE }, #ifdef notyet /* Not implemented */ { "null", no_argument, 0, '0' }, { "swap", no_argument, 0, 'b' }, { "numeric-uid-gid", no_argument, 0, 'n' }, { "swap-bytes", no_argument, 0, 's' }, { "message", required_argument, 0, 'M' }, { "owner", required_argument, 0 'R' }, { "dot", no_argument, 0, 'V' }, { "block-size", required_argument, 0, OPT_BLOCK_SIZE }, { "no-absolute-pathnames", no_argument, 0, OPT_NO_ABSOLUTE_PATHNAMES }, { "no-preserve-owner", no_argument, 0, OPT_NO_PRESERVE_OWNER }, { "only-verify-crc", no_argument, 0, OPT_ONLY_VERIFY_CRC }, { "rsh-command", required_argument, 0, OPT_RSH_COMMAND }, { "sparce", no_argument, 0, OPT_SPARSE }, { "version", no_argument, 0, OPT_VERSION }, #endif }; a992 2 FILE *fp; char *str; d994 1 a994 8 uflag = 1; kflag = 1; pids = 1; pmode = 1; pmtime = 0; arcname = NULL; dflag = 1; nodirs = 1; d999 1 a999 2 "+abcdfiklmoprstuvzABC:E:F:H:I:LM:O:R:SVZ6", cpio_longopts, NULL)) != -1) { d1001 81 a1090 3 /* * swap bytes and half-words when reading data */ a1093 3 /* * ASCII cpio header */ a1097 1 * create directories as needed a1099 1 nodirs = 0; a1112 1 act = EXTRACT; a1136 2 act = ARCHIVE; frmt = &(fsub[F_SV4CRC]); a1142 1 act = COPY; a1153 3 /* * swap bytes after reading data */ a1156 3 /* * list contents of archive */ a1157 1 listf = stdout; a1163 1 kflag = 0; a1172 120 case 'z': /* * use gzip. Non standard option. */ gzip_program = GZIP_CMD; break; case 'A': /* * append to an archive */ act = APPND; flg |= AF; break; case 'B': /* * set blocksize to 5120 */ blksz = 5120; break; case 'C': /* * specify blocksize */ if ((blksz = (int)str_offt(optarg)) <= 0) { tty_warn(1, "Invalid block size %s", optarg); cpio_usage(); } break; case 'E': /* * file with patterns to extract or list */ if ((fp = fopen(optarg, "r")) == NULL) { tty_warn(1, "Unable to open file '%s' for read", optarg); cpio_usage(); } while ((str = getline(fp)) != NULL) { pat_add(str, NULL); } fclose(fp); if (getline_error) { tty_warn(1, "Problem with file '%s'", optarg); cpio_usage(); } break; case 'H': /* * specify an archive format on write */ tmp.name = optarg; frmt = (FSUB *)bsearch((void *)&tmp, (void *)fsub, sizeof(fsub)/sizeof(FSUB), sizeof(FSUB), c_frmt); if (frmt != NULL) { flg |= XF; break; } tty_warn(1, "Unknown -H format: %s", optarg); (void)fputs("cpio: Known -H formats are:", stderr); for (i = 0; i < (sizeof(fsub)/sizeof(FSUB)); ++i) (void)fprintf(stderr, " %s", fsub[i].name); (void)fputs("\n\n", stderr); cpio_usage(); break; case 'I': case 'O': /* * filename where the archive is stored */ if ((optarg[0] == '-') && (optarg[1]== '\0')) { /* * treat a - as stdin */ arcname = NULL; break; } arcname = optarg; break; case 'L': /* * follow symlinks */ Lflag = 1; flg |= CLF; break; #ifdef notyet case 'M': arg = optarg; break; case 'R': arg = optarg; break; #endif case 'S': /* * swap halfwords after reading data */ cpio_swp_head = 1; break; #ifdef notyet case 'V': break; #endif case 'Z': /* * use compress. Non standard option. */ gzip_program = COMPRESS_CMD; break; case '6': /* * process Version 6 cpio format */ frmt = &(fsub[F_BCPIO]); case OPT_FORCE_LOCAL: forcelocal = 1; break; case OPT_INSECURE: secure = 0; break; d1232 3 a1234 6 if (argc != optind) { for (; optind < argc; optind++) if (ftree_add(argv[optind], 0) < 0) cpio_usage(); break; } a1238 10 while ((str = getline(stdin)) != NULL) { ftree_add(str, 0); } if (getline_error) { tty_warn(1, "Problem while reading stdin"); cpio_usage(); } break; default: cpio_usage(); d1252 1 d1256 3 a1258 2 flg &= ~(1 << (nxt - 1)); (void)fprintf(stderr, " -%c", flgch[nxt - 1]); d1309 1 a1309 2 tty_warn(1," These format options are not supported for %s", frmt->name); d1312 1 a1312 6 if (strcmp(NM_TAR, argv0) == 0) tar_usage(); else if (strcmp(NM_CPIO, argv0) == 0) cpio_usage(); else pax_usage(); a1331 1 char *dstr; d1337 1 a1337 5 if ((dstr = strdup(str)) == NULL) { tty_warn(0, "Unable to allocate space for option list"); return(-1); } frpt = endpt = dstr; a1348 1 free(dstr); a1352 1 free(dstr); a1444 23 char * getline(FILE *f) { char *name, *temp; size_t len; name = fgetln(f, &len); if (!name) { getline_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0; return(0); } if (name[len-1] != '\n') len++; temp = malloc(len); if (!temp) { getline_error = GETLINE_OUT_OF_MEM; return(0); } memcpy(temp, name, len-1); temp[len-1] = 0; return(temp); } d1467 1 a1467 1 "usage: pax [-cdjnvzO] [-E limit] [-f archive] [-N dbdir] [-s replstr] ...\n" d1471 1 a1471 1 " pax -r [-cdijknuvzADOYZ] [-E limit] [-f archive] [-N dbdir]\n" d1475 1 a1475 1 " pax -w [-dijtuvzAHLMOPX] [-b blocksize] [[-a] [-f archive]] [-x format]\n" d1480 1 a1480 1 " pax -r -w [-dijklntuvzADHLMOPXYZ] [-N dbdir] [-p string] ...\n" d1495 3 a1497 4 (void)fputs("usage: tar [-]{crtux}[-befhjlmopqvwzHLOPXZ014578] [archive] " "[blocksize]\n" " [-C directory] [-T file] [-s replstr] " "[file ...]\n", stderr); d1511 20 a1530 9 (void)fputs("usage: cpio -o [-aABcLvzZ] [-C bytes] [-F archive] " "[-H format] [-O archive]\n" " < name-list [> archive]\n" " cpio -i [-bBcdfmrsStuvzZ6] [-C bytes] [-E file] " "[-F archive] [-H format] \n" " [-I archive] " "[pattern ...] [< archive]\n" " cpio -p [-adlLmuv] destination-directory " "< name-list\n", stderr); d1534 45 @ 1.39.2.2 log @fix botched pullup from ticket #1021 and make sure this compiles on non-NetBSD hosts again. Also fixes PR#24481 @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.39.2.1 2004/04/07 06:58:00 jmc Exp $ */ d36 2 a37 2 #if HAVE_CONFIG_H #include "config.h" d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.39.2.1 2004/04/07 06:58:00 jmc Exp $"); @ 1.38 log @Roll in fixes to permit cross-compiling from non-NetBSD hosts. This round has been tested on Solaris/x86 and Linux hosts. * Add host tools cap_mkdb, ctags, m4, uudecode. * Protect __RCSID() and __COPYRIGHT() better. * Reduce the number of places that need to include "config.h", to keep sources closer to their "vanilla" versions. * Add more compat #defines and autoconf-checked functions. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.37 2002/01/29 10:20:29 tv Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.37 2002/01/29 10:20:29 tv Exp $"); d66 1 d68 1 d472 6 d497 1 @ 1.37 log @Make almost all tools compile and run properly on non-NetBSD hosts. (In particular, most tools now run correctly on Solaris 7.) @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.36 2002/01/26 02:22:54 lukem Exp $ */ d41 1 a41 1 #ifndef lint d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.36 2002/01/26 02:22:54 lukem Exp $"); d54 3 d58 1 a58 1 #include a60 2 #include #include a66 3 /* After extern.h to pull in HAVE_CONFIG_H */ #include @ 1.36 log @provide meaningful warning if -N is called with a dodgy dbdir @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.35 2002/01/24 07:45:33 lukem Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.35 2002/01/24 07:45:33 lukem Exp $"); a59 1 #include d66 3 @ 1.35 log @Add '-N dbdir', to specify that user & group lookups (via pwcache(3)) are to be done from dbdir/master.passwd and dbdir/group, using simple text file parsing routines from ../../usr.sbin/mtree/getid.c. This does not affect the -G and -U options, which always use the system databases. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.34 2001/10/25 08:51:51 lukem Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.34 2001/10/25 08:51:51 lukem Exp $"); d482 4 a485 1 if (!setup_getid(optarg)) d487 1 @ 1.34 log @Implement -M flag: During a write or copy operation, treat the list of files on standard input as an mtree(8) `specfile' specification, and write or copy only those items in the specfile. If the file exists in the underlying file system, its permissions and modification time will be used unless specifically overridden by the specfile. An error will be raised if the type of entry in the specfile conflicts with that of an existing file. Otherwise, it is necessary to specify at least the following parameters in the specfile: type, mode, gname or gid, and uname or uid, device (in the case of block or character devices), and link (in the case of symbolic links). If time isn't provided, the current time will be used. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.33 2001/10/25 05:33:33 lukem Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.33 2001/10/25 05:33:33 lukem Exp $"); d66 1 d199 1 a199 1 "ab:cdf:iklno:p:rs:tuvwx:zAB:DE:G:HLMOPT:U:XYZ")) != -1) { d320 1 a320 1 * preserver file mode bits d478 7 d1453 17 a1469 23 (void)fputs("usage: pax [-cdnvz] [-E limit] [-f archive] ", stderr); (void)fputs("[-s replstr] ... [-U user] ...", stderr); (void)fputs("\n [-G group] ... ", stderr); (void)fputs("[-T [from_date][,to_date]] ... ", stderr); (void)fputs("[pattern ...]\n", stderr); (void)fputs(" pax -r [-cdiknuvzDYZ] [-E limit] ", stderr); (void)fputs("[-f archive] [-o options] ... \n", stderr); (void)fputs(" [-p string] ... [-s replstr] ... ", stderr); (void)fputs("[-U user] ... [-G group] ...\n ", stderr); (void)fputs("[-T [from_date][,to_date]] ... ", stderr); (void)fputs(" [pattern ...]\n", stderr); (void)fputs(" pax -w [-dituvzHLMPX] [-b blocksize] ", stderr); (void)fputs("[[-a] [-f archive]] [-x format] \n", stderr); (void)fputs(" [-B bytes] [-o options] ... ", stderr); (void)fputs("[-s replstr] ... [-U user] ...", stderr); (void)fputs("\n [-G group] ... ", stderr); (void)fputs("[-T [from_date][,to_date][/[c][m]]] ... ", stderr); (void)fputs("[file ...]\n", stderr); (void)fputs(" pax -r -w [-diklntuvzDHLMPXYZ] ", stderr); (void)fputs("[-p string] ... [-s replstr] ...", stderr); (void)fputs("\n [-U user] ... [-G group] ... ", stderr); (void)fputs("[-T [from_date][,to_date][/[c][m]]] ... ", stderr); (void)fputs("\n [file ...] directory\n", stderr); @ 1.33 log @- ansi KNF (just remove all the #ifndef __STDC__ prototype junk, leaving the ansi stuff) - use longlong_t instead of quad_t (etc), and rename *uqd*() -> *ull*() - clean up the NET2_STAT stuff similar to ftpd; provide #defines and macros which select which cast to use, etc - clean up the NET2_FTS and NET2_REGEX #define use @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.32 2001/07/22 13:33:58 wiz Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.32 2001/07/22 13:33:58 wiz Exp $"); d197 2 a198 2 while ((c=getopt(argc,argv,"ab:cdf:iklno:p:rs:tuvwx:zAB:DE:G:HLOPT:U:XYZ")) != -1) { d469 8 d1456 1 a1456 1 (void)fputs(" pax -w [-dituvzHLPX] [-b blocksize] ", stderr); d1463 1 a1463 1 (void)fputs(" pax -r -w [-diklntuvzDHLPXYZ] ", stderr); @ 1.32 log @seperate -> separate @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.31 2000/07/04 17:28:47 thorpej Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.31 2000/07/04 17:28:47 thorpej Exp $"); d79 10 a88 10 static int no_op __P((void)); static void printflg __P((unsigned int)); static int c_frmt __P((const void *, const void *)); static off_t str_offt __P((char *)); static void pax_options __P((int, char **)); static void pax_usage __P((void)); static void tar_options __P((int, char **)); static void tar_usage __P((void)); static void cpio_options __P((int, char **)); static void cpio_usage __P((void)); d90 1 a90 1 static void checkpositionalminusC __P((char ***, int (*)(char *, int))); a155 1 #if __STDC__ a157 6 #else void options(argc, argv) int argc; char **argv; #endif a183 1 #if __STDC__ a185 6 #else static void pax_options(argc, argv) int argc; char **argv; #endif a707 1 #if __STDC__ a709 6 #else static void tar_options(argc, argv) int argc; char **argv; #endif a956 1 #if __STDC__ a958 6 #else static void cpio_options(argc, argv) int argc; char **argv; #endif a1218 1 #if __STDC__ a1220 5 #else static void printflg(flg) unsigned int flg; #endif a1239 1 #if __STDC__ a1241 6 #else static int c_frmt(a, b) void *a; void *b; #endif a1253 1 #if __STDC__ a1255 4 #else OPLIST * opt_next() #endif a1269 1 #if __STDC__ a1271 4 #else int bad_opt() #endif a1295 1 #if __STDC__ a1297 5 #else int opt_add(str) const char *str; #endif a1358 1 #if __STDC__ a1360 5 #else static off_t str_offt(val) char *val; #endif d1365 2 a1366 7 # ifdef NET2_STAT num = strtol(val, &expr, 0); if ((num == LONG_MAX) || (num <= 0) || (expr == val)) # else num = strtoq(val, &expr, 0); if ((num == QUAD_MAX) || (num <= 0) || (expr == val)) # endif a1422 1 #if __STDC__ a1424 4 #else static int no_op() #endif a1433 1 #if __STDC__ a1435 4 #else void pax_usage() #endif a1468 1 #if __STDC__ a1470 4 #else void tar_usage() #endif a1483 1 #if __STDC__ a1485 4 #else void cpio_usage() #endif a1518 1 #ifdef __STDC__ a1520 5 #else int opt_chdir(name) char *name; #endif a1539 1 #ifdef __STDC__ a1541 6 #else void checkpositionalminusC(argvp, addfunc) char ***argvp; int (*addfunc)(); #endif @ 1.31 log @Implement --atime-preserve. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.30 2000/07/04 17:24:47 thorpej Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.30 2000/07/04 17:24:47 thorpej Exp $"); d1410 1 a1410 1 * seperated by x (also * for backwards compatibility), specifying @ 1.30 log @Implement --use-compress-program. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.29 2000/07/04 17:17:49 thorpej Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.29 2000/07/04 17:17:49 thorpej Exp $"); d666 2 d679 1 a679 1 { "help", no_argument, a680 2 { "atime-preserve", no_argument, OPT_ATIME_PRESERVE }, d915 3 @ 1.29 log @Add GNU tar-style long options for pax's tar front-end. Still many GNU options not implemented, but there is an #if 0'd out canonical list. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.28 2000/04/14 05:52:58 simonb Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.28 2000/04/14 05:52:58 simonb Exp $"); d668 2 a674 2 { "use-compress-program", required_argument, 0, OPT_USE_COMPRESS_PROGRAM }, d918 4 @ 1.28 log @Don't declare 'extern opt*' getopt variables. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.27 2000/03/30 17:53:04 thorpej Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.27 2000/03/30 17:53:04 thorpej Exp $"); d60 1 d621 101 d738 2 a739 1 while ((c = getoldopt(argc, argv, "b:cef:hlmoprutvwxzBC:LPX:Z014578")) d916 3 d990 2 a991 2 while ((c = getoldopt(argc, argv, "ABC:E:H:I:LM:O:R:SVabcdfiklmoprstuv")) != -1) { @ 1.27 log @Add a -O option: force one volume. This causes pax to not prompt for a new volume upon premature end-of-volume (e.g. broken pipe). This is especially useful in automated environments where error recovery cannot be performed by a human. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.26 2000/02/17 03:12:25 itohy Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.26 2000/02/17 03:12:25 itohy Exp $"); a205 2 extern char *optarg; extern int optind; @ 1.26 log @Cleanup and fix typos. Partially from FreeBSD. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.25 1999/11/07 15:57:31 mycroft Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.25 1999/11/07 15:57:31 mycroft Exp $"); d212 1 a212 1 while ((c=getopt(argc,argv,"ab:cdf:iklno:p:rs:tuvwx:zAB:DE:G:HLPT:U:XYZ")) d483 6 @ 1.25 log @Disable -pf for now, too. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.24 1999/11/01 01:35:59 mrg Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.24 1999/11/01 01:35:59 mrg Exp $"); d98 1 a98 1 * name, blksz, hdsz, udev, hlk, blkagn, inhead, id, st_read, d205 1 a205 1 FSUB tmp; d632 1 a632 1 while ((c = getoldopt(argc, argv, "b:cef:hlmoprutvwxzBC:LPX:Z014578")) d871 1 a871 1 FSUB tmp; d1163 2 a1164 2 void *a; void *b; d1167 1 a1167 1 return(strcmp(((FSUB *)a)->name, ((FSUB *)b)->name)); d1225 1 a1225 1 * mulltiple -o may be specified. d1287 1 a1287 1 * 1) A positive decimal number. d1486 1 a1486 1 * @ 1.25.2.1 log @file options.c was added on branch comdex-fall-1999 on 1999-11-07 15:57:32 +0000 @ text @d1 1539 @ 1.25.2.2 log @Disable -pf for now, too. @ text @a0 1539 /* $NetBSD: options.c,v 1.25 1999/11/07 15:57:31 mycroft Exp $ */ /*- * Copyright (c) 1992 Keith Muller. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@@(#)options.c 8.2 (Berkeley) 4/18/94"; #else __RCSID("$NetBSD: options.c,v 1.25 1999/11/07 15:57:31 mycroft Exp $"); #endif #endif /* not lint */ #include #include #include #include #include #include #include #include #include #include #include #include "pax.h" #include "options.h" #include "cpio.h" #include "tar.h" #include "extern.h" /* * Routines which handle command line options */ int cpio_mode; /* set if we are in cpio mode */ static int nopids; /* tar mode: suppress "pids" for -p option */ static char *flgch = FLGCH; /* list of all possible flags (pax) */ static OPLIST *ophead = NULL; /* head for format specific options -x */ static OPLIST *optail = NULL; /* option tail */ static char *firstminusC; /* first -C argument encountered. */ static int no_op __P((void)); static void printflg __P((unsigned int)); static int c_frmt __P((const void *, const void *)); static off_t str_offt __P((char *)); static void pax_options __P((int, char **)); static void pax_usage __P((void)); static void tar_options __P((int, char **)); static void tar_usage __P((void)); static void cpio_options __P((int, char **)); static void cpio_usage __P((void)); static void checkpositionalminusC __P((char ***, int (*)(char *, int))); #define GZIP_CMD "gzip" /* command to run as gzip */ #define COMPRESS_CMD "compress" /* command to run as compress */ /* * Format specific routine table - MUST BE IN SORTED ORDER BY NAME * (see pax.h for description of each function) * * name, blksz, hdsz, udev, hlk, blkagn, inhead, id, st_read, * read, end_read, st_write, write, end_write, trail, * rd_data, wr_data, options */ FSUB fsub[] = { /* 0: OLD BINARY CPIO */ { "bcpio", 5120, sizeof(HD_BCPIO), 1, 0, 0, 1, bcpio_id, cpio_strd, bcpio_rd, bcpio_endrd, cpio_stwr, bcpio_wr, cpio_endwr, NULL, cpio_subtrail, rd_wrfile, wr_rdfile, bad_opt }, /* 1: OLD OCTAL CHARACTER CPIO */ { "cpio", 5120, sizeof(HD_CPIO), 1, 0, 0, 1, cpio_id, cpio_strd, cpio_rd, cpio_endrd, cpio_stwr, cpio_wr, cpio_endwr, NULL, cpio_subtrail, rd_wrfile, wr_rdfile, bad_opt }, /* 2: SVR4 HEX CPIO */ { "sv4cpio", 5120, sizeof(HD_VCPIO), 1, 0, 0, 1, vcpio_id, cpio_strd, vcpio_rd, vcpio_endrd, cpio_stwr, vcpio_wr, cpio_endwr, NULL, cpio_subtrail, rd_wrfile, wr_rdfile, bad_opt }, /* 3: SVR4 HEX CPIO WITH CRC */ { "sv4crc", 5120, sizeof(HD_VCPIO), 1, 0, 0, 1, crc_id, crc_strd, vcpio_rd, vcpio_endrd, crc_stwr, vcpio_wr, cpio_endwr, NULL, cpio_subtrail, rd_wrfile, wr_rdfile, bad_opt }, /* 4: OLD TAR */ { "tar", 10240, BLKMULT, 0, 1, BLKMULT, 0, tar_id, no_op, tar_rd, tar_endrd, no_op, tar_wr, tar_endwr, tar_trail, NULL, rd_wrfile, wr_rdfile, tar_opt }, /* 5: POSIX USTAR */ { "ustar", 10240, BLKMULT, 0, 1, BLKMULT, 0, ustar_id, ustar_strd, ustar_rd, tar_endrd, ustar_stwr, ustar_wr, tar_endwr, tar_trail, NULL, rd_wrfile, wr_rdfile, bad_opt } }; #define F_BCPIO 0 /* old binary cpio format */ #define F_CPIO 1 /* old octal character cpio format */ #define F_SV4CPIO 2 /* SVR4 hex cpio format */ #define F_SV4CRC 3 /* SVR4 hex with crc cpio format */ #define F_TAR 4 /* old V7 UNIX tar format */ #define F_USTAR 5 /* ustar format */ #define DEFLT F_USTAR /* default write format from list above */ /* * ford is the archive search order used by get_arc() to determine what kind * of archive we are dealing with. This helps to properly id archive formats * some formats may be subsets of others.... */ int ford[] = {F_USTAR, F_TAR, F_SV4CRC, F_SV4CPIO, F_CPIO, F_BCPIO, -1}; /* * options() * figure out if we are pax, tar or cpio. Call the appropriate options * parser */ #if __STDC__ void options(int argc, char **argv) #else void options(argc, argv) int argc; char **argv; #endif { /* * Are we acting like pax, tar or cpio (based on argv[0]) */ if ((argv0 = strrchr(argv[0], '/')) != NULL) argv0++; else argv0 = argv[0]; if (strcmp(NM_TAR, argv0) == 0) tar_options(argc, argv); else if (strcmp(NM_CPIO, argv0) == 0) cpio_options(argc, argv); else { argv0 = NM_PAX; pax_options(argc, argv); } } /* * pax_options() * look at the user specified flags. set globals as required and check if * the user specified a legal set of flags. If not, complain and exit */ #if __STDC__ static void pax_options(int argc, char **argv) #else static void pax_options(argc, argv) int argc; char **argv; #endif { int c; int i; unsigned int flg = 0; unsigned int bflg = 0; char *pt; FSUB tmp; extern char *optarg; extern int optind; /* * process option flags */ while ((c=getopt(argc,argv,"ab:cdf:iklno:p:rs:tuvwx:zAB:DE:G:HLPT:U:XYZ")) != -1) { switch (c) { case 'a': /* * append */ flg |= AF; break; case 'b': /* * specify blocksize */ flg |= BF; if ((wrblksz = (int)str_offt(optarg)) <= 0) { tty_warn(1, "Invalid block size %s", optarg); pax_usage(); } break; case 'c': /* * inverse match on patterns */ cflag = 1; flg |= CF; break; case 'd': /* * match only dir on extract, not the subtree at dir */ dflag = 1; flg |= DF; break; case 'f': /* * filename where the archive is stored */ arcname = optarg; flg |= FF; break; case 'i': /* * interactive file rename */ iflag = 1; flg |= IF; break; case 'k': /* * do not clobber files that exist */ kflag = 1; flg |= KF; break; case 'l': /* * try to link src to dest with copy (-rw) */ lflag = 1; flg |= LF; break; case 'n': /* * select first match for a pattern only */ nflag = 1; flg |= NF; break; case 'o': /* * pass format specific options */ flg |= OF; if (opt_add(optarg) < 0) pax_usage(); break; case 'p': /* * specify file characteristic options */ for (pt = optarg; *pt != '\0'; ++pt) { switch(*pt) { case 'a': /* * do not preserve access time */ patime = 0; break; case 'e': /* * preserve user id, group id, file * mode, access/modification times * and file flags. */ pids = 1; pmode = 1; patime = 1; pmtime = 1; pfflags = 1; break; #if 0 case 'f': /* * do not preserve file flags */ pfflags = 0; break; #endif case 'm': /* * do not preserve modification time */ pmtime = 0; break; case 'o': /* * preserve uid/gid */ pids = 1; break; case 'p': /* * preserver file mode bits */ pmode = 1; break; default: tty_warn(1, "Invalid -p string: %c", *pt); pax_usage(); break; } } flg |= PF; break; case 'r': /* * read the archive */ flg |= RF; break; case 's': /* * file name substitution name pattern */ if (rep_add(optarg) < 0) { pax_usage(); break; } flg |= SF; break; case 't': /* * preserve access time on filesystem nodes we read */ tflag = 1; flg |= TF; break; case 'u': /* * ignore those older files */ uflag = 1; flg |= UF; break; case 'v': /* * verbose operation mode */ vflag = 1; flg |= VF; break; case 'w': /* * write an archive */ flg |= WF; break; case 'x': /* * specify an archive format on write */ tmp.name = optarg; frmt = (FSUB *)bsearch((void *)&tmp, (void *)fsub, sizeof(fsub)/sizeof(FSUB), sizeof(FSUB), c_frmt); if (frmt != NULL) { flg |= XF; break; } tty_warn(1, "Unknown -x format: %s", optarg); (void)fputs("pax: Known -x formats are:", stderr); for (i = 0; i < (sizeof(fsub)/sizeof(FSUB)); ++i) (void)fprintf(stderr, " %s", fsub[i].name); (void)fputs("\n\n", stderr); pax_usage(); break; case 'z': /* * use gzip. Non standard option. */ zflag = 1; gzip_program = GZIP_CMD; break; case 'A': Aflag = 1; flg |= CAF; break; case 'B': /* * non-standard option on number of bytes written on a * single archive volume. */ if ((wrlimit = str_offt(optarg)) <= 0) { tty_warn(1, "Invalid write limit %s", optarg); pax_usage(); } if (wrlimit % BLKMULT) { tty_warn(1, "Write limit is not a %d byte multiple", BLKMULT); pax_usage(); } flg |= CBF; break; case 'D': /* * On extraction check file inode change time before the * modification of the file name. Non standard option. */ Dflag = 1; flg |= CDF; break; case 'E': /* * non-standard limit on read faults * 0 indicates stop after first error, values * indicate a limit, "NONE" try forever */ flg |= CEF; if (strcmp(NONE, optarg) == 0) maxflt = -1; else if ((maxflt = atoi(optarg)) < 0) { tty_warn(1, "Error count value must be positive"); pax_usage(); } break; case 'G': /* * non-standard option for selecting files within an * archive by group (gid or name) */ if (grp_add(optarg) < 0) { pax_usage(); break; } flg |= CGF; break; case 'H': /* * follow command line symlinks only */ Hflag = 1; flg |= CHF; break; case 'L': /* * follow symlinks */ Lflag = 1; flg |= CLF; break; case 'P': /* * do NOT follow symlinks (default) */ Lflag = 0; flg |= CPF; break; case 'T': /* * non-standard option for selecting files within an * archive by modification time range (lower,upper) */ if (trng_add(optarg) < 0) { pax_usage(); break; } flg |= CTF; break; case 'U': /* * non-standard option for selecting files within an * archive by user (uid or name) */ if (usr_add(optarg) < 0) { pax_usage(); break; } flg |= CUF; break; case 'X': /* * do not pass over mount points in the file system */ Xflag = 1; flg |= CXF; break; case 'Y': /* * On extraction check file inode change time after the * modification of the file name. Non standard option. */ Yflag = 1; flg |= CYF; break; case 'Z': /* * On extraction check modification time after the * modification of the file name. Non standard option. */ Zflag = 1; flg |= CZF; break; case '?': default: pax_usage(); break; } } /* * figure out the operation mode of pax read,write,extract,copy,append * or list. check that we have not been given a bogus set of flags * for the operation mode. */ if (ISLIST(flg)) { act = LIST; bflg = flg & BDLIST; } else if (ISEXTRACT(flg)) { act = EXTRACT; bflg = flg & BDEXTR; } else if (ISARCHIVE(flg)) { act = ARCHIVE; bflg = flg & BDARCH; } else if (ISAPPND(flg)) { act = APPND; bflg = flg & BDARCH; } else if (ISCOPY(flg)) { act = COPY; bflg = flg & BDCOPY; } else pax_usage(); if (bflg) { printflg(flg); pax_usage(); } /* * if we are writing (ARCHIVE) we use the default format if the user * did not specify a format. when we write during an APPEND, we will * adopt the format of the existing archive if none was supplied. */ if (!(flg & XF) && (act == ARCHIVE)) frmt = &(fsub[DEFLT]); /* * process the args as they are interpreted by the operation mode */ switch (act) { case LIST: case EXTRACT: for (; optind < argc; optind++) if (pat_add(argv[optind], 0) < 0) pax_usage(); break; case COPY: if (optind >= argc) { tty_warn(0, "Destination directory was not supplied"); pax_usage(); } --argc; dirptr = argv[argc]; /* FALLTHROUGH */ case ARCHIVE: case APPND: for (; optind < argc; optind++) if (ftree_add(argv[optind], 0) < 0) pax_usage(); /* * no read errors allowed on updates/append operation! */ maxflt = 0; break; } } /* * tar_options() * look at the user specified flags. set globals as required and check if * the user specified a legal set of flags. If not, complain and exit */ #if __STDC__ static void tar_options(int argc, char **argv) #else static void tar_options(argc, argv) int argc; char **argv; #endif { int c; int fstdin = 0; /* * process option flags */ while ((c = getoldopt(argc, argv, "b:cef:hlmoprutvwxzBC:LPX:Z014578")) != -1) { switch(c) { case 'b': /* * specify blocksize */ if ((wrblksz = (int)str_offt(optarg)) <= 0) { tty_warn(1, "Invalid block size %s", optarg); tar_usage(); } break; case 'c': /* * create an archive */ act = ARCHIVE; break; case 'C': /* * chdir here before extracting. * do so lazily, in case it's a list */ firstminusC = optarg; break; case 'e': /* * stop after first error */ maxflt = 0; break; case 'f': /* * filename where the archive is stored */ if ((optarg[0] == '-') && (optarg[1]== '\0')) { /* * treat a - as stdin */ fstdin = 1; arcname = (char *)0; break; } fstdin = 0; arcname = optarg; break; case 'h': /* * follow command line symlinks only */ Hflag = 1; break; case 'l': /* * do not pass over mount points in the file system */ Xflag = 1; break; case 'm': /* * do not preserve modification time */ pmtime = 0; break; case 'o': /* * This option does several things based on whether * this is a create or extract operation. */ if (act == ARCHIVE) { /* 4.2BSD: don't add directory entries. */ if (opt_add("write_opt=nodir") < 0) tar_usage(); /* GNU tar: write V7 format archives. */ frmt = &(fsub[F_TAR]); } else { /* SUS: don't preserve owner/group. */ pids = 0; nopids = 1; } break; case 'p': /* * preserve user id, group id, file * mode, access/modification times */ if (!nopids) pids = 1; pmode = 1; patime = 1; pmtime = 1; break; case 'r': case 'u': /* * append to the archive */ act = APPND; break; case 't': /* * list contents of the tape */ act = LIST; break; case 'v': /* * verbose operation mode */ vflag = 1; break; case 'w': /* * interactive file rename */ iflag = 1; break; case 'x': /* * write an archive */ act = EXTRACT; break; case 'z': /* * use gzip. Non standard option. */ zflag = 1; gzip_program = GZIP_CMD; break; case 'B': /* * Nothing to do here, this is pax default */ break; case 'L': /* * follow symlinks */ Lflag = 1; break; case 'P': Aflag = 1; break; case 'X': /* * GNU tar compat: exclude the files listed in optarg */ if (tar_gnutar_X_compat(optarg) != 0) tar_usage(); break; case 'Z': /* * use compress. */ zflag = 1; gzip_program = COMPRESS_CMD; break; case '0': arcname = DEV_0; break; case '1': arcname = DEV_1; break; case '4': arcname = DEV_4; break; case '5': arcname = DEV_5; break; case '7': arcname = DEV_7; break; case '8': arcname = DEV_8; break; default: tar_usage(); break; } } argc -= optind; argv += optind; if (firstminusC && (opt_chdir(firstminusC) < 0)) tty_warn(1, "can't remember -C directory"); /* * if we are writing (ARCHIVE) specify tar, otherwise run like pax */ if (act == ARCHIVE && frmt == NULL) frmt = &(fsub[F_USTAR]); /* * process the args as they are interpreted by the operation mode */ switch (act) { case LIST: default: while (*argv != (char *)NULL) if (pat_add(*argv++, 0) < 0) tar_usage(); break; case EXTRACT: checkpositionalminusC(&argv, pat_add); break; case ARCHIVE: case APPND: checkpositionalminusC(&argv, ftree_add); /* * no read errors allowed on updates/append operation! */ maxflt = 0; break; } if (!fstdin && ((arcname == (char *)NULL) || (*arcname == '\0'))) { arcname = getenv("TAPE"); if ((arcname == (char *)NULL) || (*arcname == '\0')) arcname = DEV_8; } } /* * cpio_options() * look at the user specified flags. set globals as required and check if * the user specified a legal set of flags. If not, complain and exit */ #if __STDC__ static void cpio_options(int argc, char **argv) #else static void cpio_options(argc, argv) int argc; char **argv; #endif { FSUB tmp; unsigned int flg = 0; unsigned int bflg = 0; int c, i; cpio_mode = uflag = 1; /* * process option flags */ while ((c = getoldopt(argc, argv, "ABC:E:H:I:LM:O:R:SVabcdfiklmoprstuv")) != -1) { switch(c) { case 'A': /* * append to an archive */ act = APPND; flg |= AF; break; case 'B': /* * set blocksize to 5120 */ blksz = 5120; break; case 'C': /* * specify blocksize */ if ((blksz = (int)str_offt(optarg)) <= 0) { tty_warn(1, "Invalid block size %s", optarg); tar_usage(); } break; #ifdef notyet case 'E': arg = optarg; break; #endif case 'H': /* * specify an archive format on write */ tmp.name = optarg; frmt = (FSUB *)bsearch((void *)&tmp, (void *)fsub, sizeof(fsub)/sizeof(FSUB), sizeof(FSUB), c_frmt); if (frmt != NULL) { flg |= XF; break; } tty_warn(1, "Unknown -H format: %s", optarg); (void)fputs("cpio: Known -H formats are:", stderr); for (i = 0; i < (sizeof(fsub)/sizeof(FSUB)); ++i) (void)fprintf(stderr, " %s", fsub[i].name); (void)fputs("\n\n", stderr); tar_usage(); break; case 'I': case 'O': /* * filename where the archive is stored */ if ((optarg[0] == '-') && (optarg[1]== '\0')) { /* * treat a - as stdin */ arcname = (char *)0; break; } arcname = optarg; break; case 'L': /* * follow symlinks */ Lflag = 1; flg |= CLF; break; #ifdef notyet case 'M': arg = optarg; break; case 'R': arg = optarg; break; #endif case 'S': cpio_swp_head = 1; break; #ifdef notyet case 'V': break; #endif case 'a': /* * preserve access time on filesystem nodes we read */ tflag = 1; flg |= TF; break; #ifdef notyet case 'b': break; #endif case 'c': frmt = &fsub[F_SV4CPIO]; break; case 'd': /* * pax does this by default .. */ flg |= RF; break; case 'f': /* * inverse match on patterns */ cflag = 1; flg |= CF; break; case 'i': /* * read the archive */ flg |= RF; break; #ifdef notyet case 'k': break; #endif case 'l': /* * try to link src to dest with copy (-rw) */ lflag = 1; flg |= LF; break; case 'm': /* * preserve mtime */ flg |= PF; pmtime = 1; break; case 'o': /* * write an archive */ flg |= WF; break; case 'p': /* * cpio -p is like pax -rw */ flg |= RF | WF; break; case 'r': /* * interactive file rename */ iflag = 1; flg |= IF; break; #ifdef notyet case 's': break; #endif case 't': act = LIST; break; case 'u': /* * don't ignore those older files */ uflag = 0; flg |= UF; break; case 'v': /* * verbose operation mode */ vflag = 1; flg |= VF; break; default: cpio_usage(); break; } } /* * figure out the operation mode of cpio. check that we have not been * given a bogus set of flags for the operation mode. */ if (ISLIST(flg)) { act = LIST; bflg = flg & BDLIST; } else if (ISEXTRACT(flg)) { act = EXTRACT; bflg = flg & BDEXTR; } else if (ISARCHIVE(flg)) { act = ARCHIVE; bflg = flg & BDARCH; } else if (ISAPPND(flg)) { act = APPND; bflg = flg & BDARCH; } else if (ISCOPY(flg)) { act = COPY; bflg = flg & BDCOPY; } else cpio_usage(); if (bflg) { cpio_usage(); } /* * if we are writing (ARCHIVE) we use the default format if the user * did not specify a format. when we write during an APPEND, we will * adopt the format of the existing archive if none was supplied. */ if (!(flg & XF) && (act == ARCHIVE)) frmt = &(fsub[F_BCPIO]); /* * process the args as they are interpreted by the operation mode */ switch (act) { case LIST: case EXTRACT: for (; optind < argc; optind++) if (pat_add(argv[optind], 0) < 0) cpio_usage(); break; case COPY: if (optind >= argc) { tty_warn(0, "Destination directory was not supplied"); cpio_usage(); } --argc; dirptr = argv[argc]; /* FALLTHROUGH */ case ARCHIVE: case APPND: for (; optind < argc; optind++) if (ftree_add(argv[optind], 0) < 0) cpio_usage(); /* * no read errors allowed on updates/append operation! */ maxflt = 0; break; } } /* * printflg() * print out those invalid flag sets found to the user */ #if __STDC__ static void printflg(unsigned int flg) #else static void printflg(flg) unsigned int flg; #endif { int nxt; int pos = 0; (void)fprintf(stderr,"%s: Invalid combination of options:", argv0); while ((nxt = ffs(flg)) != 0) { flg = flg >> nxt; pos += nxt; (void)fprintf(stderr, " -%c", flgch[pos-1]); } (void)putc('\n', stderr); } /* * c_frmt() * comparison routine used by bsearch to find the format specified * by the user */ #if __STDC__ static int c_frmt(const void *a, const void *b) #else static int c_frmt(a, b) void *a; void *b; #endif { return(strcmp(((FSUB *)a)->name, ((FSUB *)b)->name)); } /* * opt_next() * called by format specific options routines to get each format specific * flag and value specified with -o * Return: * pointer to next OPLIST entry or NULL (end of list). */ #if __STDC__ OPLIST * opt_next(void) #else OPLIST * opt_next() #endif { OPLIST *opt; if ((opt = ophead) != NULL) ophead = ophead->fow; return(opt); } /* * bad_opt() * generic routine used to complain about a format specific options * when the format does not support options. */ #if __STDC__ int bad_opt(void) #else int bad_opt() #endif { OPLIST *opt; if (ophead == NULL) return(0); /* * print all we were given */ tty_warn(1,"These format options are not supported"); while ((opt = opt_next()) != NULL) (void)fprintf(stderr, "\t%s = %s\n", opt->name, opt->value); pax_usage(); return(0); } /* * opt_add() * breaks the value supplied to -o into a option name and value. options * are given to -o in the form -o name-value,name=value * mulltiple -o may be specified. * Return: * 0 if format in name=value format, -1 if -o is passed junk */ #if __STDC__ int opt_add(const char *str) #else int opt_add(str) const char *str; #endif { OPLIST *opt; char *frpt; char *pt; char *endpt; if ((str == NULL) || (*str == '\0')) { tty_warn(0, "Invalid option name"); return(-1); } frpt = endpt = strdup(str); /* * break into name and values pieces and stuff each one into a * OPLIST structure. When we know the format, the format specific * option function will go through this list */ while ((frpt != NULL) && (*frpt != '\0')) { if ((endpt = strchr(frpt, ',')) != NULL) *endpt = '\0'; if ((pt = strchr(frpt, '=')) == NULL) { tty_warn(0, "Invalid options format"); return(-1); } if ((opt = (OPLIST *)malloc(sizeof(OPLIST))) == NULL) { tty_warn(0, "Unable to allocate space for option list"); return(-1); } *pt++ = '\0'; opt->name = frpt; opt->value = pt; opt->fow = NULL; if (endpt != NULL) frpt = endpt + 1; else frpt = NULL; if (ophead == NULL) { optail = ophead = opt; continue; } optail->fow = opt; optail = opt; } return(0); } /* * str_offt() * Convert an expression of the following forms to an off_t > 0. * 1) A positive decimal number. * 2) A positive decimal number followed by a b (mult by 512). * 3) A positive decimal number followed by a k (mult by 1024). * 4) A positive decimal number followed by a m (mult by 512). * 5) A positive decimal number followed by a w (mult by sizeof int) * 6) Two or more positive decimal numbers (with/without k,b or w). * seperated by x (also * for backwards compatibility), specifying * the product of the indicated values. * Return: * 0 for an error, a positive value o.w. */ #if __STDC__ static off_t str_offt(char *val) #else static off_t str_offt(val) char *val; #endif { char *expr; off_t num, t; # ifdef NET2_STAT num = strtol(val, &expr, 0); if ((num == LONG_MAX) || (num <= 0) || (expr == val)) # else num = strtoq(val, &expr, 0); if ((num == QUAD_MAX) || (num <= 0) || (expr == val)) # endif return(0); switch(*expr) { case 'b': t = num; num *= 512; if (t > num) return(0); ++expr; break; case 'k': t = num; num *= 1024; if (t > num) return(0); ++expr; break; case 'm': t = num; num *= 1048576; if (t > num) return(0); ++expr; break; case 'w': t = num; num *= sizeof(int); if (t > num) return(0); ++expr; break; } switch(*expr) { case '\0': break; case '*': case 'x': t = num; num *= str_offt(expr + 1); if (t > num) return(0); break; default: return(0); } return(num); } /* * no_op() * for those option functions where the archive format has nothing to do. * Return: * 0 */ #if __STDC__ static int no_op(void) #else static int no_op() #endif { return(0); } /* * pax_usage() * print the usage summary to the user */ #if __STDC__ void pax_usage(void) #else void pax_usage() #endif { (void)fputs("usage: pax [-cdnvz] [-E limit] [-f archive] ", stderr); (void)fputs("[-s replstr] ... [-U user] ...", stderr); (void)fputs("\n [-G group] ... ", stderr); (void)fputs("[-T [from_date][,to_date]] ... ", stderr); (void)fputs("[pattern ...]\n", stderr); (void)fputs(" pax -r [-cdiknuvzDYZ] [-E limit] ", stderr); (void)fputs("[-f archive] [-o options] ... \n", stderr); (void)fputs(" [-p string] ... [-s replstr] ... ", stderr); (void)fputs("[-U user] ... [-G group] ...\n ", stderr); (void)fputs("[-T [from_date][,to_date]] ... ", stderr); (void)fputs(" [pattern ...]\n", stderr); (void)fputs(" pax -w [-dituvzHLPX] [-b blocksize] ", stderr); (void)fputs("[[-a] [-f archive]] [-x format] \n", stderr); (void)fputs(" [-B bytes] [-o options] ... ", stderr); (void)fputs("[-s replstr] ... [-U user] ...", stderr); (void)fputs("\n [-G group] ... ", stderr); (void)fputs("[-T [from_date][,to_date][/[c][m]]] ... ", stderr); (void)fputs("[file ...]\n", stderr); (void)fputs(" pax -r -w [-diklntuvzDHLPXYZ] ", stderr); (void)fputs("[-p string] ... [-s replstr] ...", stderr); (void)fputs("\n [-U user] ... [-G group] ... ", stderr); (void)fputs("[-T [from_date][,to_date][/[c][m]]] ... ", stderr); (void)fputs("\n [file ...] directory\n", stderr); exit(1); /* NOTREACHED */ } /* * tar_usage() * print the usage summary to the user */ #if __STDC__ void tar_usage(void) #else void tar_usage() #endif { (void)fputs("usage: tar -{txru}[cevfbhlmopwBLPX014578] [tapefile] ", stderr); (void)fputs("[blocksize] [exclude-file] file1 file2...\n", stderr); exit(1); /* NOTREACHED */ } /* * cpio_usage() * print the usage summary to the user */ #if __STDC__ void cpio_usage(void) #else void cpio_usage() #endif { #if 1 (void)fputs( "usage: cpio -i [-BcdfmrStuv] [ -C blksize ] [ -H header ]\n", stderr); (void)fputs(" [ -I file ] [ pattern ... ]\n", stderr); (void)fputs("usage: cpio -o [-aABcLv] [ -C bufsize ] [ -H header ]\n", stderr); (void)fputs(" [ -O file ]\n", stderr); (void)fputs("usage: cpio -p [ adlLmuv ] directory\n", stderr); #else /* no E, M, R, V, b, k or s */ (void)fputs("usage: cpio -i [-bBcdfkmrsStuvV] [ -C bufsize ]\n", stderr); (void)fputs(" [ -E file ] [ -H header ] [ -I file [ -M message ] ]\n", stderr); (void)fputs(" [ -R id ] [ pattern ... ]\n", stderr); (void)fputs("usage: cpio -o [-aABcLvV] [ -C bufsize ] [ -H header ]\n", stderr); (void)fputs(" [ -O file [ -M message ] ]\n", stderr); (void)fputs("usage: cpio -p [ adlLmuvV ] [ -R id ] directory\n", stderr); #endif exit(1); /* NOTREACHED */ } /* * opt_chdir * call ftree_add or pat_add, depending on archive type. * * Returns: -1 for listing, else what ftree_add or pat_add returned. */ #ifdef __STDC__ int opt_chdir(char *name) #else int opt_chdir(name) char *name; #endif { switch (act) { default: return (-1); break; case ARCHIVE: case APPND: return (ftree_add(name, 1)); break; case EXTRACT: return (pat_add(name, 1)); break; } } /* * checkpositionalminusC(argvp, addfunc) */ #ifdef __STDC__ void checkpositionalminusC(char ***argvp, int (*addfunc)(char *, int)) #else void checkpositionalminusC(argvp, addfunc) char ***argvp; int (*addfunc)(); #endif { while (**argvp != (char *)NULL) { if (!strcmp(**argvp, "-C")) { /* XXX should be allow for positional -C/dir, too? */ if ((*addfunc)(*++*argvp, 1) < 0) { tar_usage(); } ++*argvp; continue; } if ((*addfunc)(*(*argvp)++, 0) < 0) tar_usage(); } } @ 1.24 log @add a new -p subflag: 'f' to preserve 4.4BSD fileflags. this only really works for `pax -rw' but that's where it is most useful. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.23 1999/10/22 20:59:08 is Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.23 1999/10/22 20:59:08 is Exp $"); d312 1 d319 1 @ 1.23 log @Implement positional -C argument to tar. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.22 1999/08/24 08:02:27 tron Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.22 1999/08/24 08:02:27 tron Exp $"); d304 1 d310 7 @ 1.22 log @Fix "tar" mode usage string. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.21 1999/08/24 08:00:03 tron Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.21 1999/08/24 08:00:03 tron Exp $"); a70 1 char *chdir_dir; /* directory to chdir to before operating */ d76 1 d89 2 d575 1 a575 1 if (pat_add(argv[optind]) < 0) d589 1 a589 1 if (ftree_add(argv[optind]) < 0) d643 1 d645 1 a645 1 chdir_dir = optarg; d807 3 a820 1 case EXTRACT: d823 1 a823 1 if (pat_add(*argv++) < 0) d826 3 d831 1 a831 3 while (*argv != (char *)NULL) if (ftree_add(*argv++) < 0) tar_usage(); d1091 1 a1091 1 if (pat_add(argv[optind]) < 0) d1105 1 a1105 1 if (ftree_add(argv[optind]) < 0) d1471 58 @ 1.22.2.1 log @Pull up to last week's -current. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.25 1999/11/07 15:57:31 mycroft Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.25 1999/11/07 15:57:31 mycroft Exp $"); d71 1 a76 1 static char *firstminusC; /* first -C argument encountered. */ a88 2 static void checkpositionalminusC __P((char ***, int (*)(char *, int))); a301 1 * and file flags. a306 8 pfflags = 1; break; #if 0 case 'f': /* * do not preserve file flags */ pfflags = 0; a307 1 #endif d573 1 a573 1 if (pat_add(argv[optind], 0) < 0) d587 1 a587 1 if (ftree_add(argv[optind], 0) < 0) a640 1 * do so lazily, in case it's a list d642 1 a642 1 firstminusC = optarg; a803 3 if (firstminusC && (opt_chdir(firstminusC) < 0)) tty_warn(1, "can't remember -C directory"); d815 1 d818 1 a818 1 if (pat_add(*argv++, 0) < 0) a820 3 case EXTRACT: checkpositionalminusC(&argv, pat_add); break; d823 3 a825 1 checkpositionalminusC(&argv, ftree_add); d1085 1 a1085 1 if (pat_add(argv[optind], 0) < 0) d1099 1 a1099 1 if (ftree_add(argv[optind], 0) < 0) a1464 58 } /* * opt_chdir * call ftree_add or pat_add, depending on archive type. * * Returns: -1 for listing, else what ftree_add or pat_add returned. */ #ifdef __STDC__ int opt_chdir(char *name) #else int opt_chdir(name) char *name; #endif { switch (act) { default: return (-1); break; case ARCHIVE: case APPND: return (ftree_add(name, 1)); break; case EXTRACT: return (pat_add(name, 1)); break; } } /* * checkpositionalminusC(argvp, addfunc) */ #ifdef __STDC__ void checkpositionalminusC(char ***argvp, int (*addfunc)(char *, int)) #else void checkpositionalminusC(argvp, addfunc) char ***argvp; int (*addfunc)(); #endif { while (**argvp != (char *)NULL) { if (!strcmp(**argvp, "-C")) { /* XXX should be allow for positional -C/dir, too? */ if ((*addfunc)(*++*argvp, 1) < 0) { tar_usage(); } ++*argvp; continue; } if ((*addfunc)(*(*argvp)++, 0) < 0) tar_usage(); } @ 1.21 log @Recognize GnuTAR's "h" (instead of "H") and "P" options. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.20 1999/08/24 07:57:06 tron Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.20 1999/08/24 07:57:06 tron Exp $"); d620 1 a620 1 while ((c = getoldopt(argc, argv, "b:cef:lmoprutvwxzBC:HLPX:Z014578")) d1422 1 a1422 1 (void)fputs("usage: tar -{txru}[cevfblmopwBHLPX014578] [tapefile] ", @ 1.20 log @Strip leading slashes from filenames by default, add new "A" option to disable this behaviour. Patches supplied by Peter Seebach in PR bin/8233. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.19 1999/03/07 01:03:32 mycroft Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.19 1999/03/07 01:03:32 mycroft Exp $"); d665 6 a754 6 case 'H': /* * follow command line symlinks only */ Hflag = 1; break; d762 1 a762 4 /* * do not follow symlinks */ Lflag = 0; @ 1.19 log @Add -z option to usage message. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.18 1999/02/07 00:56:55 tv Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.18 1999/02/07 00:56:55 tv Exp $"); d210 1 a210 1 while ((c=getopt(argc,argv,"ab:cdf:iklno:p:rs:tuvwx:zB:DE:G:HLPT:U:XYZ")) d402 4 @ 1.18 log @Fix opt_add to take const char * so that it can be passed a constant string legally (it strdup()s the argument). How pax-as-tar `-o' ever worked without a coredump is beyond me... Also modify pax-as-tar `-o' to do three things, which depend on the create/extract mode: - write V7 format archives (which, though part of GNU tar, actually goes along with the following point--after all, old pax-as-tar created V7 archives by default); - write archives with "write_opt=nodir", as pax already did, and as specified by 4.2BSD; - extract archives with owner/group set to invoking user, as specified by SUS. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.17 1999/02/02 23:42:41 tv Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.17 1999/02/02 23:42:41 tv Exp $"); d1381 1 a1381 1 (void)fputs("usage: pax [-cdnv] [-E limit] [-f archive] ", stderr); d1386 1 a1386 1 (void)fputs(" pax -r [-cdiknuvDYZ] [-E limit] ", stderr); d1392 4 a1395 4 (void)fputs(" pax -w [-dituvHLPX] [-b blocksize] ", stderr); (void)fputs("[ [-a] [-f archive] ] [-x format] \n", stderr); (void)fputs(" [-B bytes] [-s replstr] ... ", stderr); (void)fputs("[-o options] ... [-U user] ...", stderr); d1399 1 a1399 1 (void)fputs(" pax -r -w [-diklntuvDHLPXYZ] ", stderr); @ 1.17 log @Lost 5 lines in the version that was committed. Re-add them. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.16 1999/02/02 23:31:52 tv Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.16 1999/02/02 23:31:52 tv Exp $"); d73 1 d136 1 a136 1 #define F_TAR 4 /* format when called as tar */ d674 10 a683 2 /* Change output type to V7 tar. */ if (act == ARCHIVE) d685 5 d696 2 a697 1 pids = 1; d1215 1 a1215 1 opt_add(char *str) d1219 1 a1219 1 char *str; d1231 1 a1231 1 frpt = endpt = str; @ 1.16 log @Uh, when called as "tar" we should still default to "ustar" output, not V7 tar format. Also change meaning of pax-as-tar option "-o" to mean "use V7 output format" (same as GNU tar's -o). @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.15 1999/01/20 14:45:09 mrg Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.15 1999/01/20 14:45:09 mrg Exp $"); d787 6 @ 1.15 log @implement the gnutar -X flag in terms of pax -s. fix some bugs in pax -s handling while i am here... @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.14 1998/07/28 17:44:24 mycroft Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.14 1998/07/28 17:44:24 mycroft Exp $"); d673 3 a675 2 if (opt_add("write_opt=nodir") < 0) tar_usage(); a786 6 /* * if we are writing (ARCHIVE) specify tar, otherwise run like pax */ if (act == ARCHIVE) frmt = &(fsub[F_TAR]); @ 1.14 log @Use the uid/gid caching moved into libc. Fixed a memory leak! @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.13 1998/07/28 11:41:50 mycroft Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.13 1998/07/28 11:41:50 mycroft Exp $"); d615 1 a615 1 while ((c = getoldopt(argc, argv, "b:cef:lmoprutvwxzBC:HLPXZ014578")) d749 1 a749 1 * do not pass over mount points in the file system d751 2 a752 1 Xflag = 1; d1407 1 a1407 1 (void)fputs("[blocksize] file1 file2...\n", stderr); @ 1.13 log @Be more retentive about use of NOTREACHED and noreturn. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.12 1998/07/28 05:31:26 mycroft Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.12 1998/07/28 05:31:26 mycroft Exp $"); d578 1 a578 1 /* FALL THROUGH */ d1077 1 a1077 1 /* FALL THROUGH */ @ 1.12 log @Delint. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.11 1998/06/09 10:53:55 mrg Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.11 1998/06/09 10:53:55 mrg Exp $"); d172 1 a172 1 return(tar_options(argc, argv)); d174 5 a178 6 return(cpio_options(argc, argv)); /* * assume pax as the default */ argv0 = NM_PAX; return(pax_options(argc, argv)); @ 1.11 log @oops, fix broken cpio options code. tar options code should be made like pax and cpio code. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.10 1998/03/06 09:13:02 mrg Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.10 1998/03/06 09:13:02 mrg Exp $"); d1389 1 d1409 1 d1447 1 @ 1.10 log @- implement -C and -l for pax-as-tar, as inspried by GNU tar. - minor cleanups to the options parsing code. - add a cpio frontend. note: a few GNU/svr4 cpio options are not supported yet (#ifdef notyet), however all x/open ones are. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.9 1997/09/14 14:54:34 lukem Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.9 1997/09/14 14:54:34 lukem Exp $"); a1026 2 argc -= optind; argv += optind; @ 1.9 log @* cleanup manpage * getopt returns -1 not EOF * deprecate register @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.8 1997/07/20 20:32:35 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: options.c,v 1.8 1997/07/20 20:32:35 christos Exp $"); d70 4 a73 1 static char flgch[] = FLGCH; /* list of all possible flags */ a84 1 #ifdef notdef a86 1 #endif d131 7 a137 2 #define F_TAR 4 /* format when called as tar */ #define DEFLT 5 /* default write format from list above */ d144 1 a144 1 int ford[] = {5, 4, 3, 2, 1, 0, -1 }; a172 1 # ifdef notdef a174 1 # endif d616 1 a616 1 while ((c = getoldopt(argc, argv, "b:cef:moprutvwxzBHLPXZ014578")) d634 6 d661 6 a821 1 #ifdef notdef d838 254 a1092 1 #endif d1406 1 a1406 1 (void)fputs("usage: tar -{txru}[cevfbmopwBHLPX014578] [tapefile] ", a1411 1 #ifdef notdef d1425 21 a1447 1 #endif @ 1.8 log @- Rename local warn so tty_warn that we can include since this program uses err() and errx(). - Fix printf format strings. - Added WARNS=1; note - Added missing prototypes. - Split overloaded trail function into trail() and subtrail(). @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.7 1997/01/11 02:06:41 tls Exp $ */ d45 1 a45 1 __RCSID("$NetBSD$"); d207 1 a207 1 != EOF) { d613 1 a613 1 != EOF) { @ 1.7 log @kill 'register' @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $ */ d40 1 d45 1 a45 1 static char rcsid[] = "$NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $"; d101 3 a103 3 "bcpio", 5120, sizeof(HD_BCPIO), 1, 0, 0, 1, bcpio_id, cpio_strd, bcpio_rd, bcpio_endrd, cpio_stwr, bcpio_wr, cpio_endwr, cpio_trail, rd_wrfile, wr_rdfile, bad_opt, d106 3 a108 3 "cpio", 5120, sizeof(HD_CPIO), 1, 0, 0, 1, cpio_id, cpio_strd, cpio_rd, cpio_endrd, cpio_stwr, cpio_wr, cpio_endwr, cpio_trail, rd_wrfile, wr_rdfile, bad_opt, d111 3 a113 3 "sv4cpio", 5120, sizeof(HD_VCPIO), 1, 0, 0, 1, vcpio_id, cpio_strd, vcpio_rd, vcpio_endrd, cpio_stwr, vcpio_wr, cpio_endwr, cpio_trail, rd_wrfile, wr_rdfile, bad_opt, d116 3 a118 3 "sv4crc", 5120, sizeof(HD_VCPIO), 1, 0, 0, 1, crc_id, crc_strd, vcpio_rd, vcpio_endrd, crc_stwr, vcpio_wr, cpio_endwr, cpio_trail, rd_wrfile, wr_rdfile, bad_opt, d121 1 a121 1 "tar", 10240, BLKMULT, 0, 1, BLKMULT, 0, tar_id, no_op, d123 1 a123 1 rd_wrfile, wr_rdfile, tar_opt, d126 1 a126 1 "ustar", 10240, BLKMULT, 0, 1, BLKMULT, 0, ustar_id, ustar_strd, d128 1 a128 1 rd_wrfile, wr_rdfile, bad_opt, d221 1 a221 1 warn(1, "Invalid block size %s", optarg); d323 2 a324 1 warn(1, "Invalid -p string: %c", *pt); d379 3 a381 2 if (frmt = (FSUB *)bsearch((void *)&tmp, (void *)fsub, sizeof(fsub)/sizeof(FSUB), sizeof(FSUB), c_frmt)) { d385 1 a385 1 warn(1, "Unknown -x format: %s", optarg); d405 1 a405 1 warn(1, "Invalid write limit %s", optarg); d409 2 a410 1 warn(1, "Write limit is not a %d byte multiple", d434 2 a435 1 warn(1, "Error count value must be positive"); d570 1 a570 1 warn(0, "Destination directory was not supplied"); d620 1 a620 1 warn(1, "Invalid block size %s", optarg); d844 1 a844 1 while (nxt = ffs(flg)) { d915 1 a915 1 warn(1,"These format options are not supported"); d946 1 a946 1 warn(0, "Invalid option name"); d960 1 a960 1 warn(0, "Invalid options format"); d964 1 a964 1 warn(0, "Unable to allocate space for option list"); @ 1.6 log @impliment -z (gzip) in pax and tar, and -Z (compress) in tar. @ text @d1 1 a1 1 /* $NetBSD: options.c,v 1.5 1995/03/21 09:07:30 cgd Exp $ */ d44 1 a44 1 static char rcsid[] = "$NetBSD: options.c,v 1.5 1995/03/21 09:07:30 cgd Exp $"; d77 1 a77 1 static void pax_options __P((register int, register char **)); d79 1 a79 1 static void tar_options __P((register int, register char **)); d82 1 a82 1 static void cpio_options __P((register int, register char **)); d147 1 a147 1 options(register int argc, register char **argv) d151 2 a152 2 register int argc; register char **argv; d185 1 a185 1 pax_options(register int argc, register char **argv) d189 2 a190 2 register int argc; register char **argv; d193 2 a194 2 register int c; register int i; d197 1 a197 1 register char *pt; d593 1 a593 1 tar_options(register int argc, register char **argv) d597 2 a598 2 register int argc; register char **argv; d601 1 a601 1 register int c; d810 1 a810 1 cpio_options(register int argc, register char **argv) d814 2 a815 2 register int argc; register char **argv; d903 1 a903 1 register OPLIST *opt; d928 1 a928 1 opt_add(register char *str) d932 1 a932 1 register char *str; d935 4 a938 4 register OPLIST *opt; register char *frpt; register char *pt; register char *endpt; @ 1.5 log @convert to new RCS id conventions. @ text @d1 1 a1 1 /* $NetBSD$ */ d44 1 a44 1 static char rcsid[] = "$NetBSD$"; d86 3 d205 1 a205 1 while ((c=getopt(argc,argv,"ab:cdf:iklno:p:rs:tuvwx:B:DE:G:HLPT:U:XYZ")) d389 7 d607 1 a607 1 while ((c = getoldopt(argc, argv, "b:cef:moprutvwxBHLPX014578")) d697 7 d732 7 @ 1.4 log @Whoever wrote the tar command line argument parsing code didn't realize that the order of arguments is different if the command flags are specified without a `-'. I've integrated getoldopt.c from John Gilmore's pdtar which handles argument parsing correctly. @ text @d1 2 d41 5 a45 2 /*static char sccsid[] = "from: @@(#)options.c 8.2 (Berkeley) 4/18/94";*/ static char *rcsid = "$Id: options.c,v 1.3 1994/06/14 00:42:47 mycroft Exp $"; @ 1.3 log @Fix up RCS ids. @ text @d40 1 a40 1 static char *rcsid = "$Id: options.c,v 1.2 1994/06/13 16:34:06 jtc Exp $"; d586 1 a586 1 register char *cp; a588 2 if (argc < 2) tar_usage(); d592 3 a594 8 ++argv; for (cp = *argv++; *cp != '\0'; ++cp) { switch (*cp) { case '-': /* * skip over - */ break; d599 2 a600 2 if (*argv == (char *)NULL) { warn(1,"blocksize must be specified with 'b'"); a602 5 if ((wrblksz = (int)str_offt(*argv)) <= 0) { warn(1, "Invalid block size %s", *argv); tar_usage(); } ++argv; d620 1 a620 5 if (*argv == (char *)NULL) { warn(1, "filename must be specified with 'f'"); tar_usage(); } if ((argv[0][0] == '-') && (argv[0][1]== '\0')) { d624 1 a624 2 ++argv; ++fstdin; d629 1 a629 1 arcname = *argv++; d734 2 @ 1.2 log @Add RCS ID's @ text @d40 1 a40 1 static char rcsid[] = "$Id: $"; @ 1.1 log @Initial revision @ text @d39 2 a40 1 static char sccsid[] = "@@(#)options.c 8.2 (Berkeley) 4/18/94"; @ 1.1.1.1 log @From 4.4 lite @ text @@