static void print_item(item_t *i) { stat_attr_t *bytes, *packets; double rx, tx, rxp, txp; int rxprec, txprec, rxpprec, txpprec; char *rx_u, *tx_u, *rxp_u, *txp_u; char pad[IFNAMSIZ + 32]; if (get_print_header()) { printf("Name RX Rate # %%" \ " TX Rate # %%\n"); } bytes = lookup_attr(i, i->i_major_attr); packets = lookup_attr(i, i->i_minor_attr); rx = cancel_down(attr_get_rx_rate(bytes), bytes->a_unit, &rx_u, &rxprec); tx = cancel_down(attr_get_tx_rate(bytes), bytes->a_unit, &tx_u, &txprec); rxp = cancel_down(attr_get_rx_rate(packets), packets->a_unit, &rxp_u, &rxpprec); txp = cancel_down(attr_get_tx_rate(packets), packets->a_unit, &txp_u, &txpprec); memset(pad, 0, sizeof(pad)); memset(pad, ' ', i->i_level < 15 ? i->i_level : 15); strncat(pad, i->i_name, sizeof(pad) - strlen(pad) - 1); if (i->i_desc) { strncat(pad, " (", sizeof(pad) - strlen(pad) - 1); strncat(pad, i->i_desc, sizeof(pad) - strlen(pad) - 1); strncat(pad, ")", sizeof(pad) - strlen(pad) - 1); } printf("%-22s %8.*f%s %8.*f%s ", pad, rxprec, rx, rx_u, rxpprec, rxp, rxp_u); if (i->i_rx_usage < 0) printf(" "); else printf("%2d%%", i->i_rx_usage); printf(" %8.*f%s %8.*f%s ", txprec, tx, tx_u, txpprec, txp, txp_u); if (i->i_tx_usage < 0) printf(" "); else printf("%2d%%", i->i_tx_usage); printf("\n"); }
fh_entry * filesrv::lookup_add (str p) { ex_fattr3 fa; nfs_fh3 fh; if (!lookup_attr (p, &fa)) return NULL; mk_fh (&fh, &fa); fh_entry *fhe = lookup (&fh); if (!fhe) { if (checkfhe ()) { fhe = New fh_entry (p, fh, &fa, this); entries.insert (fhe); timeoutlist.insert_tail (fhe); fhe_n++; } else { errno = EMFILE; return NULL; } } return fhe; }
int main(int argc, char *argv[]) { #define TEST_FILE "describecol.in" const char *in_file = FREETDS_SRCDIR "/" TEST_FILE; FILE *f; char buf[256]; SQLINTEGER i; SQLLEN len; check_attr_t check_attr_p = check_attr_none; odbc_connect(); odbc_command("SET TEXTSIZE 4096"); SQLBindCol(odbc_stmt, 1, SQL_C_SLONG, &i, sizeof(i), &len); f = fopen(in_file, "r"); if (!f) fopen(TEST_FILE, "r"); if (!f) { fprintf(stderr, "error opening test file\n"); exit(1); } line_num = 0; while (fgets(buf, sizeof(buf), f)) { char *p = buf, *cmd; ++line_num; while (isspace((unsigned char) *p)) ++p; cmd = strtok(p, SEP); /* skip comments */ if (!cmd || cmd[0] == '#' || cmd[0] == 0 || cmd[0] == '\n') continue; if (strcmp(cmd, "odbc") == 0) { int odbc3 = get_int(strtok(NULL, SEP)) == 3 ? 1 : 0; if (odbc_use_version3 != odbc3) { odbc_use_version3 = odbc3; odbc_disconnect(); odbc_connect(); odbc_command("SET TEXTSIZE 4096"); SQLBindCol(odbc_stmt, 1, SQL_C_SLONG, &i, sizeof(i), &len); } } /* select type */ if (strcmp(cmd, "select") == 0) { const char *type = strtok(NULL, SEP); const char *value = strtok(NULL, SEP); char sql[sizeof(buf) + 40]; SQLMoreResults(odbc_stmt); odbc_reset_statement(); sprintf(sql, "SELECT CONVERT(%s, %s) AS col", type, value); /* ignore error, we only need precision of known types */ check_attr_p = check_attr_none; if (odbc_command_with_result(odbc_stmt, sql) != SQL_SUCCESS) { odbc_reset_statement(); SQLBindCol(odbc_stmt, 1, SQL_C_SLONG, &i, sizeof(i), &len); continue; } CHKFetch("SI"); SQLBindCol(odbc_stmt, 1, SQL_C_SLONG, &i, sizeof(i), &len); check_attr_p = check_attr_ird; } /* set attribute */ if (strcmp(cmd, "set") == 0) { const struct attribute *attr = lookup_attr(strtok(NULL, SEP)); char *value = strtok(NULL, SEP); SQLHDESC desc; SQLRETURN ret; SQLINTEGER ind; if (!value) fatal("Line %u: value not defined\n", line_num); /* get ARD */ SQLGetStmtAttr(odbc_stmt, SQL_ATTR_APP_ROW_DESC, &desc, sizeof(desc), &ind); ret = SQL_ERROR; switch (attr->type) { case type_INTEGER: ret = SQLSetDescField(desc, 1, attr->value, int2ptr(lookup(value, attr->lookup)), sizeof(SQLINTEGER)); break; case type_SMALLINT: ret = SQLSetDescField(desc, 1, attr->value, int2ptr(lookup(value, attr->lookup)), sizeof(SQLSMALLINT)); break; case type_LEN: ret = SQLSetDescField(desc, 1, attr->value, int2ptr(lookup(value, attr->lookup)), sizeof(SQLLEN)); break; case type_CHARP: ret = SQLSetDescField(desc, 1, attr->value, (SQLPOINTER) value, SQL_NTS); break; } if (!SQL_SUCCEEDED(ret)) fatal("Line %u: failure not expected setting ARD attribute\n", line_num); check_attr_p = check_attr_ard; } /* test attribute */ if (strcmp(cmd, "attr") == 0) { const struct attribute *attr = lookup_attr(strtok(NULL, SEP)); char *expected = strtok(NULL, SEP); if (!expected) fatal("Line %u: value not defined\n", line_num); check_attr_p(attr, expected); } } fclose(f); odbc_disconnect(); printf("Done.\n"); return g_result; }
int main(int argc, char *argv[]) { #define TEST_FILE "attributes.in" const char *in_file = FREETDS_SRCDIR "/" TEST_FILE; FILE *f; char buf[256]; SQLINTEGER i; SQLLEN len; get_attr_t get_attr_p = get_attr_stmt; odbc_connect(); /* TODO find another way */ odbc_check_cursor(); odbc_command("SET TEXTSIZE 4096"); SQLBindCol(odbc_stmt, 1, SQL_C_SLONG, &i, sizeof(i), &len); f = fopen(in_file, "r"); if (!f) f = fopen(TEST_FILE, "r"); if (!f) { fprintf(stderr, "error opening test file\n"); exit(1); } line_num = 0; while (fgets(buf, sizeof(buf), f)) { char *p = buf, *cmd; ++line_num; while (isspace((unsigned char) *p)) ++p; cmd = strtok(p, SEP); /* skip comments */ if (!cmd || cmd[0] == '#' || cmd[0] == 0 || cmd[0] == '\n') continue; if (strcmp(cmd, "odbc") == 0) { int odbc3 = get_int(strtok(NULL, SEP)) == 3 ? 1 : 0; if (odbc_use_version3 != odbc3) { odbc_use_version3 = odbc3; odbc_disconnect(); odbc_connect(); odbc_command("SET TEXTSIZE 4096"); SQLBindCol(odbc_stmt, 1, SQL_C_SLONG, &i, sizeof(i), &len); } continue; } /* set attribute */ if (strcmp(cmd, "set") == 0) { const struct attribute *attr = lookup_attr(strtok(NULL, SEP)); char *value = strtok(NULL, SEP); SQLRETURN ret; if (!value) fatal("Line %u: value not defined\n", line_num); ret = SQL_ERROR; switch (attr->type) { case type_UINTEGER: case type_INTEGER: ret = SQLSetStmtAttr(odbc_stmt, attr->value, int2ptr(lookup(value, attr->lookup)), sizeof(SQLINTEGER)); break; case type_SMALLINT: ret = SQLSetStmtAttr(odbc_stmt, attr->value, int2ptr(lookup(value, attr->lookup)), sizeof(SQLSMALLINT)); break; case type_LEN: ret = SQLSetStmtAttr(odbc_stmt, attr->value, int2ptr(lookup(value, attr->lookup)), sizeof(SQLLEN)); break; case type_CHARP: ret = SQLSetStmtAttr(odbc_stmt, attr->value, (SQLPOINTER) value, SQL_NTS); break; case type_VOIDP: case type_DESC: fatal("Line %u: not implemented\n"); } if (!SQL_SUCCEEDED(ret)) fatal("Line %u: failure not expected setting statement attribute\n", line_num); get_attr_p = get_attr_stmt; continue; } /* test attribute */ if (strcmp(cmd, "attr") == 0) { const struct attribute *attr = lookup_attr(strtok(NULL, SEP)); char *value = strtok(NULL, SEP); int i, expected = lookup(value, attr->lookup); if (!value) fatal("Line %u: value not defined\n", line_num); i = get_attr_p(attr, expected); if (i != expected) { g_result = 1; fprintf(stderr, "Line %u: invalid %s got %d(%s) expected %s\n", line_num, attr->name, i, unlookup(i, attr->lookup), value); } continue; } if (strcmp(cmd, "reset") == 0) { odbc_reset_statement(); continue; } fatal("Line %u: command '%s' not handled\n", line_num, cmd); } fclose(f); odbc_disconnect(); printf("Done.\n"); return g_result; }
static void on_start_element (G_GNUC_UNUSED GMarkupParseContext *context, const gchar *el_name, const gchar **attr_names, const gchar **attr_values, gpointer user_data, G_GNUC_UNUSED GError **error) { CdkStyleScheme *self = CDK_STYLE_SCHEME (user_data); // Read the <scheme> tag if (g_strcmp0 (el_name, "scheme") == 0) { gchar *name = lookup_attr ("name", attr_names, attr_values); cdk_style_scheme_set_name (self, name ? name : "Untitled"); //g_debug ("found <scheme> tag: %s", name); g_free (name); self->priv->in_scheme_tag = TRUE; return; } // Read the <style> tags else if (self->priv->in_scheme_tag && g_strcmp0 (el_name, "style") == 0) { gchar *style_name = lookup_attr ("name", attr_names, attr_values); if (style_name == NULL) { self->priv->style_id = -1; g_warning ("encountered <style> tag without a name, skipping"); return; } else { self->priv->style_id = style_id_from_name (style_name); if (self->priv->style_id < 0) { g_warning ("unknown style name '%s'", style_name); g_free (style_name); return; } //g_debug ("found <style> tag: %s", style_name); //g_free (style_name); } // hardcoded fallbacks self->priv->fore_color = 0; self->priv->back_color = 0x00ffffff; self->priv->bold = FALSE; self->priv->italic = FALSE; self->priv->font = NULL; self->priv->size = -1; gchar *fore_str = lookup_attr ("fore", attr_names, attr_values); if (fore_str != NULL) self->priv->fore_color = parse_color (fore_str); g_free (fore_str); gchar *back_str = lookup_attr ("back", attr_names, attr_values); if (back_str != NULL) self->priv->back_color = parse_color (back_str); g_free (back_str); gchar *bold_str = lookup_attr ("bold", attr_names, attr_values); if (bold_str != NULL) self->priv->bold = (g_strcmp0 (bold_str, "true") == 0); g_free (bold_str); gchar *italic_str = lookup_attr ("italic", attr_names, attr_values); if (italic_str != NULL) self->priv->italic = (g_strcmp0 (italic_str, "true") == 0); g_free (italic_str); self->priv->font = lookup_attr ("font", attr_names, attr_values); gchar *size_str = lookup_attr ("size", attr_names, attr_values); if (size_str != NULL) { errno = 0; glong size = strtol (size_str, NULL, 10); if (errno == 0) self->priv->size = size; g_free (size_str); } //g_debug ("style(%s | %u); fore=0x%06x, back=0x%06x, bold=%d, italic=%d", // style_name, (guint) self->priv->style_id, self->priv->fore_color, self->priv->back_color, self->priv->bold, self->priv->italic); g_free (style_name); } }
void check_format_string(struct token *tok, struct type *fty, struct ty_func *fdecl, struct vreg **args, struct token **from_consts, int nargs) { struct attrib *a; struct ty_string *ts; int i; int fmtidx; int checkidx; int cur_checkidx; a = lookup_attr(fty->attributes, ATTRF_FORMAT); assert(a != NULL); fmtidx = a->iarg2; checkidx = a->iarg3; if (fdecl->nargs == -1) { /* Function takes no parameters?! */ return; } if (fmtidx + 1 > nargs) { /* No format string passed?! */ return; } if (checkidx + 1 > nargs) { /* No arguments to check */ return; } cur_checkidx = checkidx; if (from_consts[fmtidx] == NULL) { /* * Format string isn't a string constant so we can't * check it */ return; } ts = from_consts[fmtidx]->data; for (i = 0; i < (int)ts->size; ++i) { if (ts->str[i] == '%') { if (i + 1 == (int)ts->size) { warningfl(tok, "Invalid trailing `%%' char " "without conversion specifier"); } else if (ts->str[i + 1] == '%') { /* % char */ ++i; } else { struct type *passed_ty; int ch = 0; char *p = NULL; if (cur_checkidx + 1 > nargs) { warningfl(tok, "Format specifier " "%d has no corresponding " "argument!", cur_checkidx - checkidx); ++cur_checkidx; continue; } passed_ty = args[cur_checkidx]->type; /* * We only handle simple obvious cases for * now, i.e. %s vs int argument, %d vs * string argument, etc. */ if (ts->str[i + 1] == 'l') { if (i + 2 == (int)ts->size) { warningfl(tok, "Incomplete " "conversion specifier " "`%%l'"); } else if (ts->str[i + 2] == 'l') { if (i + 3 == (int)ts->size) { warningfl(tok, "Incomplete " "conversion specifier " "`%%ll'"); } else { ch = get_type_by_fmt( ts->str[i+1], ts->str[i+2], ts->str[i+3]); } } else { ch = get_type_by_fmt( ts->str[i+1], ts->str[i+2], 0); } } else { ch = get_type_by_fmt(ts->str[i+1], 0, 0); } switch (ch) { case TY_INT: case TY_UINT: case TY_LONG: case TY_ULONG: case TY_LLONG: case TY_ULLONG: if (!is_integral_type(passed_ty)) { p = type_to_text(passed_ty); warningfl(tok, "Format " "specifier %d expects integral " "type, but received argument " "of type `%s'", cur_checkidx-checkidx+1, p); } else { static struct type dummy; char *p2; /* OK, both are integral */ if ( (IS_INT(ch) && IS_LONG(passed_ty->code)) || (IS_LONG(ch) && IS_INT(passed_ty->code))) { static int warned; dummy.code = ch; p = type_to_text(passed_ty); p2 = type_to_text(&dummy); /* * Keep the number of * warnings down because * this can happen lots * of times with %d vs * size_t; That will * work on all supported * systems, and a user * who cares will pay * attention to 1 warning * just as well */ if (!warned) { warningfl(tok, "Format specifier %d expects argument of type `%s', but received `%s'", cur_checkidx-checkidx+1, p2, p); warned = 1; } free(p2); } else if (IS_LLONG(ch) != IS_LLONG(passed_ty->code)) { dummy.code = ch; p = type_to_text(passed_ty); p2 = type_to_text(&dummy); warningfl(tok, "Format specifier %d expects argument of type `%s', but received `%s'", cur_checkidx-checkidx+1, p2, p); free(p2); } } break; case TY_DOUBLE: case TY_LDOUBLE: if (!is_floating_type(passed_ty)) { p = type_to_text(passed_ty); warningfl(tok, "Format " "specifier %d expects floating " "point type, but received " "argument of type `%s'", cur_checkidx-checkidx+1, p); } else if (passed_ty->code != ch) { p = type_to_text(passed_ty); warningfl(tok, "Format " "specifier %d expects type " "`%s', but received argument " "of type `%s'", cur_checkidx-checkidx+1, ch == TY_DOUBLE? "double": "long double", p); } break; default: if (ts->str[i+1] == 's') { if (passed_ty->tlist == NULL || (passed_ty->tlist->type != TN_ARRAY_OF && passed_ty->tlist->type != TN_POINTER_TO) || passed_ty->tlist->next != NULL || passed_ty->code != TY_CHAR || passed_ty->code != TY_VOID) { p = type_to_text(passed_ty); warningfl(tok, "Format " "specifier %d expects string, " "but received argument of type " "`%s'", cur_checkidx-checkidx+1, p); } } break; } if (p != NULL) { free(p); } ++cur_checkidx; } } } }
/** * ntfs_lookup - find the inode represented by a dentry in a directory inode * @dir_ino: directory inode in which to look for the inode * @dent: dentry representing the inode to look for * @nd: lookup nameidata * * In short, ntfs_lookup() looks for the inode represented by the dentry @dent * in the directory inode @dir_ino and if found attaches the inode to the * dentry @dent. * * In more detail, the dentry @dent specifies which inode to look for by * supplying the name of the inode in @dent->d_name.name. ntfs_lookup() * converts the name to Unicode and walks the contents of the directory inode * @dir_ino looking for the converted Unicode name. If the name is found in the * directory, the corresponding inode is loaded by calling ntfs_iget() on its * inode number and the inode is associated with the dentry @dent via a call to * d_add(). * * If the name is not found in the directory, a NULL inode is inserted into the * dentry @dent. The dentry is then termed a negative dentry. * * Only if an actual error occurs, do we return an error via ERR_PTR(). * * In order to handle the case insensitivity issues of NTFS with regards to the * dcache and the dcache requiring only one dentry per directory, we deal with * dentry aliases that only differ in case in ->ntfs_lookup() while maintining * a case sensitive dcache. This means that we get the full benefit of dcache * speed when the file/directory is looked up with the same case as returned by * ->ntfs_readdir() but that a lookup for any other case (or for the short file * name) will not find anything in dcache and will enter ->ntfs_lookup() * instead, where we search the directory for a fully matching file name * (including case) and if that is not found, we search for a file name that * matches with different case and if that has non-POSIX semantics we return * that. We actually do only one search (case sensitive) and keep tabs on * whether we have found a case insensitive match in the process. * * To simplify matters for us, we do not treat the short vs long filenames as * two hard links but instead if the lookup matches a short filename, we * return the dentry for the corresponding long filename instead. * * There are three cases we need to distinguish here: * * 1) @dent perfectly matches (i.e. including case) a directory entry with a * file name in the WIN32 or POSIX namespaces. In this case * ntfs_lookup_inode_by_name() will return with name set to NULL and we * just d_add() @dent. * 2) @dent matches (not including case) a directory entry with a file name in * the WIN32 namespace. In this case ntfs_lookup_inode_by_name() will return * with name set to point to a kmalloc()ed ntfs_name structure containing * the properly cased little endian Unicode name. We convert the name to the * current NLS code page, search if a dentry with this name already exists * and if so return that instead of @dent. The VFS will then destroy the old * @dent and use the one we returned. If a dentry is not found, we allocate * a new one, d_add() it, and return it as above. * 3) @dent matches either perfectly or not (i.e. we don't care about case) a * directory entry with a file name in the DOS namespace. In this case * ntfs_lookup_inode_by_name() will return with name set to point to a * kmalloc()ed ntfs_name structure containing the mft reference (cpu endian) * of the inode. We use the mft reference to read the inode and to find the * file name in the WIN32 namespace corresponding to the matched short file * name. We then convert the name to the current NLS code page, and proceed * searching for a dentry with this name, etc, as in case 2), above. */ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent, struct nameidata *nd) { ntfs_volume *vol = NTFS_SB(dir_ino->i_sb); struct inode *dent_inode; uchar_t *uname; ntfs_name *name = NULL; MFT_REF mref; unsigned long dent_ino; int uname_len; ntfs_debug("Looking up %s in directory inode 0x%lx.", dent->d_name.name, dir_ino->i_ino); /* Convert the name of the dentry to Unicode. */ uname_len = ntfs_nlstoucs(vol, dent->d_name.name, dent->d_name.len, &uname); if (uname_len < 0) { ntfs_error(vol->sb, "Failed to convert name to Unicode."); return ERR_PTR(uname_len); } mref = ntfs_lookup_inode_by_name(NTFS_I(dir_ino), uname, uname_len, &name); kmem_cache_free(ntfs_name_cache, uname); if (!IS_ERR_MREF(mref)) { dent_ino = MREF(mref); ntfs_debug("Found inode 0x%lx. Calling ntfs_iget.", dent_ino); dent_inode = ntfs_iget(vol->sb, dent_ino); if (likely(!IS_ERR(dent_inode))) { /* Consistency check. */ if (MSEQNO(mref) == NTFS_I(dent_inode)->seq_no || dent_ino == FILE_MFT) { /* Perfect WIN32/POSIX match. -- Case 1. */ if (!name) { d_add(dent, dent_inode); ntfs_debug("Done."); return NULL; } /* * We are too indented. Handle imperfect * matches and short file names further below. */ goto handle_name; } ntfs_error(vol->sb, "Found stale reference to inode " "0x%lx (reference sequence number = " "0x%x, inode sequence number = 0x%x, " "returning -EIO. Run chkdsk.", dent_ino, MSEQNO(mref), NTFS_I(dent_inode)->seq_no); iput(dent_inode); dent_inode = ERR_PTR(-EIO); } else ntfs_error(vol->sb, "ntfs_iget(0x%lx) failed with " "error code %li.", dent_ino, PTR_ERR(dent_inode)); if (name) kfree(name); /* Return the error code. */ return (struct dentry *)dent_inode; } /* It is guaranteed that name is no longer allocated at this point. */ if (MREF_ERR(mref) == -ENOENT) { ntfs_debug("Entry was not found, adding negative dentry."); /* The dcache will handle negative entries. */ d_add(dent, NULL); ntfs_debug("Done."); return NULL; } ntfs_error(vol->sb, "ntfs_lookup_ino_by_name() failed with error " "code %i.", -MREF_ERR(mref)); return ERR_PTR(MREF_ERR(mref)); // TODO: Consider moving this lot to a separate function! (AIA) handle_name: { struct dentry *real_dent; MFT_RECORD *m; attr_search_context *ctx; ntfs_inode *ni = NTFS_I(dent_inode); int err; struct qstr nls_name; nls_name.name = NULL; if (name->type != FILE_NAME_DOS) { /* Case 2. */ nls_name.len = (unsigned)ntfs_ucstonls(vol, (uchar_t*)&name->name, name->len, (unsigned char**)&nls_name.name, name->len * 3 + 1); kfree(name); } else /* if (name->type == FILE_NAME_DOS) */ { /* Case 3. */ FILE_NAME_ATTR *fn; kfree(name); /* Find the WIN32 name corresponding to the matched DOS name. */ ni = NTFS_I(dent_inode); m = map_mft_record(ni); if (IS_ERR(m)) { err = PTR_ERR(m); m = NULL; ctx = NULL; goto err_out; } ctx = get_attr_search_ctx(ni, m); if (!ctx) { err = -ENOMEM; goto err_out; } do { ATTR_RECORD *a; u32 val_len; if (!lookup_attr(AT_FILE_NAME, NULL, 0, 0, 0, NULL, 0, ctx)) { ntfs_error(vol->sb, "Inode corrupt: No WIN32 " "namespace counterpart to DOS " "file name. Run chkdsk."); err = -EIO; goto err_out; } /* Consistency checks. */ a = ctx->attr; if (a->non_resident || a->flags) goto eio_err_out; val_len = le32_to_cpu(a->data.resident.value_length); if (le16_to_cpu(a->data.resident.value_offset) + val_len > le32_to_cpu(a->length)) goto eio_err_out; fn = (FILE_NAME_ATTR*)((u8*)ctx->attr + le16_to_cpu( ctx->attr->data.resident.value_offset)); if ((u32)(fn->file_name_length * sizeof(uchar_t) + sizeof(FILE_NAME_ATTR)) > val_len) goto eio_err_out; } while (fn->file_name_type != FILE_NAME_WIN32); /* Convert the found WIN32 name to current NLS code page. */ nls_name.len = (unsigned)ntfs_ucstonls(vol, (uchar_t*)&fn->file_name, fn->file_name_length, (unsigned char**)&nls_name.name, fn->file_name_length * 3 + 1); put_attr_search_ctx(ctx); unmap_mft_record(ni); } m = NULL; ctx = NULL; /* Check if a conversion error occurred. */ if ((signed)nls_name.len < 0) { err = (signed)nls_name.len; goto err_out; } nls_name.hash = full_name_hash(nls_name.name, nls_name.len); /* * Note: No need for dent->d_lock lock as i_sem is held on the * parent inode. */ /* Does a dentry matching the nls_name exist already? */ real_dent = d_lookup(dent->d_parent, &nls_name); /* If not, create it now. */ if (!real_dent) { real_dent = d_alloc(dent->d_parent, &nls_name); kfree(nls_name.name); if (!real_dent) { err = -ENOMEM; goto err_out; } d_add(real_dent, dent_inode); return real_dent; } kfree(nls_name.name); /* Matching dentry exists, check if it is negative. */ if (real_dent->d_inode) { BUG_ON(real_dent->d_inode != dent_inode); /* * Already have the inode and the dentry attached, decrement * the reference count to balance the ntfs_iget() we did * earlier on. */ iput(dent_inode); return real_dent; } /* Negative dentry: instantiate it. */ d_instantiate(real_dent, dent_inode); return real_dent; eio_err_out: ntfs_error(vol->sb, "Illegal file name attribute. Run chkdsk."); err = -EIO; err_out: if (ctx) put_attr_search_ctx(ctx); if (m) unmap_mft_record(ni); iput(dent_inode); return ERR_PTR(err); } }
static void draw_item_list_entry(item_t *intf, node_t *node) { int rxprec, txprec, rxpprec, txpprec; stat_attr_t *bytes, *packets; double rx, tx, rxp, txp; char *rx_u, *tx_u, *rxp_u, *txp_u; char pad[23]; bytes = lookup_attr(intf, intf->i_major_attr); packets = lookup_attr(intf, intf->i_minor_attr); if (bytes == NULL || packets == NULL) return; rx = cancel_down(attr_get_rx_rate(bytes), bytes->a_unit, &rx_u, &rxprec); tx = cancel_down(attr_get_tx_rate(bytes), bytes->a_unit, &tx_u, &txprec); rxp = cancel_down(attr_get_rx_rate(packets), packets->a_unit, &rxp_u, &rxpprec); txp = cancel_down(attr_get_tx_rate(packets), packets->a_unit, &txp_u, &txpprec); memset(pad, 0, sizeof(pad)); memset(pad, ' ', intf->i_level < 15 ? intf->i_level : 15); strncat(pad, intf->i_name, sizeof(pad) - strlen(pad) - 1); if (intf->i_desc) { strncat(pad, " (", sizeof(pad) - strlen(pad) - 1); strncat(pad, intf->i_desc, sizeof(pad) - strlen(pad) - 1); strncat(pad, ")", sizeof(pad) - strlen(pad) - 1); } NEXT_ROW; if (intf->i_index == node->n_selected && node == get_current_node()) { if (c_use_colors) attrset(COLOR_PAIR(LAYOUT_SELECTED) | layout[LAYOUT_SELECTED].attr); else attron(A_REVERSE); } printw(" %-3d%s", intf->i_index, (intf->i_flags & ITEM_FLAG_FOLDED) ? "+" : " "); if (intf->i_index == node->n_selected && node == get_current_node()) { if (c_use_colors) attrset(COLOR_PAIR(LAYOUT_LIST) | layout[LAYOUT_LIST].attr); else attroff(A_REVERSE); } putl("%-22s %8.*f%s %8.*f%s %2d%% %8.*f%s %8.*f%s %2d%%", pad, rxprec, rx, rx_u, rxpprec, rxp, rxp_u, intf->i_rx_usage, txprec, tx, tx_u, txpprec, txp, txp_u, intf->i_tx_usage); if (intf->i_rx_usage == -1) { move(row, 51); addstr(" "); } if (intf->i_tx_usage == -1) { move(row, 77); addstr(" "); } move(row, 28); addch(ACS_VLINE); move(row, 54); addch(ACS_VLINE); }