Messages::Messages(GuiWidgets* _gw) : gw(*_gw) { messages.addAttr(UOrient::vertical + UFont::small + utop()); messages.add(uhbox(UFont::bold + UColor::orange + "Have fun with VREng ;-)")); history.push_back(ustr("")); history_pos = 0; }
/* * Check for a valid statefile pathname, inode and mount status. */ int sfpath(void) { static int statefile; char *err_fmt = NULL; char *sfile, *sp, ch; char diskname[256]; struct stat stbuf; int dir = 0; dev_t dev = NODEV; if (statefile) { mesg(MERR, "ignored redundant statefile entry\n"); return (OKUP); } else if (ua_err) { if (ua_err != ENOTSUP) mesg(MERR, "uadmin(A_FREEZE, A_CHECK, 0): %s\n", strerror(ua_err)); return (NOUP); } /* * Check for an absolute path and trim any trailing '/'. */ sfile = LINEARG(1); if (*sfile != '/') { mesg(MERR, "statefile requires an absolute path\n"); return (NOUP); } for (sp = sfile + strlen(sfile) - 1; sp > sfile && *sp == '/'; sp--) *sp = '\0'; /* * If the statefile doesn't exist, the leading path must be a dir. */ if (stat(sfile, &stbuf) == -1) { if (errno == ENOENT) { dir = 1; if ((sp = strrchr(sfile, '/')) == sfile) sp++; ch = *sp; *sp = '\0'; if (stat(sfile, &stbuf) == -1) err_fmt = stat_fmt; *sp = ch; } else err_fmt = stat_fmt; if (err_fmt) { mesg(MERR, err_fmt, sfile, strerror(errno)); return (NOUP); } } /* * Check for regular/dir/block types, set cf_type and dev. */ if (S_ISREG(stbuf.st_mode) || (dir && S_ISDIR(stbuf.st_mode))) { new_cc.cf_type = CFT_UFS; dev = stbuf.st_dev; } else if (S_ISBLK(stbuf.st_mode)) { if (is_good_slice(sfile, &err_fmt)) { switch (ztop(sfile, diskname)) { case 1: new_cc.cf_type = CFT_ZVOL; break; case 0: new_cc.cf_type = CFT_SPEC; break; case -1: default: return (NOUP); } dev = stbuf.st_rdev; } } else err_fmt = "bad file type for \"%s\"\n" "statefile must be a regular file or block device\n"; if (err_fmt) { mesg(MERR, err_fmt, sfile); return (NOUP); } if (check_mount(sfile, dev, (new_cc.cf_type == CFT_UFS))) return (NOUP); if (new_cc.cf_type == CFT_ZVOL) { if (utop(diskname, new_cc.cf_dev_prom)) return (NOUP); } else if (utop(new_cc.cf_devfs, new_cc.cf_dev_prom)) { return (NOUP); } new_cc.cf_magic = CPR_CONFIG_MAGIC; statefile = 1; return (OKUP); }