VirtualBox

Changeset 2466 in kBuild


Ignore:
Timestamp:
Jul 12, 2011 9:52:39 AM (14 years ago)
Author:
bird
Message:

kmkbuiltins: More specific error messages (solaris EINTR).

Location:
trunk/src/kmk/kmkbuiltin
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/append.c

    r2413 r2466  
    178178    pFile = fopen(argv[i], fTruncate ? "w" : "a");
    179179    if (!pFile)
    180         return err(1, "failed to open '%s'.", argv[i]);
     180        return err(1, "failed to open '%s'", argv[i]);
    181181
    182182    /*
  • trunk/src/kmk/kmkbuiltin/chmod.c

    r2421 r2466  
    196196                        continue;
    197197                case FTS_DNR:                   /* Warn, chmod, continue. */
    198                         warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
     198                        warnx("fts: %s: %s", p->fts_path, strerror(p->fts_errno));
    199199                        rval = 1;
    200200                        break;
    201201                case FTS_ERR:                   /* Warn, continue. */
    202202                case FTS_NS:
    203                         warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
     203                        warnx("fts: %s: %s", p->fts_path, strerror(p->fts_errno));
    204204                        rval = 1;
    205205                        continue;
     
    222222                        continue;
    223223                if ((*change_mode)(p->fts_accpath, newmode) && !fflag) {
    224                         warn("%s", p->fts_path);
     224                        warn("%schmod: %s", hflag ? "l" : "", p->fts_path);
    225225                        rval = 1;
    226226                } else {
  • trunk/src/kmk/kmkbuiltin/cp.c

    r2206 r2466  
    337337        if (r == -1 && errno != ENOENT) {
    338338                kBuildProtectionTerm(&g_ProtData);
    339                 return err(1, "%s", to.p_path);
     339                return err(1, "stat: %s", to.p_path);
    340340        }
    341341        if (r == -1 || !S_ISDIR(to_stat.st_mode)) {
     
    424424                            && curr->fts_errno == ENOENT) {
    425425                                if (vflag) {
    426                                         warnx("%s: %s", curr->fts_path,
     426                                        warnx("fts: %s: %s", curr->fts_path,
    427427                                              strerror(curr->fts_errno));
    428428                                }
     
    431431                case FTS_DNR:
    432432                case FTS_ERR:
    433                         warnx("%s: %s",
     433                        warnx("fts: %s: %s",
    434434                            curr->fts_path, strerror(curr->fts_errno));
    435435                        badcp = rval = 1;
     
    594594                                if (mkdir(to.p_path,
    595595                                    curr->fts_statp->st_mode | S_IRWXU) < 0)
    596                                         return err(1, "%s", to.p_path);
     596                                        return err(1, "mkdir: %s", to.p_path);
    597597                        } else if (!S_ISDIR(to_stat.st_mode)) {
    598598                                errno = ENOTDIR;
    599                                 return err(1, "%s", to.p_path);
     599                                return err(1, "to-mode: %s", to.p_path);
    600600                        }
    601601                        /*
  • trunk/src/kmk/kmkbuiltin/cp_utils.c

    r2192 r2466  
    9898
    9999        if ((from_fd = open(entp->fts_path, O_RDONLY | O_BINARY, 0)) == -1) {
    100                 warn("%s", entp->fts_path);
     100                warn("open: %s", entp->fts_path);
    101101                return (1);
    102102        }
     
    124124                                close(from_fd);
    125125                                if ((from_fd = open(entp->fts_path, O_RDONLY | O_BINARY, 0)) == -1) {
    126                                         warn("%s", entp->fts_path);
     126                                        warn("open: %s", entp->fts_path);
    127127                                        return (1);
    128128                                }
     
    162162
    163163        if (to_fd == -1) {
    164                 warn("%s", to.p_path);
     164                warn("open: %s", to.p_path);
    165165                (void)close(from_fd);
    166166                return (1);
     
    180180                if ((p = mmap(NULL, (size_t)fs->st_size, PROT_READ,
    181181                    MAP_SHARED, from_fd, (off_t)0)) == MAP_FAILED) {
    182                         warn("%s", entp->fts_path);
     182                        warn("mmap: %s", entp->fts_path);
    183183                        rval = 1;
    184184                } else {
     
    200200                        }
    201201                        if (wcount != (ssize_t)wresid) {
    202                                 warn("%s", to.p_path);
     202                                warn("write[%zd != %zu]: %s", wcount, wresid, to.p_path);
    203203                                rval = 1;
    204204                        }
    205205                        /* Some systems don't unmap on close(2). */
    206206                        if (munmap(p, fs->st_size) < 0) {
    207                                 warn("%s", entp->fts_path);
     207                                warn("munmap: %s", entp->fts_path);
    208208                                rval = 1;
    209209                        }
     
    230230                        }
    231231                        if (wcount != (ssize_t)wresid) {
    232                                 warn("%s", to.p_path);
     232                                warn("write[%zd != %zu]: %s", wcount, wresid, to.p_path);
    233233                                rval = 1;
    234234                                break;
     
    236236                }
    237237                if (rcount < 0) {
    238                         warn("%s", entp->fts_path);
     238                        warn("read: %s", entp->fts_path);
    239239                        rval = 1;
    240240                }
     
    252252        (void)close(from_fd);
    253253        if (close(to_fd)) {
    254                 warn("%s", to.p_path);
     254                warn("close: %s", to.p_path);
    255255                rval = 1;
    256256        }
  • trunk/src/kmk/kmkbuiltin/ln.c

    r2129 r2466  
    155155                 */
    156156                errno = ENOTDIR;
    157                 return err(1, "%s", sourcedir);
     157                return err(1, "st_mode: %s", sourcedir);
    158158        }
    159159        if (stat(sourcedir, &sb))
    160                 return err(1, "%s", sourcedir);
     160                return err(1, "stat: %s", sourcedir);
    161161        if (!S_ISDIR(sb.st_mode))
    162162                return usage(stderr);
     
    177177                /* If target doesn't exist, quit now. */
    178178                if (stat(target, &sb)) {
    179                         warn("%s", target);
     179                        warn("stat: %s", target);
    180180                        return (1);
    181181                }
     
    183183                if (S_ISDIR(sb.st_mode)) {
    184184                        errno = EISDIR;
    185                         warn("%s", target);
     185                        warn("st_mode: %s", target);
    186186                        return (1);
    187187                }
     
    210210                    (ssize_t)sizeof(path)) {
    211211                        errno = ENAMETOOLONG;
    212                         warn("%s", target);
     212                        warn("snprintf: %s", target);
    213213                        return (1);
    214214                }
     
    223223        if (fflag && exists) {
    224224                if (unlink(source)) {
    225                         warn("%s", source);
     225                        warn("unlink: %s", source);
    226226                        return (1);
    227227                }
     
    239239
    240240                if (unlink(source)) {
    241                         warn("%s", source);
     241                        warn("unlink: %s", source);
    242242                        return (1);
    243243                }
     
    246246        /* Attempt the link. */
    247247        if ((*linkf)(target, source)) {
    248                 warn("%s", source);
     248                warn("%s: %s", linkf == link ? "link" : "symlink", source);
    249249                return (1);
    250250        }
  • trunk/src/kmk/kmkbuiltin/mkdir.c

    r2465 r2466  
    144144                } else if (mkdir(*argv, omode) < 0) {
    145145                        if (errno == ENOTDIR || errno == ENOENT)
    146                                 warn("%s [mkdir]", dirname(*argv));
     146                                warn("mkdir: %s", dirname(*argv));
    147147                        else
    148                                 warn("%s [mkdir]", *argv);
     148                                warn("mkdir: %s", *argv);
    149149                        success = 0;
    150150                } else if (vflag)
     
    161161                 */
    162162                if (success && mode != NULL && chmod(*argv, omode) == -1) {
    163                         warn("%s [chmod]", *argv);
     163                        warn("chmod: %s", *argv);
    164164                        exitval = 1;
    165165                }
     
    246246                            || errno == EACCES /* (ditto) */) {
    247247                                if (stat(path, &sb) < 0) {
    248                                         warn("%s [stat]", path);
     248                                        warn("stat: %s", path);
    249249                                        retval = 1;
    250250                                        break;
     
    254254                                        else
    255255                                                errno = ENOTDIR;
    256                                         warn("%s [st_mode]", path);
     256                                        warn("st_mode: %s", path);
    257257                                        retval = 1;
    258258                                        break;
    259259                                }
    260260                        } else {
    261                                 warn("%s [mkdir]", path);
     261                                warn("mkdir: %s", path);
    262262                                retval = 1;
    263263                                break;
  • trunk/src/kmk/kmkbuiltin/rm.c

    r2464 r2466  
    3939#endif /* not lint */
    4040#include <sys/cdefs.h>
    41 //__FBSDID("$FreeBSD: src/bin/rm/rm.c,v 1.47 2004/04/06 20:06:50 markm Exp $");
     41/*__FBSDID("$FreeBSD: src/bin/rm/rm.c,v 1.47 2004/04/06 20:06:50 markm Exp $");*/
    4242#endif
    4343
     
    287287        }
    288288        while ((p = fts_read(fts)) != NULL) {
     289                const char *operation = "chflags";
    289290                switch (p->fts_info) {
    290291                case FTS_DNR:
    291292                        if (!fflag || p->fts_errno != ENOENT) {
    292                                 fprintf(stderr, "%s: %s: %s" CUR_LINE() "\n",
     293                                fprintf(stderr, "fts: %s: %s: %s" CUR_LINE() "\n",
    293294                                        argv0, p->fts_path, strerror(p->fts_errno));
    294295                                eval = 1;
     
    297298                case FTS_ERR:
    298299                        fts_close(fts);
    299                         return errx(1, "%s: %s " CUR_LINE(), p->fts_path, strerror(p->fts_errno));
     300                        return errx(1, "fts: %s: %s " CUR_LINE(), p->fts_path, strerror(p->fts_errno));
    300301                case FTS_NS:
    301302                        /*
     
    306307                                break;
    307308                        if (!fflag || p->fts_errno != ENOENT) {
    308                                 fprintf(stderr, "%s: %s: %s " CUR_LINE() "\n",
    309                                         argv0, p->fts_path, strerror(p->fts_errno), __LINE__);
     309                                fprintf(stderr, "fts: %s: %s: %s " CUR_LINE() "\n",
     310                                        argv0, p->fts_path, strerror(p->fts_errno));
    310311                                eval = 1;
    311312                        }
     
    370371                                        continue;
    371372                                }
     373                                operation = "mkdir";
    372374                                break;
    373375
     
    381383                                        continue;
    382384                                }
     385                                operation = "undelete";
    383386                                break;
    384387#endif
     
    410413                                        continue;
    411414                                }
     415                                operation = "unlink";
     416                                break;
    412417                        }
    413418                }
     
    415420err:
    416421#endif
    417                 fprintf(stderr, "%s: %s: %s " CUR_LINE() "\n", argv0, p->fts_path, strerror(errno));
     422                fprintf(stderr, "%s: %s: %s: %s " CUR_LINE() "\n", operation, argv0, p->fts_path, strerror(errno));
    418423                eval = 1;
    419424        }
     
    447452         */
    448453        while ((f = *argv++) != NULL) {
     454                const char *operation = "?";
    449455                /* Assume if can't stat the file, can't unlink it. */
    450456                if (lstat(f, &sb)) {
     
    457463#endif
    458464                                if (!fflag || errno != ENOENT) {
    459                                         fprintf(stderr, "%s: %s: %s " CUR_LINE() "\n", argv0, f, strerror(errno));
     465                                        fprintf(stderr, "lstat: %s: %s: %s " CUR_LINE() "\n", argv0, f, strerror(errno));
    460466                                        eval = 1;
    461467                                }
     
    485491#endif
    486492                if (rval == 0) {
    487                         if (S_ISWHT(sb.st_mode))
     493                        if (S_ISWHT(sb.st_mode)) {
    488494                                rval = undelete(f);
    489                         else if (S_ISDIR(sb.st_mode))
     495                                operation = "undelete";
     496                        } else if (S_ISDIR(sb.st_mode)) {
    490497                                rval = rmdir(f);
    491                         else {
     498                                operation = "rmdir";
     499                        } else {
    492500                                if (Pflag)
    493501                                        if (!rm_overwrite(f, &sb))
     
    500508                                }
    501509#endif
     510                                operation = "unlink";
    502511                        }
    503512                }
    504513                if (rval && (!fflag || errno != ENOENT)) {
    505                         fprintf(stderr, "%s: %s: %s" CUR_LINE() "\n", argv0, f, strerror(errno));
     514                        fprintf(stderr, "%s: %s: %s: %s" CUR_LINE() "\n", operation, argv0, f, strerror(errno));
    506515                        eval = 1;
    507516                }
     
    533542        int bsize, fd, wlen;
    534543        char *buf = NULL;
     544        const char *operation = "lstat";
    535545
    536546        fd = -1;
     
    542552        if (!S_ISREG(sbp->st_mode))
    543553                return (1);
     554        operation = "open";
    544555        if ((fd = open(file, O_WRONLY, 0)) == -1)
    545556                goto err;
     
    557568
    558569#define PASS(byte) {                                                    \
     570        operation = "write";                                            \
    559571        memset(buf, byte, bsize);                                       \
    560572        for (len = sbp->st_size; len > 0; len -= wlen) {                \
     
    565577}
    566578        PASS(0xff);
     579        operation = "fsync/lseek";
    567580        if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET))
    568581                goto err;
    569582        PASS(0x00);
     583        operation = "fsync/lseek";
    570584        if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET))
    571585                goto err;
     
    575589                return (1);
    576590        }
     591        operation = "fsync/close";
    577592
    578593err:    eval = 1;
     
    581596        if (fd != -1)
    582597                close(fd);
    583         fprintf(stderr, "%s: %s: %s" CUR_LINE() "\n", argv0, file, strerror(errno));
     598        fprintf(stderr, "%s: %s: %s: %s" CUR_LINE() "\n", operation, argv0, file, strerror(errno));
    584599        return (0);
    585600}
  • trunk/src/kmk/kmkbuiltin/rmdir.c

    r2121 r2466  
    128128                        if (    (!ignore_fail_on_non_empty || (errno != ENOTEMPTY && errno != EPERM && errno != EACCES && errno != EINVAL && errno != EEXIST))
    129129                            &&  (!ignore_fail_on_not_exist || errno != ENOENT)) {
    130                                 warn("%s", *argv);
     130                                warn("rmdir: %s", *argv);
    131131                                errors = 1;
    132132                                continue;
     
    181181                                break;
    182182                        if (!ignore_fail_on_not_exist || errno != ENOENT) {
    183                                 warn("%s", path);
     183                                warn("rmdir: %s", path);
    184184                                return (1);
    185185                        }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette