Reset errno to previous value when it does not mean an error
parent
94d299b848
commit
08537782ce
|
@ -155,6 +155,7 @@ ntfs_inode *ntfs_inode_open(ntfs_volume *vol, const MFT_REF mref)
|
|||
ntfs_inode *ni = NULL;
|
||||
ntfs_attr_search_ctx *ctx;
|
||||
STANDARD_INFORMATION *std_info;
|
||||
int olderrno;
|
||||
|
||||
ntfs_log_enter("Entering for inode %lld\n", MREF(mref));
|
||||
if (!vol) {
|
||||
|
@ -202,11 +203,14 @@ ntfs_inode *ntfs_inode_open(ntfs_volume *vol, const MFT_REF mref)
|
|||
ni->security_id = 0;
|
||||
}
|
||||
/* Set attribute list information. */
|
||||
olderrno = errno;
|
||||
if (ntfs_attr_lookup(AT_ATTRIBUTE_LIST, AT_UNNAMED, 0, 0, 0, NULL, 0,
|
||||
ctx)) {
|
||||
if (errno != ENOENT)
|
||||
goto put_err_out;
|
||||
/* Attribute list attribute does not present. */
|
||||
/* restore previous errno to avoid misinterpretation */
|
||||
errno = olderrno;
|
||||
goto get_size;
|
||||
}
|
||||
NInoSetAttrList(ni);
|
||||
|
@ -229,10 +233,13 @@ ntfs_inode *ntfs_inode_open(ntfs_volume *vol, const MFT_REF mref)
|
|||
goto put_err_out;
|
||||
}
|
||||
get_size:
|
||||
olderrno = errno;
|
||||
if (ntfs_attr_lookup(AT_DATA, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
|
||||
if (errno != ENOENT)
|
||||
goto put_err_out;
|
||||
/* Directory or special file. */
|
||||
/* restore previous errno to avoid misinterpretation */
|
||||
errno = olderrno;
|
||||
ni->data_size = ni->allocated_size = 0;
|
||||
} else {
|
||||
if (ctx->attr->non_resident) {
|
||||
|
|
|
@ -697,6 +697,7 @@ static le32 entersecurityattr(ntfs_volume *vol,
|
|||
INDEX_ENTRY *next;
|
||||
ntfs_index_context *xsii;
|
||||
ntfs_attr *na;
|
||||
int olderrno;
|
||||
|
||||
/* find the first available securid beyond the last key */
|
||||
/* in $Secure:$SII. This also determines the first */
|
||||
|
@ -709,12 +710,15 @@ static le32 entersecurityattr(ntfs_volume *vol,
|
|||
ntfs_index_ctx_reinit(xsii);
|
||||
offs = size = 0;
|
||||
keyid = const_cpu_to_le32(-1);
|
||||
olderrno = errno;
|
||||
found = !ntfs_index_lookup((char*)&keyid,
|
||||
sizeof(SII_INDEX_KEY), xsii);
|
||||
if (!found && (errno != ENOENT)) {
|
||||
ntfs_log_perror("Inconsistency in index $SII");
|
||||
psii = (struct SII*)NULL;
|
||||
} else {
|
||||
/* restore errno to avoid misinterpretation */
|
||||
errno = olderrno;
|
||||
entry = xsii->entry;
|
||||
psii = (struct SII*)xsii->entry;
|
||||
}
|
||||
|
@ -858,6 +862,7 @@ static le32 setsecurityattr(ntfs_volume *vol,
|
|||
INDEX_ENTRY *entry;
|
||||
le32 securid;
|
||||
le32 hash;
|
||||
int olderrno;
|
||||
|
||||
hash = ntfs_security_hash(attr,attrsz);
|
||||
oldattr = (char*)NULL;
|
||||
|
@ -874,11 +879,14 @@ static le32 setsecurityattr(ntfs_volume *vol,
|
|||
*/
|
||||
key.hash = hash;
|
||||
key.security_id = const_cpu_to_le32(0);
|
||||
olderrno = errno;
|
||||
found = !ntfs_index_lookup((char*)&key,
|
||||
sizeof(SDH_INDEX_KEY), xsdh);
|
||||
if (!found && (errno != ENOENT))
|
||||
ntfs_log_perror("Inconsistency in index $SDH");
|
||||
else {
|
||||
/* restore errno to avoid misinterpretation */
|
||||
errno = olderrno;
|
||||
entry = xsdh->entry;
|
||||
found = FALSE;
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue