create.c (121299) | create.c (121300) |
---|---|
1/*- 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. | 1/*- 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. |
13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors | 13 * 3. Neither the name of the University nor the names of its contributors |
18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL --- 6 unchanged lines hidden (view full) --- 32 */ 33 34#if 0 35#ifndef lint 36static char sccsid[] = "@(#)create.c 8.1 (Berkeley) 6/6/93"; 37#endif /* not lint */ 38#endif 39#include <sys/cdefs.h> | 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL --- 6 unchanged lines hidden (view full) --- 28 */ 29 30#if 0 31#ifndef lint 32static char sccsid[] = "@(#)create.c 8.1 (Berkeley) 6/6/93"; 33#endif /* not lint */ 34#endif 35#include <sys/cdefs.h> |
40__FBSDID("$FreeBSD: head/usr.sbin/mtree/create.c 121299 2003-10-21 07:58:52Z phk $"); | 36__FBSDID("$FreeBSD: head/usr.sbin/mtree/create.c 121300 2003-10-21 08:27:05Z phk $"); |
41 42#include <sys/param.h> 43#include <sys/stat.h> 44#include <dirent.h> 45#include <err.h> 46#include <errno.h> 47#include <fcntl.h> 48#include <fts.h> --- 110 unchanged lines hidden (view full) --- 159 if (escaped_name == NULL) 160 errx(1, "statf(): calloc() failed"); 161 strvis(escaped_name, p->fts_name, VIS_WHITE | VIS_OCTAL); 162 163 if (iflag || S_ISDIR(p->fts_statp->st_mode)) 164 offset = printf("%*s%s", indent, "", escaped_name); 165 else 166 offset = printf("%*s %s", indent, "", escaped_name); | 37 38#include <sys/param.h> 39#include <sys/stat.h> 40#include <dirent.h> 41#include <err.h> 42#include <errno.h> 43#include <fcntl.h> 44#include <fts.h> --- 110 unchanged lines hidden (view full) --- 155 if (escaped_name == NULL) 156 errx(1, "statf(): calloc() failed"); 157 strvis(escaped_name, p->fts_name, VIS_WHITE | VIS_OCTAL); 158 159 if (iflag || S_ISDIR(p->fts_statp->st_mode)) 160 offset = printf("%*s%s", indent, "", escaped_name); 161 else 162 offset = printf("%*s %s", indent, "", escaped_name); |
167 | 163 |
168 free(escaped_name); 169 170 if (offset > (INDENTNAMELEN + indent)) 171 offset = MAXLINELEN; 172 else 173 offset += printf("%*s", (INDENTNAMELEN + indent) - offset, ""); 174 175 if (!S_ISREG(p->fts_statp->st_mode) && !dflag) --- 161 unchanged lines hidden (view full) --- 337 } 338 /* 339 * If the /set record is the same as the last one we do not need to output 340 * a new one. So first we check to see if anything changed. Note that we 341 * always output a /set record for the first directory. 342 */ 343 if ((((keys & F_UNAME) | (keys & F_UID)) && (*puid != saveuid)) || 344 (((keys & F_GNAME) | (keys & F_GID)) && (*pgid != savegid)) || | 164 free(escaped_name); 165 166 if (offset > (INDENTNAMELEN + indent)) 167 offset = MAXLINELEN; 168 else 169 offset += printf("%*s", (INDENTNAMELEN + indent) - offset, ""); 170 171 if (!S_ISREG(p->fts_statp->st_mode) && !dflag) --- 161 unchanged lines hidden (view full) --- 333 } 334 /* 335 * If the /set record is the same as the last one we do not need to output 336 * a new one. So first we check to see if anything changed. Note that we 337 * always output a /set record for the first directory. 338 */ 339 if ((((keys & F_UNAME) | (keys & F_UID)) && (*puid != saveuid)) || 340 (((keys & F_GNAME) | (keys & F_GID)) && (*pgid != savegid)) || |
345 ((keys & F_MODE) && (*pmode != savemode)) || | 341 ((keys & F_MODE) && (*pmode != savemode)) || |
346 ((keys & F_FLAGS) && (*pflags != saveflags)) || 347 (first)) { 348 first = 0; 349 if (dflag) 350 (void)printf("/set type=dir"); 351 else 352 (void)printf("/set type=file"); 353 if (keys & F_UNAME) { --- 65 unchanged lines hidden --- | 342 ((keys & F_FLAGS) && (*pflags != saveflags)) || 343 (first)) { 344 first = 0; 345 if (dflag) 346 (void)printf("/set type=dir"); 347 else 348 (void)printf("/set type=file"); 349 if (keys & F_UNAME) { --- 65 unchanged lines hidden --- |