AssetLoadState OgreMeshAsset::DeserializeFromData(const u8 *data_, size_t numBytes) { PROFILE(OgreMeshAsset_LoadFromFileInMemory); assert(data_); if (!data_) return ASSET_LOAD_FAILED; // Force an unload of this data first. Unload(); if (OGRE_THREAD_SUPPORT != 0) { // We can only do threaded loading from disk, and not any disk location but only from asset cache. // local:// refs will return empty string here and those will fall back to the non-threaded loading. // Do not change this to do DiskCache() as that directory for local:// refs will not be a known resource location for ogre. QString cacheDiskSource = assetAPI->GetAssetCache()->GetDiskSource(QUrl(Name())); if (!cacheDiskSource.isEmpty()) { QFileInfo fileInfo(cacheDiskSource); std::string sanitatedAssetRef = fileInfo.fileName().toStdString(); loadTicket_ = Ogre::ResourceBackgroundQueue::getSingleton().load(Ogre::MeshManager::getSingleton().getResourceType(), sanitatedAssetRef, OgreRenderer::OgreRenderingModule::CACHE_RESOURCE_GROUP, false, 0, 0, this); return ASSET_LOAD_PROCESSING; } } if (ogreMesh.isNull()) { ogreMesh = Ogre::MeshManager::getSingleton().createManual( OgreRenderer::SanitateAssetIdForOgre(this->Name().toStdString()), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); if (ogreMesh.isNull()) { LogError("Failed to create mesh " + Name().toStdString()); return ASSET_LOAD_FAILED; } ogreMesh->setAutoBuildEdgeLists(false); } std::vector<u8> tempData(data_, data_ + numBytes); #include "DisableMemoryLeakCheck.h" Ogre::DataStreamPtr stream(new Ogre::MemoryDataStream((void*)&tempData[0], numBytes, false)); #include "EnableMemoryLeakCheck.h" Ogre::MeshSerializer serializer; serializer.importMesh(stream, ogreMesh.getPointer()); // Note: importMesh *adds* submeshes to an existing mesh. It doesn't replace old ones. // Generate tangents to mesh try { unsigned short src, dest; ///\bug Crashes if called for a mesh that has null or zero vertices in the vertex buffer, or null or zero indices in the index buffer. if (!ogreMesh->suggestTangentVectorBuildParams(Ogre::VES_TANGENT, src, dest)) ogreMesh->buildTangentVectors(Ogre::VES_TANGENT, src, dest); } catch (...) {} // Generate extremity points to submeshes, 1 should be enough try { for(uint i = 0; i < ogreMesh->getNumSubMeshes(); ++i) { Ogre::SubMesh *smesh = ogreMesh->getSubMesh(i); if (smesh) smesh->generateExtremes(1); } } catch (...) {} try { // Assign default materials that won't complain SetDefaultMaterial(); // Set asset references the mesh has //ResetReferences(); } catch (Ogre::Exception &e) { LogError("Failed to create mesh " + this->Name().toStdString() + ": " + std::string(e.what())); Unload(); return ASSET_LOAD_FAILED; } //internal_name_ = SanitateAssetIdForOgre(id_); LogDebug("Ogre mesh " + this->Name().toStdString() + " created"); return ASSET_LOAD_SUCCESFULL; }
static bool Remove_Client( int Type, CHANNEL *Chan, CLIENT *Client, CLIENT *Origin, const char *Reason, bool InformServer ) { CL2CHAN *cl2chan, *last_cl2chan; CHANNEL *c; assert( Chan != NULL ); assert( Client != NULL ); assert( Origin != NULL ); assert( Reason != NULL ); /* Do not inform other servers if the channel is local to this server, * regardless of what the caller requested! */ if(InformServer) InformServer = !Channel_IsLocal(Chan); last_cl2chan = NULL; cl2chan = My_Cl2Chan; while( cl2chan ) { if(( cl2chan->channel == Chan ) && ( cl2chan->client == Client )) break; last_cl2chan = cl2chan; cl2chan = cl2chan->next; } if( ! cl2chan ) return false; c = cl2chan->channel; assert( c != NULL ); /* maintain cl2chan list */ if( last_cl2chan ) last_cl2chan->next = cl2chan->next; else My_Cl2Chan = cl2chan->next; free( cl2chan ); switch( Type ) { case REMOVE_QUIT: /* QUIT: other servers have already been notified, * see Client_Destroy(); so only inform other clients * in same channel. */ assert( InformServer == false ); LogDebug("User \"%s\" left channel \"%s\" (%s).", Client_Mask( Client ), c->name, Reason ); break; case REMOVE_KICK: /* User was KICKed: inform other servers (public * channels) and all users in the channel */ if( InformServer ) IRC_WriteStrServersPrefix( Client_NextHop( Origin ), Origin, "KICK %s %s :%s", c->name, Client_ID( Client ), Reason); IRC_WriteStrChannelPrefix(Client, c, Origin, false, "KICK %s %s :%s", c->name, Client_ID( Client ), Reason ); if ((Client_Conn(Client) > NONE) && (Client_Type(Client) == CLIENT_USER)) { IRC_WriteStrClientPrefix(Client, Origin, "KICK %s %s :%s", c->name, Client_ID( Client ), Reason); } LogDebug("User \"%s\" has been kicked off \"%s\" by \"%s\": %s.", Client_Mask( Client ), c->name, Client_ID(Origin), Reason); break; default: /* PART */ if (Conf_MorePrivacy) Reason = ""; if (InformServer) IRC_WriteStrServersPrefix(Origin, Client, "PART %s :%s", c->name, Reason); IRC_WriteStrChannelPrefix(Origin, c, Client, false, "PART %s :%s", c->name, Reason); if ((Client_Conn(Origin) > NONE) && (Client_Type(Origin) == CLIENT_USER)) { IRC_WriteStrClientPrefix( Origin, Client, "PART %s :%s", c->name, Reason); LogDebug("User \"%s\" left channel \"%s\" (%s).", Client_Mask(Client), c->name, Reason); } } /* When channel is empty and is not pre-defined, delete */ if( ! Channel_HasMode( Chan, 'P' )) { if( ! Get_First_Cl2Chan( NULL, Chan )) Delete_Channel( Chan ); } return true; } /* Remove_Client */
int _9p_setattr( _9p_request_data_t * preq9p, void * pworker_data, u32 * plenout, char * preply) { char * cursor = preq9p->_9pmsg + _9P_HDR_SIZE + _9P_TYPE_SIZE ; nfs_worker_data_t * pwkrdata = (nfs_worker_data_t *)pworker_data ; u16 * msgtag = NULL ; u32 * fid = NULL ; u32 * valid = NULL ; u32 * mode = NULL ; u32 * uid = NULL ; u32 * gid = NULL ; u64 * size = NULL ; u64 * atime_sec = NULL ; u64 * atime_nsec = NULL ; u64 * mtime_sec = NULL ; u64 * mtime_nsec = NULL ; _9p_fid_t * pfid = NULL ; fsal_attrib_list_t fsalattr ; cache_inode_status_t cache_status ; struct timeval t; int rc = 0 ; int err = 0 ; if ( !preq9p || !pworker_data || !plenout || !preply ) return -1 ; /* Get data */ _9p_getptr( cursor, msgtag, u16 ) ; _9p_getptr( cursor, fid, u32 ) ; _9p_getptr( cursor, valid, u32 ) ; _9p_getptr( cursor, mode, u32 ) ; _9p_getptr( cursor, uid, u32 ) ; _9p_getptr( cursor, gid, u32 ) ; _9p_getptr( cursor, size, u64 ) ; _9p_getptr( cursor, atime_sec, u64 ) ; _9p_getptr( cursor, atime_nsec, u64 ) ; _9p_getptr( cursor, mtime_sec, u64 ) ; _9p_getptr( cursor, mtime_nsec, u64 ) ; LogDebug( COMPONENT_9P, "TSETATTR: tag=%u fid=%u mode=0%o uid=%u gid=%u size=%llu atime=(%llu|%llu) mtime=(%llu|%llu)", (u32)*msgtag, *fid, *mode, *uid, *gid, *size, (unsigned long long)*atime_sec, (unsigned long long)*atime_nsec, (unsigned long long)*mtime_sec, (unsigned long long)*mtime_nsec ) ; if( *fid >= _9P_FID_PER_CONN ) { err = ERANGE ; rc = _9p_rerror( preq9p, msgtag, &err, plenout, preply ) ; return rc ; } pfid = &preq9p->pconn->fids[*fid] ; /* If a "time" change is required, but not with the "_set" suffix, use gettimeofday */ if( *valid & (_9P_SETATTR_ATIME|_9P_SETATTR_CTIME|_9P_SETATTR_MTIME) ) { if( gettimeofday( &t, NULL ) == -1 ) { LogMajor( COMPONENT_9P, "TSETATTR: tag=%u fid=%u ERROR !! gettimeofday returned -1 with errno=%u", (u32)*msgtag, *fid, errno ) ; err = errno ; rc = _9p_rerror( preq9p, msgtag, &err, plenout, preply ) ; return rc ; } } /* Let's do the job */ memset( (char *)&fsalattr, 0, sizeof( fsalattr ) ) ; if( *valid & _9P_SETATTR_MODE ) { fsalattr.asked_attributes |= FSAL_ATTR_MODE ; fsalattr.mode = *mode ; } if( *valid & _9P_SETATTR_UID ) { fsalattr.asked_attributes |= FSAL_ATTR_OWNER ; fsalattr.owner = *uid ; } if( *valid & _9P_SETATTR_GID ) { fsalattr.asked_attributes |= FSAL_ATTR_GROUP ; fsalattr.group = *gid ; } if( *valid & _9P_SETATTR_SIZE ) { fsalattr.asked_attributes |= FSAL_ATTR_SIZE ; fsalattr.filesize = *size ; } if( *valid & _9P_SETATTR_ATIME ) { fsalattr.asked_attributes |= FSAL_ATTR_ATIME ; fsalattr.atime.seconds = t.tv_sec ; fsalattr.atime.nseconds = t.tv_usec * 1000 ; } if( *valid & _9P_SETATTR_MTIME ) { fsalattr.asked_attributes |= FSAL_ATTR_MTIME ; fsalattr.mtime.seconds = t.tv_sec ; fsalattr.mtime.nseconds = t.tv_usec * 1000 ; } if( *valid & _9P_SETATTR_CTIME ) { fsalattr.asked_attributes |= FSAL_ATTR_CTIME ; fsalattr.ctime.seconds = t.tv_sec ; fsalattr.ctime.nseconds = t.tv_usec * 1000 ; } if( *valid & _9P_SETATTR_ATIME_SET ) { fsalattr.asked_attributes |= FSAL_ATTR_ATIME ; fsalattr.atime.seconds = *atime_sec ; fsalattr.atime.nseconds = *atime_nsec ; } if( *valid & _9P_SETATTR_MTIME_SET ) { fsalattr.asked_attributes |= FSAL_ATTR_MTIME ; fsalattr.mtime.seconds = *mtime_sec ; fsalattr.mtime.nseconds = *mtime_nsec ; } /* Now set the attr */ if( cache_inode_setattr( pfid->pentry, &fsalattr, pwkrdata->ht, &pwkrdata->cache_inode_client, &pfid->fsal_op_context, &cache_status ) != CACHE_INODE_SUCCESS ) { err = _9p_tools_errno( cache_status ) ; ; rc = _9p_rerror( preq9p, msgtag, &err, plenout, preply ) ; return rc ; } /* Build the reply */ _9p_setinitptr( cursor, preply, _9P_RSETATTR ) ; _9p_setptr( cursor, msgtag, u16 ) ; _9p_setendptr( cursor, preply ) ; _9p_checkbound( cursor, preply, plenout ) ; return 1 ; }
void CDeMultiplexer::FillAudio(CTsHeader& header, byte* tsPacket) { //LogDebug("FillAudio - audio PID %d", m_audioPid ); if (m_iAudioStream < 0 || m_iAudioStream >= m_audioStreams.size()) return; m_audioPid = m_audioStreams[m_iAudioStream].pid; if (m_audioPid == 0 || m_audioPid != header.Pid) return; if (header.AdaptionFieldOnly()) return; bool packetProcessed = false; CAutoLock lock (&m_sectionAudio); if (header.PayloadUnitStart) { byte* p = tsPacket + header.PayLoadStart; if ((p[0] == 0) && (p[1] == 0) && (p[2] == 1)) { CPcr pts; CPcr dts; if (m_pCurrentAudioBuffer) { delete m_pCurrentAudioBuffer; m_pCurrentAudioBuffer = NULL; } m_pCurrentAudioBuffer = new Packet(); if (CPcr::DecodeFromPesHeader(p, 0, pts, dts)) { #ifdef LOG_DEMUXER_AUDIO_SAMPLES LogDebug("demux: aud pts: %6.3f clip: %d playlist: %d", pts.ToClock(), m_nClip, m_nPlaylist); #endif m_bAC3Substream = false; m_pCurrentAudioBuffer->rtStart = pts.IsValid ? CONVERT_90KHz_DS(pts.PcrReferenceBase) : Packet::INVALID_TIME; WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_audioParser->pmt.pbFormat; if (wfe) { REFERENCE_TIME duration = (wfe->nBlockAlign * 10000000) / wfe->nAvgBytesPerSec; m_pCurrentAudioBuffer->rtStop = m_pCurrentAudioBuffer->rtStart + duration; } else m_pCurrentAudioBuffer->rtStop = m_pCurrentAudioBuffer->rtStart + 1; m_pCurrentAudioBuffer->nClipNumber = m_nClip; m_pCurrentAudioBuffer->nPlaylist = m_nPlaylist; m_pCurrentAudioBuffer->rtTitleDuration = m_rtTitleDuration; UINT32 pesHeaderLen = p[8] + 9; m_nAudioPesLenght = (p[4] << 8) + p[5] - (pesHeaderLen - 6); unsigned int flags = p[7]; const BYTE* pos = p + 9; if ((flags & 0xc0) == 0x80) pos += 5; // PTS else if ((flags & 0xc0) == 0xc0) pos += 10; // PTS & DTS if (flags & 0x01) // PES extension { unsigned int pes_ext = *pos++; // Skip PES private data, program packet sequence counter and P-STD buffer unsigned int skip = (pes_ext >> 4) & 0xb; skip += skip & 0x9; pos += skip; if ((pes_ext & 0x41) == 0x01 && (pos + 2) <= (p + pesHeaderLen)) { // PES extension 2 if ((pos[0] & 0x7f) > 0 && (pos[1] & 0x80) == 0) { if (pos[1] == 0x76) m_bAC3Substream = true; // this stream will get discarded } } }
static int file_attributes_to_xattr_attrs(fsal_attrib_list_t * file_attrs, fsal_attrib_list_t * p_xattr_attrs, unsigned int attr_index) { /* supported attributes are: * - owner (same as the objet) * - group (same as the objet) * - type FSAL_TYPE_XATTR * - fileid (attr index ? or (fileid^((index+1)<<24)) ) * - mode (config & file) * - atime, mtime, ctime = these of the object ? * - size=1block, used=1block * - rdev=0 * - nlink=1 */ fsal_attrib_mask_t supported = FSAL_ATTR_SUPPATTR | FSAL_ATTR_MODE | FSAL_ATTR_FILEID | FSAL_ATTR_TYPE | FSAL_ATTR_OWNER | FSAL_ATTR_GROUP | FSAL_ATTR_ATIME | FSAL_ATTR_MTIME | FSAL_ATTR_CTIME | FSAL_ATTR_CREATION | FSAL_ATTR_CHGTIME | FSAL_ATTR_SIZE | FSAL_ATTR_SPACEUSED | FSAL_ATTR_NUMLINKS | FSAL_ATTR_RAWDEV | FSAL_ATTR_FSID; fsal_attrib_mask_t unsupp; /* only those supported by filesystem */ supported &= global_fs_info.supported_attrs; if(p_xattr_attrs->asked_attributes == 0) { p_xattr_attrs->asked_attributes = supported; LogCrit(COMPONENT_FSAL, "Error: p_xattr_attrs->asked_attributes was 0 in %s() line %d, file %s", __FUNCTION__, __LINE__, __FILE__); } unsupp = p_xattr_attrs->asked_attributes & (~supported); if(unsupp) { LogDebug(COMPONENT_FSAL, "Asking for unsupported attributes in %s(): %#llX removing it from asked attributes", __FUNCTION__, unsupp); p_xattr_attrs->asked_attributes &= (~unsupp); } if(p_xattr_attrs->asked_attributes & FSAL_ATTR_SUPPATTR) p_xattr_attrs->supported_attributes = supported; if(p_xattr_attrs->asked_attributes & FSAL_ATTR_MODE) { p_xattr_attrs->mode = file_attrs->mode & global_fs_info.xattr_access_rights; if(xattr_list[attr_index].flags & XATTR_RO) p_xattr_attrs->mode &= ~(0222); } if(p_xattr_attrs->asked_attributes & FSAL_ATTR_FILEID) { unsigned int i; unsigned long hash = attr_index + 1; char *str = (char *)&file_attrs->fileid; for(i = 0; i < sizeof(p_xattr_attrs->fileid); i++, str++) { hash = (hash << 5) - hash + (unsigned long)(*str); } p_xattr_attrs->fileid = hash; } if(p_xattr_attrs->asked_attributes & FSAL_ATTR_TYPE) p_xattr_attrs->type = FSAL_TYPE_XATTR; if(p_xattr_attrs->asked_attributes & FSAL_ATTR_OWNER) p_xattr_attrs->owner = file_attrs->owner; if(p_xattr_attrs->asked_attributes & FSAL_ATTR_GROUP) p_xattr_attrs->group = file_attrs->group; if(p_xattr_attrs->asked_attributes & FSAL_ATTR_ATIME) p_xattr_attrs->atime = file_attrs->atime; if(p_xattr_attrs->asked_attributes & FSAL_ATTR_MTIME) p_xattr_attrs->mtime = file_attrs->mtime; if(p_xattr_attrs->asked_attributes & FSAL_ATTR_CTIME) p_xattr_attrs->ctime = file_attrs->ctime; if(p_xattr_attrs->asked_attributes & FSAL_ATTR_CREATION) p_xattr_attrs->creation = file_attrs->creation; if(p_xattr_attrs->asked_attributes & FSAL_ATTR_CHGTIME) p_xattr_attrs->chgtime = file_attrs->chgtime; if(p_xattr_attrs->asked_attributes & FSAL_ATTR_SIZE) p_xattr_attrs->filesize = DEV_BSIZE; if(p_xattr_attrs->asked_attributes & FSAL_ATTR_SPACEUSED) p_xattr_attrs->spaceused = DEV_BSIZE; if(p_xattr_attrs->asked_attributes & FSAL_ATTR_NUMLINKS) p_xattr_attrs->numlinks = 1; if(p_xattr_attrs->asked_attributes & FSAL_ATTR_RAWDEV) { p_xattr_attrs->rawdev.major = 0; p_xattr_attrs->rawdev.minor = 0; } if(p_xattr_attrs->asked_attributes & FSAL_ATTR_FSID) { p_xattr_attrs->fsid = file_attrs->fsid; } /* if mode==0, then owner is set to root and mode is set to 0600 */ if((p_xattr_attrs->asked_attributes & FSAL_ATTR_OWNER) && (p_xattr_attrs->asked_attributes & FSAL_ATTR_MODE) && (p_xattr_attrs->mode == 0)) { p_xattr_attrs->owner = 0; p_xattr_attrs->mode = 0600; if(xattr_list[attr_index].flags & XATTR_RO) p_xattr_attrs->mode &= ~(0200); } return 0; }
/* * Duplicate xprt from original to copy. */ SVCXPRT *Svcxprt_copy(SVCXPRT *xprt_copy, SVCXPRT *xprt_orig) { if(xprt_copy) FreeXprt(xprt_copy); xprt_copy = (SVCXPRT *) Mem_Alloc(sizeof(SVCXPRT)); if(xprt_copy == NULL) goto fail_no_xprt; LogFullDebug(COMPONENT_RPC, "Svcxprt_copy copying xprt_orig=%p to xprt_copy=%p", xprt_orig, xprt_copy); memcpy(xprt_copy, xprt_orig, sizeof(SVCXPRT)); xprt_copy->xp_p1 = NULL; xprt_copy->xp_p2 = NULL; if(xprt_orig->xp_ops == &Svcudp_op) { if(Su_data(xprt_orig)) { struct Svcudp_data *su_o = Su_data(xprt_orig), *su_c; su_c = (struct Svcudp_data *) Mem_Alloc(sizeof(*su_c)); if(!su_c) goto fail; Su_data_set(xprt_copy) = (void *) su_c; memcpy(su_c, su_o, sizeof(*su_c)); rpc_buffer(xprt_copy) = Mem_Alloc_Label(su_c->su_iosz, "UDP IO Buffer"); if(!rpc_buffer(xprt_copy)) goto fail; xdrmem_create(&(su_c->su_xdrs), rpc_buffer(xprt_copy), su_c->su_iosz, XDR_DECODE); if(xprt_orig->xp_verf.oa_base == su_o->su_verfbody) xprt_copy->xp_verf.oa_base = su_c->su_verfbody; else xprt_copy->xp_verf.oa_base = xprt_orig->xp_verf.oa_base; xprt_copy->xp_verf.oa_flavor = xprt_orig->xp_verf.oa_flavor; xprt_copy->xp_verf.oa_length = xprt_orig->xp_verf.oa_length; } else goto fail; } else if (xprt_orig->xp_ops == &Svctcp_op) { struct tcp_conn *cd_o = (struct tcp_conn *)xprt_orig->xp_p1, *cd_c; cd_c = (struct tcp_conn *) Mem_Alloc(sizeof(*cd_c)); if(!cd_c) goto fail; memcpy(cd_c, cd_o, sizeof(*cd_c)); xprt_copy->xp_p1 = (void *) cd_c; xdrrec_create(&(cd_c->xdrs), 32768, 32768, (caddr_t) xprt_copy, Readtcp, Writetcp); if(xprt_orig->xp_verf.oa_base == cd_o->verf_body) xprt_copy->xp_verf.oa_base = cd_c->verf_body; else xprt_copy->xp_verf.oa_base = xprt_orig->xp_verf.oa_base; xprt_copy->xp_verf.oa_flavor = xprt_orig->xp_verf.oa_flavor; xprt_copy->xp_verf.oa_length = xprt_orig->xp_verf.oa_length; } else if (xprt_orig->xp_ops == &Svctcp_rendezvous_op) { goto fail; } else { LogDebug(COMPONENT_RPC, "Attempt to copy unknown xprt %p", xprt_orig); Mem_Free(xprt_copy); goto fail_no_xprt; } return xprt_copy; fail: FreeXprt(xprt_copy); fail_no_xprt: /* Let caller know about failure */ LogCrit(COMPONENT_RPC, "Failed to copy xprt"); svcerr_systemerr(xprt_orig); return NULL; }
//FIXME: this older code version is only for backward compatibility with dependent classes. // proper fix is to change code of all classes that depend on PidInfo2 in favour of CPidTable! bool CPmtParser::DecodePmt(CSection sections, int& pcr_pid, bool& hasCaDescriptor, vector<PidInfo2>& pidInfos) { byte* section=sections.Data; int sectionLen=sections.section_length; int table_id = sections.table_id; if (table_id!=2) return false; if (m_serviceId!=-1) if (sections.table_id_extension!=m_serviceId) return false; int section_syntax_indicator = (section[1]>>7) & 1; int section_length = ((section[1]& 0xF)<<8) + section[2]; int program_number = (section[3]<<8)+section[4]; int version_number = ((section[5]>>1)&0x1F); int current_next_indicator = section[5] & 1; int section_number = section[6]; int last_section_number = section[7]; pcr_pid=((section[8]& 0x1F)<<8)+section[9]; int program_info_length = ((section[10] & 0xF)<<8)+section[11]; int len2 = program_info_length; int pointer = 12; int len1 = section_length -( 9 + program_info_length +4); int x; // loop 1 while (len2 > 0) { int indicator=section[pointer]; if (indicator == 0x9) // MPEG CA descriptor, implying the service is scrambled { hasCaDescriptor = true; } int descriptorLen=section[pointer+1]; len2 -= (descriptorLen+2); pointer += (descriptorLen+2); } // loop 2 int stream_type=0; int elementary_PID=0; int ES_info_length=0; int audioToSet=0; int subtitleToSet=0; pidInfos.clear(); while (len1 > 0) { //if (start+pointer+4>=sectionLen+9) return ; int curSubtitle=-1; stream_type = section[pointer]; elementary_PID = ((section[pointer+1]&0x1F)<<8)+section[pointer+2]; ES_info_length = ((section[pointer+3] & 0xF)<<8)+section[pointer+4]; if (pointer+ES_info_length>=sectionLen) { LogDebug("pmt parser check 1"); return false; } PidInfo2 pidInfo2; pidInfo2.fakePid=-1; pidInfo2.elementaryPid=elementary_PID; pidInfo2.streamType=stream_type; pidInfo2.rawDescriptorSize=ES_info_length; if (pidInfo2.streamType!=SERVICE_TYPE_DVB_SUBTITLES2) pidInfo2.logicalStreamType=stream_type; //ITV HD workaround if (pidInfo2.streamType==SERVICE_TYPE_DVB_SUBTITLES2 && program_number==10510) { if (pidInfo2.logicalStreamType==0xffffffff && pidInfo2.elementaryPid==0xd49) { pidInfo2.streamType=SERVICE_TYPE_VIDEO_H264; pidInfo2.logicalStreamType=SERVICE_TYPE_VIDEO_H264; LogDebug("DecodePmt: set ITV HD video stream to H.264"); } } //end of workaround // Boundary check if(ES_info_length > sizeof(pidInfo2.rawDescriptorData)) { LogDebug("pmt parser check 3"); return false; } if (pidInfo2.streamType==SERVICE_TYPE_DVB_SUBTITLES2) pidInfo2.logicalStreamType=-1; memset(pidInfo2.rawDescriptorData,0xFF,ES_info_length); memcpy(pidInfo2.rawDescriptorData,§ion[pointer+5],ES_info_length); pointer += 5; len1 -= 5; len2 = ES_info_length; while (len2 > 0) { if (pointer+1>=sectionLen) { LogDebug("pmt parser check2"); return false; } x = 0; int indicator=section[pointer]; x = section[pointer + 1] + 2; if(indicator==DESCRIPTOR_DVB_AC3) pidInfo2.logicalStreamType=SERVICE_TYPE_AUDIO_AC3; if(indicator==DESCRIPTOR_DVB_E_AC3) pidInfo2.logicalStreamType=SERVICE_TYPE_AUDIO_E_AC3; if(indicator==DESCRIPTOR_DVB_TELETEXT) pidInfo2.logicalStreamType=DESCRIPTOR_DVB_TELETEXT; if(indicator==DESCRIPTOR_DVB_SUBTITLING && stream_type==SERVICE_TYPE_DVB_SUBTITLES2) pidInfo2.logicalStreamType=SERVICE_TYPE_DVB_SUBTITLES2; len2 -= x; len1 -= x; pointer += x; } pidInfos.push_back(pidInfo2); } return true; }
int nfs41_op_open(struct nfs_argop4 *op, compound_data_t * data, struct nfs_resop4 *resp) { char __attribute__ ((__unused__)) funcname[] = "nfs4_op_open"; cache_entry_t * pentry_parent = NULL; cache_entry_t * pentry_lookup = NULL; cache_entry_t * pentry_newfile = NULL; fsal_handle_t * pnewfsal_handle = NULL; fsal_attrib_list_t attr_parent; fsal_attrib_list_t attr; fsal_attrib_list_t attr_newfile; fsal_attrib_list_t sattr; fsal_openflags_t openflags = 0; cache_inode_status_t cache_status; state_status_t state_status; nfsstat4 rc; int retval; fsal_name_t filename; bool_t AttrProvided = FALSE; fsal_accessmode_t mode = 0600; nfs_fh4 newfh4; nfs_worker_data_t * pworker = NULL; int convrc = 0; state_data_t candidate_data; state_type_t candidate_type; state_t * pfile_state = NULL; state_t * pstate_found_iterate = NULL; state_t * pstate_previous_iterate = NULL; state_t * pstate_found_same_owner = NULL; state_nfs4_owner_name_t owner_name; state_owner_t * powner = NULL; fsal_accessflags_t write_access = FSAL_MODE_MASK_SET(FSAL_W_OK) | FSAL_ACE4_MASK_SET(FSAL_ACE_PERM_WRITE_DATA | FSAL_ACE_PERM_APPEND_DATA); fsal_accessflags_t read_access = FSAL_MODE_MASK_SET(FSAL_R_OK) | FSAL_ACE4_MASK_SET(FSAL_ACE_PERM_READ_DATA); resp->resop = NFS4_OP_OPEN; res_OPEN4.status = NFS4_OK; uint32_t tmp_attr[2]; uint_t tmp_int = 2; #ifdef _USE_PNFS nfs_client_id_t nfs_clientid; bool_t open_owner_known = FALSE; int pnfs_status; #endif cache_inode_create_arg_t create_arg; pworker = (nfs_worker_data_t *) data->pclient->pworker; /* If there is no FH */ if(nfs4_Is_Fh_Empty(&(data->currentFH))) { res_OPEN4.status = NFS4ERR_NOFILEHANDLE; return res_OPEN4.status; } /* If the filehandle is invalid */ if(nfs4_Is_Fh_Invalid(&(data->currentFH))) { res_OPEN4.status = NFS4ERR_BADHANDLE; return res_OPEN4.status; } /* Tests if the Filehandle is expired (for volatile filehandle) */ if(nfs4_Is_Fh_Expired(&(data->currentFH))) { res_OPEN4.status = NFS4ERR_FHEXPIRED; return res_OPEN4.status; } /* This can't be done on the pseudofs */ if(nfs4_Is_Fh_Pseudo(&(data->currentFH))) { res_OPEN4.status = NFS4ERR_ROFS; return res_OPEN4.status; } /* If Filehandle points to a xattr object, manage it via the xattrs specific functions */ if(nfs4_Is_Fh_Xattr(&(data->currentFH))) return nfs4_op_open_xattr(op, data, resp); /* If data->current_entry is empty, repopulate it */ if(data->current_entry == NULL) { if((data->current_entry = nfs_FhandleToCache(NFS_V4, NULL, NULL, &(data->currentFH), NULL, NULL, &(res_OPEN4.status), &attr, data->pcontext, data->pclient, data->ht, &retval)) == NULL) { res_OPEN4.status = NFS4ERR_SERVERFAULT; return res_OPEN4.status; } } /* Set parent */ pentry_parent = data->current_entry; /* First switch is based upon claim type */ switch (arg_OPEN4.claim.claim) { case CLAIM_DELEGATE_CUR: case CLAIM_DELEGATE_PREV: /* Check for name length */ if(arg_OPEN4.claim.open_claim4_u.file.utf8string_len > FSAL_MAX_NAME_LEN) { res_OPEN4.status = NFS4ERR_NAMETOOLONG; return res_OPEN4.status; } /* get the filename from the argument, it should not be empty */ if(arg_OPEN4.claim.open_claim4_u.file.utf8string_len == 0) { res_OPEN4.status = NFS4ERR_INVAL; return res_OPEN4.status; } res_OPEN4.status = NFS4ERR_NOTSUPP; return res_OPEN4.status; break; case CLAIM_NULL: /* Check for name length */ if(arg_OPEN4.claim.open_claim4_u.file.utf8string_len > FSAL_MAX_NAME_LEN) { res_OPEN4.status = NFS4ERR_NAMETOOLONG; return res_OPEN4.status; } /* get the filename from the argument, it should not be empty */ if(arg_OPEN4.claim.open_claim4_u.file.utf8string_len == 0) { res_OPEN4.status = NFS4ERR_INVAL; return res_OPEN4.status; } /* Check if asked attributes are correct */ if(arg_OPEN4.openhow.openflag4_u.how.mode == GUARDED4 || arg_OPEN4.openhow.openflag4_u.how.mode == UNCHECKED4) { if(!nfs4_Fattr_Supported (&arg_OPEN4.openhow.openflag4_u.how.createhow4_u.createattrs)) { res_OPEN4.status = NFS4ERR_ATTRNOTSUPP; return res_OPEN4.status; } /* Do not use READ attr, use WRITE attr */ if(!nfs4_Fattr_Check_Access (&arg_OPEN4.openhow.openflag4_u.how.createhow4_u.createattrs, FATTR4_ATTR_WRITE)) { res_OPEN4.status = NFS4ERR_INVAL; return res_OPEN4.status; } } /* Check if filename is correct */ if((cache_status = cache_inode_error_convert(FSAL_buffdesc2name ((fsal_buffdesc_t *) & arg_OPEN4.claim.open_claim4_u. file, &filename))) != CACHE_INODE_SUCCESS) { res_OPEN4.status = nfs4_Errno(cache_status); return res_OPEN4.status; } /* Check parent */ pentry_parent = data->current_entry; /* Parent must be a directory */ if((pentry_parent->internal_md.type != DIR_BEGINNING) && (pentry_parent->internal_md.type != DIR_CONTINUE)) { /* Parent object is not a directory... */ if(pentry_parent->internal_md.type == SYMBOLIC_LINK) res_OPEN4.status = NFS4ERR_SYMLINK; else res_OPEN4.status = NFS4ERR_NOTDIR; return res_OPEN4.status; } /* What kind of open is it ? */ LogFullDebug(COMPONENT_NFS_V4, " OPEN: Claim type = %d Open Type = %d Share Deny = %d Share Access = %d ", arg_OPEN4.claim.claim, arg_OPEN4.openhow.opentype, arg_OPEN4.share_deny, arg_OPEN4.share_access); /* It this a known client id ? */ LogDebug(COMPONENT_NFS_V4, "OPEN Client id = %llx", (long long unsigned int)arg_OPEN4.owner.clientid); /* Is this open_owner known ? */ convert_nfs4_owner(&arg_OPEN4.owner, &owner_name); if(!nfs4_owner_Get_Pointer(&owner_name, &powner)) { /* This open owner is not known yet, allocated and set up a new one */ powner = create_nfs4_owner(data->pclient, &owner_name, &arg_OPEN4.owner, NULL, 1); /* NFSv4.1 specific, initial seqid is 1 */ if(powner == NULL) { res_OPEN4.status = NFS4ERR_SERVERFAULT; return res_OPEN4.status; } } /* Status of parent directory before the operation */ if(cache_inode_getattr(pentry_parent, &attr_parent, data->ht, data->pclient, data->pcontext, &cache_status) != CACHE_INODE_SUCCESS) { res_OPEN4.status = nfs4_Errno(cache_status); return res_OPEN4.status; } memset(&(res_OPEN4.OPEN4res_u.resok4.cinfo.before), 0, sizeof(changeid4)); res_OPEN4.OPEN4res_u.resok4.cinfo.before = (changeid4) pentry_parent->internal_md.mod_time; /* CLient may have provided fattr4 to set attributes at creation time */ if(arg_OPEN4.openhow.openflag4_u.how.mode == GUARDED4 || arg_OPEN4.openhow.openflag4_u.how.mode == UNCHECKED4) { if(arg_OPEN4.openhow.openflag4_u.how.createhow4_u.createattrs.attrmask. bitmap4_len != 0) { /* Convert fattr4 so nfs4_sattr */ convrc = nfs4_Fattr_To_FSAL_attr(&sattr, &(arg_OPEN4.openhow.openflag4_u.how. createhow4_u.createattrs)); if(convrc != NFS4_OK) { res_OPEN4.status = convrc; return res_OPEN4.status; } AttrProvided = TRUE; } } /* Second switch is based upon "openhow" */ switch (arg_OPEN4.openhow.opentype) { case OPEN4_CREATE: /* a new file is to be created */ /* Does a file with this name already exist ? */ pentry_lookup = cache_inode_lookup(pentry_parent, &filename, &attr_newfile, data->ht, data->pclient, data->pcontext, &cache_status); if(cache_status != CACHE_INODE_NOT_FOUND) { /* if open is UNCHECKED, return NFS4_OK (RFC3530 page 172) */ if(arg_OPEN4.openhow.openflag4_u.how.mode == UNCHECKED4 && (cache_status == CACHE_INODE_SUCCESS)) { /* If the file is opened for write, OPEN4 while deny share write access, * in this case, check caller has write access to the file */ if(arg_OPEN4.share_deny & OPEN4_SHARE_DENY_WRITE) { if(cache_inode_access(pentry_lookup, write_access, data->ht, data->pclient, data->pcontext, &cache_status) != CACHE_INODE_SUCCESS) { res_OPEN4.status = NFS4ERR_ACCESS; return res_OPEN4.status; } openflags = FSAL_O_WRONLY; } /* Same check on read: check for readability of a file before opening it for read */ if(arg_OPEN4.share_access & OPEN4_SHARE_ACCESS_READ) { if(cache_inode_access(pentry_lookup, read_access, data->ht, data->pclient, data->pcontext, &cache_status) != CACHE_INODE_SUCCESS) { res_OPEN4.status = NFS4ERR_ACCESS; return res_OPEN4.status; } openflags = FSAL_O_RDONLY; } if(AttrProvided == TRUE) /* Set the attribute if provided */ { if(cache_inode_setattr(pentry_lookup, &sattr, data->ht, data->pclient, data->pcontext, &cache_status) != CACHE_INODE_SUCCESS) { res_OPEN4.status = nfs4_Errno(cache_status); return res_OPEN4.status; } res_OPEN4.OPEN4res_u.resok4.attrset = arg_OPEN4.openhow.openflag4_u.how.createhow4_u.createattrs. attrmask; } else res_OPEN4.OPEN4res_u.resok4.attrset.bitmap4_len = 0; /* Same check on write */ if(arg_OPEN4.share_access & OPEN4_SHARE_ACCESS_WRITE) { if(cache_inode_access(pentry_lookup, write_access, data->ht, data->pclient, data->pcontext, &cache_status) != CACHE_INODE_SUCCESS) { res_OPEN4.status = NFS4ERR_ACCESS; return res_OPEN4.status; } openflags = FSAL_O_RDWR; } /* Set the state for the related file */ /* Prepare state management structure */ candidate_type = STATE_TYPE_SHARE; candidate_data.share.share_deny = arg_OPEN4.share_deny; candidate_data.share.share_access = arg_OPEN4.share_access; if(state_add(pentry_lookup, candidate_type, &candidate_data, powner, data->pclient, data->pcontext, &pfile_state, &state_status) != STATE_SUCCESS) { /* Seqid has to be incremented even in this case */ P(powner->so_mutex); powner->so_owner.so_nfs4_owner.so_seqid += 1; V(powner->so_mutex); res_OPEN4.status = NFS4ERR_SHARE_DENIED; return res_OPEN4.status; } /* Open the file */ if(cache_inode_open_by_name(pentry_parent, &filename, pentry_lookup, data->pclient, openflags, data->pcontext, &cache_status) != CACHE_INODE_SUCCESS) { /* Seqid has to be incremented even in this case */ P(powner->so_mutex); powner->so_owner.so_nfs4_owner.so_seqid += 1; V(powner->so_mutex); res_OPEN4.status = NFS4ERR_SHARE_DENIED; res_OPEN4.status = NFS4ERR_ACCESS; return res_OPEN4.status; } res_OPEN4.OPEN4res_u.resok4.attrset.bitmap4_len = 2; if((res_OPEN4.OPEN4res_u.resok4.attrset.bitmap4_val = (uint32_t *) Mem_Alloc(res_OPEN4.OPEN4res_u.resok4.attrset. bitmap4_len * sizeof(uint32_t))) == NULL) { res_OPEN4.status = NFS4ERR_SERVERFAULT; return res_OPEN4.status; } memset(&(res_OPEN4.OPEN4res_u.resok4.cinfo.after), 0, sizeof(changeid4)); res_OPEN4.OPEN4res_u.resok4.cinfo.after = (changeid4) pentry_parent->internal_md.mod_time; res_OPEN4.OPEN4res_u.resok4.cinfo.atomic = TRUE; res_OPEN4.OPEN4res_u.resok4.stateid.seqid = pfile_state->state_seqid; memcpy(res_OPEN4.OPEN4res_u.resok4.stateid.other, pfile_state->stateid_other, OTHERSIZE); /* No delegation */ res_OPEN4.OPEN4res_u.resok4.delegation.delegation_type = OPEN_DELEGATE_NONE; res_OPEN4.OPEN4res_u.resok4.rflags = OPEN4_RESULT_LOCKTYPE_POSIX; /* Now produce the filehandle to this file */ if((pnewfsal_handle = cache_inode_get_fsal_handle(pentry_lookup, &cache_status)) == NULL) { res_OPEN4.status = nfs4_Errno(cache_status); return res_OPEN4.status; } /* Allocation of a new file handle */ if((rc = nfs4_AllocateFH(&newfh4)) != NFS4_OK) { res_OPEN4.status = rc; return res_OPEN4.status; } /* Building a new fh */ if(!nfs4_FSALToFhandle(&newfh4, pnewfsal_handle, data)) { res_OPEN4.status = NFS4ERR_SERVERFAULT; return res_OPEN4.status; } /* This new fh replaces the current FH */ data->currentFH.nfs_fh4_len = newfh4.nfs_fh4_len; memcpy(data->currentFH.nfs_fh4_val, newfh4.nfs_fh4_val, newfh4.nfs_fh4_len); data->current_entry = pentry_lookup; data->current_filetype = REGULAR_FILE; res_OPEN4.status = NFS4_OK; return res_OPEN4.status; } /* if open is EXCLUSIVE, but verifier is the same, return NFS4_OK (RFC3530 page 173) */ if(arg_OPEN4.openhow.openflag4_u.how.mode == EXCLUSIVE4) { if((pentry_lookup != NULL) && (pentry_lookup->internal_md.type == REGULAR_FILE)) { pstate_found_iterate = NULL; pstate_previous_iterate = NULL; do { state_iterate(pentry_lookup, &pstate_found_iterate, pstate_previous_iterate, data->pclient, data->pcontext, &state_status); if(state_status == STATE_STATE_ERROR) break; if(state_status == STATE_INVALID_ARGUMENT) { /* Seqid has to be incremented even in this case */ P(powner->so_mutex); powner->so_owner.so_nfs4_owner.so_seqid += 1; V(powner->so_mutex); res_OPEN4.status = NFS4ERR_INVAL; return res_OPEN4.status; } cache_status = CACHE_INODE_SUCCESS; /* Check is open_owner is the same */ if(pstate_found_iterate != NULL) { if((pstate_found_iterate->state_type == STATE_TYPE_SHARE) && !memcmp(arg_OPEN4.owner.owner.owner_val, pstate_found_iterate->state_powner->so_owner_val, pstate_found_iterate->state_powner->so_owner_len) && !memcmp(pstate_found_iterate->state_data.share. oexcl_verifier, arg_OPEN4.openhow.openflag4_u.how. createhow4_u.createverf, NFS4_VERIFIER_SIZE)) { /* A former open EXCLUSIVE with same owner and verifier was found, resend it */ res_OPEN4.OPEN4res_u.resok4.stateid.seqid = pstate_found_iterate->state_seqid; memcpy(res_OPEN4.OPEN4res_u.resok4.stateid.other, pstate_found_iterate->stateid_other, OTHERSIZE); memset(&(res_OPEN4.OPEN4res_u.resok4.cinfo.after), 0, sizeof(changeid4)); res_OPEN4.OPEN4res_u.resok4.cinfo.after = (changeid4) pentry_parent->internal_md.mod_time; res_OPEN4.OPEN4res_u.resok4.cinfo.atomic = TRUE; /* No delegation */ res_OPEN4.OPEN4res_u.resok4.delegation.delegation_type = OPEN_DELEGATE_NONE; res_OPEN4.OPEN4res_u.resok4.rflags = OPEN4_RESULT_LOCKTYPE_POSIX; /* Now produce the filehandle to this file */ if((pnewfsal_handle = cache_inode_get_fsal_handle(pentry_lookup, &cache_status)) == NULL) { res_OPEN4.status = nfs4_Errno(cache_status); return res_OPEN4.status; } /* Allocation of a new file handle */ if((rc = nfs4_AllocateFH(&newfh4)) != NFS4_OK) { res_OPEN4.status = rc; return res_OPEN4.status; } /* Building a new fh */ if(!nfs4_FSALToFhandle(&newfh4, pnewfsal_handle, data)) { res_OPEN4.status = NFS4ERR_SERVERFAULT; return res_OPEN4.status; } /* This new fh replaces the current FH */ data->currentFH.nfs_fh4_len = newfh4.nfs_fh4_len; memcpy(data->currentFH.nfs_fh4_val, newfh4.nfs_fh4_val, newfh4.nfs_fh4_len); data->current_entry = pentry_lookup; data->current_filetype = REGULAR_FILE; /* regular exit */ res_OPEN4.status = NFS4_OK; return res_OPEN4.status; } } /* if( pstate_found_iterate != NULL ) */ pstate_previous_iterate = pstate_found_iterate; } while(pstate_found_iterate != NULL); } } /* Managing GUARDED4 mode */ if(cache_status != CACHE_INODE_SUCCESS) res_OPEN4.status = nfs4_Errno(cache_status); else res_OPEN4.status = NFS4ERR_EXIST; /* File already exists */ return res_OPEN4.status; } /* if( cache_status != CACHE_INODE_NOT_FOUND ), if file already exists basically */ LogFullDebug(COMPONENT_NFS_V4, " OPEN open.how = %d", arg_OPEN4.openhow.openflag4_u.how.mode); create_arg.use_pnfs = FALSE; #ifdef _USE_PNFS /* set the file has "managed via pNFS" */ if(data->pexport->options & EXPORT_OPTION_USE_PNFS) create_arg.use_pnfs = TRUE; #endif /* _USE_PNFS */ /* Create the file, if we reach this point, it does not exist, we can create it */ if((pentry_newfile = cache_inode_create(pentry_parent, &filename, REGULAR_FILE, mode, &create_arg, &attr_newfile, data->ht, data->pclient, data->pcontext, &cache_status)) == NULL) { /* If the file already exists, this is not an error if open mode is UNCHECKED */ if(cache_status != CACHE_INODE_ENTRY_EXISTS) { res_OPEN4.status = nfs4_Errno(cache_status); return res_OPEN4.status; } else { /* If this point is reached, then the file already exists, cache_status == CACHE_INODE_ENTRY_EXISTS and pentry_newfile == NULL This probably means EXCLUSIVE4 mode is used and verifier matches. pentry_newfile is then set to pentry_lookup */ pentry_newfile = pentry_lookup; } } /* Prepare state management structure */ candidate_type = STATE_TYPE_SHARE; candidate_data.share.share_deny = arg_OPEN4.share_deny; candidate_data.share.share_access = arg_OPEN4.share_access; candidate_data.share.lockheld = 0; /* If file is opened under mode EXCLUSIVE4, open verifier should be kept to detect non vicious double open */ if(arg_OPEN4.openhow.openflag4_u.how.mode == EXCLUSIVE4) { strncpy(candidate_data.share.oexcl_verifier, arg_OPEN4.openhow.openflag4_u.how.createhow4_u.createverf, NFS4_VERIFIER_SIZE); } if(state_add(pentry_newfile, candidate_type, &candidate_data, powner, data->pclient, data->pcontext, &pfile_state, &state_status) != STATE_SUCCESS) { /* Seqid has to be incremented even in this case */ P(powner->so_mutex); powner->so_owner.so_nfs4_owner.so_seqid += 1; V(powner->so_mutex); res_OPEN4.status = NFS4ERR_SHARE_DENIED; return res_OPEN4.status; } cache_status = CACHE_INODE_SUCCESS; if(AttrProvided == TRUE) /* Set the attribute if provided */ { if((cache_status = cache_inode_setattr(pentry_newfile, &sattr, data->ht, data->pclient, data->pcontext, &cache_status)) != CACHE_INODE_SUCCESS) { res_OPEN4.status = nfs4_Errno(cache_status); return res_OPEN4.status; } } /* Set the openflags variable */ if(arg_OPEN4.share_deny & OPEN4_SHARE_DENY_WRITE) openflags |= FSAL_O_RDONLY; if(arg_OPEN4.share_deny & OPEN4_SHARE_DENY_READ) openflags |= FSAL_O_WRONLY; if(arg_OPEN4.share_access & OPEN4_SHARE_ACCESS_WRITE) openflags = FSAL_O_RDWR; if(arg_OPEN4.share_access != 0) openflags = FSAL_O_RDWR; /* @todo : BUGAZOMEU : Something better later */ /* Open the file */ if(cache_inode_open_by_name(pentry_parent, &filename, pentry_newfile, data->pclient, openflags, data->pcontext, &cache_status) != CACHE_INODE_SUCCESS) { /* Seqid has to be incremented even in this case */ P(powner->so_mutex); powner->so_owner.so_nfs4_owner.so_seqid += 1; V(powner->so_mutex); res_OPEN4.status = NFS4ERR_ACCESS; return res_OPEN4.status; } break; case OPEN4_NOCREATE: /* It was not a creation, but a regular open */ /* The filehandle to the new file replaces the current filehandle */ if(pentry_newfile == NULL) { if((pentry_newfile = cache_inode_lookup(pentry_parent, &filename, &attr_newfile, data->ht, data->pclient, data->pcontext, &cache_status)) == NULL) { res_OPEN4.status = nfs4_Errno(cache_status); return res_OPEN4.status; } } /* OPEN4 is to be done on a file */ if(pentry_newfile->internal_md.type != REGULAR_FILE) { if(pentry_newfile->internal_md.type == DIR_BEGINNING || pentry_newfile->internal_md.type == DIR_CONTINUE) { res_OPEN4.status = NFS4ERR_ISDIR; return res_OPEN4.status; } else if(pentry_newfile->internal_md.type == SYMBOLIC_LINK) { res_OPEN4.status = NFS4ERR_SYMLINK; return res_OPEN4.status; } else { res_OPEN4.status = NFS4ERR_INVAL; return res_OPEN4.status; } } /* If the file is opened for write, OPEN4 while deny share write access, * in this case, check caller has write access to the file */ if(arg_OPEN4.share_deny & OPEN4_SHARE_DENY_WRITE) { if(cache_inode_access(pentry_newfile, write_access, data->ht, data->pclient, data->pcontext, &cache_status) != CACHE_INODE_SUCCESS) { res_OPEN4.status = NFS4ERR_ACCESS; return res_OPEN4.status; } openflags = FSAL_O_WRONLY; } /* Same check on read: check for readability of a file before opening it for read */ if(arg_OPEN4.share_access & OPEN4_SHARE_ACCESS_READ) { if(cache_inode_access(pentry_newfile, read_access, data->ht, data->pclient, data->pcontext, &cache_status) != CACHE_INODE_SUCCESS) { res_OPEN4.status = NFS4ERR_ACCESS; return res_OPEN4.status; } openflags = FSAL_O_RDONLY; } /* Same check on write */ if(arg_OPEN4.share_access & OPEN4_SHARE_ACCESS_WRITE) { if(cache_inode_access(pentry_newfile, write_access, data->ht, data->pclient, data->pcontext, &cache_status) != CACHE_INODE_SUCCESS) { res_OPEN4.status = NFS4ERR_ACCESS; return res_OPEN4.status; } openflags = FSAL_O_RDWR; } /* Try to find if the same open_owner already has acquired a stateid for this file */ pstate_found_iterate = NULL; pstate_previous_iterate = NULL; do { state_iterate(pentry_newfile, &pstate_found_iterate, pstate_previous_iterate, data->pclient, data->pcontext, &state_status); if(state_status == STATE_STATE_ERROR) break; /* Get out of the loop */ if(state_status == STATE_INVALID_ARGUMENT) { res_OPEN4.status = NFS4ERR_INVAL; return res_OPEN4.status; } cache_status = CACHE_INODE_SUCCESS; /* Check is open_owner is the same */ if(pstate_found_iterate != NULL) { if((pstate_found_iterate->state_type == STATE_TYPE_SHARE) && (pstate_found_iterate->state_powner->so_owner.so_nfs4_owner.so_clientid == arg_OPEN4.owner.clientid) && ((pstate_found_iterate->state_powner->so_owner_len == arg_OPEN4.owner.owner.owner_len) && (!memcmp (arg_OPEN4.owner.owner.owner_val, pstate_found_iterate->state_powner->so_owner_val, pstate_found_iterate->state_powner->so_owner_len)))) { /* We'll be re-using the found state */ pstate_found_same_owner = pstate_found_iterate; } else { /* This is a different owner, check for possible conflicts */ if(memcmp(arg_OPEN4.owner.owner.owner_val, pstate_found_iterate->state_powner->so_owner_val, pstate_found_iterate->state_powner->so_owner_len)) { if(pstate_found_iterate->state_type == STATE_TYPE_SHARE) { if((pstate_found_iterate->state_data.share. share_access & OPEN4_SHARE_ACCESS_WRITE) && (arg_OPEN4.share_deny & OPEN4_SHARE_DENY_WRITE)) { res_OPEN4.status = NFS4ERR_SHARE_DENIED; return res_OPEN4.status; } } } } /* In all cases opening in read access a read denied file or write access to a write denied file * should fail, even if the owner is the same, see discussion in 14.2.16 and 8.9 */ if(pstate_found_iterate->state_type == STATE_TYPE_SHARE) { /* deny read access on read denied file */ if((pstate_found_iterate->state_data.share. share_deny & OPEN4_SHARE_DENY_READ) && (arg_OPEN4.share_access & OPEN4_SHARE_ACCESS_READ)) { /* Seqid has to be incremented even in this case */ P(powner->so_mutex); powner->so_owner.so_nfs4_owner.so_seqid += 1; V(powner->so_mutex); powner->so_owner.so_nfs4_owner.so_seqid += 1; res_OPEN4.status = NFS4ERR_SHARE_DENIED; return res_OPEN4.status; } /* deny write access on write denied file */ if((pstate_found_iterate->state_data.share. share_deny & OPEN4_SHARE_DENY_WRITE) && (arg_OPEN4.share_access & OPEN4_SHARE_ACCESS_WRITE)) { /* Seqid has to be incremented even in this case */ P(powner->so_mutex); powner->so_owner.so_nfs4_owner.so_seqid += 1; V(powner->so_mutex); res_OPEN4.status = NFS4ERR_SHARE_DENIED; return res_OPEN4.status; } } } /* if( pstate_found_iterate != NULL ) */ pstate_previous_iterate = pstate_found_iterate; } while(pstate_found_iterate != NULL); if(pstate_found_same_owner != NULL) { pfile_state = pstate_found_same_owner; pfile_state->state_seqid += 1; P(powner->so_mutex); powner->so_owner.so_nfs4_owner.so_seqid += 1; V(powner->so_mutex); } else { /* Set the state for the related file */ /* Prepare state management structure */ candidate_type = STATE_TYPE_SHARE; candidate_data.share.share_deny = arg_OPEN4.share_deny; candidate_data.share.share_access = arg_OPEN4.share_access; if(state_add(pentry_newfile, candidate_type, &candidate_data, powner, data->pclient, data->pcontext, &pfile_state, &state_status) != STATE_SUCCESS) { /* Seqid has to be incremented even in this case */ P(powner->so_mutex); powner->so_owner.so_nfs4_owner.so_seqid += 1; V(powner->so_mutex); res_OPEN4.status = NFS4ERR_SHARE_DENIED; return res_OPEN4.status; } } /* Open the file */ if(cache_inode_open_by_name(pentry_parent, &filename, pentry_newfile, data->pclient, openflags, data->pcontext, &cache_status) != CACHE_INODE_SUCCESS) { /* Seqid has to be incremented even in this case */ P(powner->so_mutex); powner->so_owner.so_nfs4_owner.so_seqid += 1; V(powner->so_mutex); res_OPEN4.status = NFS4ERR_ACCESS; return res_OPEN4.status; } break; default: /* Seqid has to be incremented even in this case */ if(powner != NULL) { P(powner->so_mutex); powner->so_owner.so_nfs4_owner.so_seqid += 1; V(powner->so_mutex); } res_OPEN4.status = NFS4ERR_INVAL; return res_OPEN4.status; break; } /* switch( arg_OPEN4.openhow.opentype ) */ break; case CLAIM_PREVIOUS: break; default: /* Seqid has to be incremented even in this case */ if(powner != NULL) { P(powner->so_mutex); powner->so_owner.so_nfs4_owner.so_seqid += 1; V(powner->so_mutex); } res_OPEN4.status = NFS4ERR_INVAL; return res_OPEN4.status; break; } /* switch( arg_OPEN4.claim.claim ) */ /* Now produce the filehandle to this file */ if((pnewfsal_handle = cache_inode_get_fsal_handle(pentry_newfile, &cache_status)) == NULL) { res_OPEN4.status = nfs4_Errno(cache_status); return res_OPEN4.status; } /* Allocation of a new file handle */ if((rc = nfs4_AllocateFH(&newfh4)) != NFS4_OK) { res_OPEN4.status = rc; return res_OPEN4.status; } /* Building a new fh */ if(!nfs4_FSALToFhandle(&newfh4, pnewfsal_handle, data)) { res_OPEN4.status = NFS4ERR_SERVERFAULT; return res_OPEN4.status; } /* This new fh replaces the current FH */ data->currentFH.nfs_fh4_len = newfh4.nfs_fh4_len; memcpy(data->currentFH.nfs_fh4_val, newfh4.nfs_fh4_val, newfh4.nfs_fh4_len); data->current_entry = pentry_newfile; data->current_filetype = REGULAR_FILE; /* No do not need newfh any more */ Mem_Free((char *)newfh4.nfs_fh4_val); /* Status of parent directory after the operation */ if((cache_status = cache_inode_getattr(pentry_parent, &attr_parent, data->ht, data->pclient, data->pcontext, &cache_status)) != CACHE_INODE_SUCCESS) { res_OPEN4.status = nfs4_Errno(cache_status); return res_OPEN4.status; } res_OPEN4.OPEN4res_u.resok4.attrset.bitmap4_len = 2; if((res_OPEN4.OPEN4res_u.resok4.attrset.bitmap4_val = (uint32_t *) Mem_Alloc(res_OPEN4.OPEN4res_u.resok4.attrset.bitmap4_len * sizeof(uint32_t))) == NULL) { res_OPEN4.status = NFS4ERR_SERVERFAULT; return res_OPEN4.status; } res_OPEN4.OPEN4res_u.resok4.attrset.bitmap4_val[0] = 0; /* No Attributes set */ res_OPEN4.OPEN4res_u.resok4.attrset.bitmap4_val[1] = 0; /* No Attributes set */ if(arg_OPEN4.openhow.opentype == OPEN4_CREATE) { tmp_int = 2; tmp_attr[0] = FATTR4_SIZE; tmp_attr[1] = FATTR4_MODE; nfs4_list_to_bitmap4(&(res_OPEN4.OPEN4res_u.resok4.attrset), &tmp_int, tmp_attr); res_OPEN4.OPEN4res_u.resok4.attrset.bitmap4_len = 2; } res_OPEN4.OPEN4res_u.resok4.cinfo.after = (changeid4) pentry_parent->internal_md.mod_time; res_OPEN4.OPEN4res_u.resok4.cinfo.atomic = TRUE; res_OPEN4.OPEN4res_u.resok4.stateid.seqid = powner->so_owner.so_nfs4_owner.so_seqid; memcpy(res_OPEN4.OPEN4res_u.resok4.stateid.other, pfile_state->stateid_other, OTHERSIZE); /* No delegation */ res_OPEN4.OPEN4res_u.resok4.delegation.delegation_type = OPEN_DELEGATE_NONE; res_OPEN4.OPEN4res_u.resok4.rflags = OPEN4_RESULT_LOCKTYPE_POSIX; /* regular exit */ res_OPEN4.status = NFS4_OK; return res_OPEN4.status; } /* nfs41_op_open */
// Sends ON GAME_READY msg to all IOs void SendGameReadyMsg() { LogDebug("SendGameReadyMsg"); SendMsgToAllIO(SM_GAME_READY); }
// // OpenFile // // Opens the file ready for streaming // HRESULT FileReader::OpenFile() { CAutoLockFR rLock (&m_accessLock); WCHAR *pFileName = NULL; DWORD Tmo=14 ; HANDLE hFileUnbuff = INVALID_HANDLE_VALUE; //Can be used to open files in random-access mode to workaround SMB caching problems DWORD accessModeFlags = (m_bUseRandomAccess ? FILE_FLAG_RANDOM_ACCESS : FILE_FLAG_SEQUENTIAL_SCAN); // Is the file already opened if (m_hFile != INVALID_HANDLE_VALUE) { LogDebug("FileReader::OpenFile() file already open"); return NOERROR; } // Has a filename been set yet if (m_pFileName == NULL) { LogDebug("FileReader::OpenFile() no filename"); return ERROR_INVALID_NAME; } m_bIsStopping = false; pFileName = m_pFileName; //LogDebug("FileReader::OpenFile(), Filename: %ws.", pFileName); do { if (m_bIsStopping) return E_FAIL; if (m_bUseDummyWrites) //enable SMB2/SMB3 file existence cache workaround { if ((wcsstr(pFileName, L".ts.tsbuffer") != NULL)) //timeshift file only { CString tempFileName = pFileName; int replCount = tempFileName.Replace(L".ts.tsbuffer", randomStrGen(12)); if (replCount > 0) { //LogDebug("FileReader::OpenFile(), try to write dummy file to update SMB2 cache - %ws", tempFileName); hFileUnbuff = ::CreateFileW(tempFileName, // The filename (DWORD) (GENERIC_READ | GENERIC_WRITE), // File access (DWORD) (FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE), // Share access NULL, // Security (DWORD) CREATE_ALWAYS, // Open flags (DWORD) (FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE), // More flags NULL); // Template if (hFileUnbuff != INVALID_HANDLE_VALUE) { char tempData[16] = {0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF}; DWORD bytesWritten; ::WriteFile(hFileUnbuff, tempData, 16, &bytesWritten, NULL); ::CloseHandle(hFileUnbuff); //File is deleted on CloseHandle since FILE_FLAG_DELETE_ON_CLOSE was used hFileUnbuff = INVALID_HANDLE_VALUE; // Invalidate the file //LogDebug("FileReader::OpenFile(), dummy file write %d bytes to %ws", bytesWritten, tempFileName); } } } } // do not try to open a tsbuffer file without SHARE_WRITE so skip this try if we have a buffer file if (wcsstr(pFileName, L".ts.tsbuffer") == NULL) // not tsbuffer files { // Try to open the file in read-only mode (should fail for 'live' recordings) m_hFile = ::CreateFileW(pFileName, // The filename (DWORD) GENERIC_READ, // File access (DWORD) FILE_SHARE_READ, // Share access NULL, // Security (DWORD) OPEN_EXISTING, // Open flags (DWORD) accessModeFlags, // More flags NULL); // Template if (m_hFile != INVALID_HANDLE_VALUE) break ; //This is in case file is being recorded to ('live' recordings) m_hFile = ::CreateFileW(pFileName, // The filename (DWORD) GENERIC_READ, // File access (DWORD) (FILE_SHARE_READ | FILE_SHARE_WRITE), // Share access NULL, // Security (DWORD) OPEN_EXISTING, // Open flags (DWORD) accessModeFlags, // More flags NULL); // Template if (m_hFile != INVALID_HANDLE_VALUE) break ; } else //for tsbuffer files { //This is in case file is being recorded to m_hFile = ::CreateFileW(pFileName, // The filename (DWORD) GENERIC_READ, // File access (DWORD) (FILE_SHARE_READ | FILE_SHARE_WRITE), // Share access NULL, // Security (DWORD) OPEN_EXISTING, // Open flags (DWORD) accessModeFlags, // More flags NULL); // Template if (m_hFile != INVALID_HANDLE_VALUE) break ; } if ((wcsstr(pFileName, L".ts.tsbuffer") != NULL) && (Tmo<10)) //timeshift file only { if (m_bUseDummyWrites) //enable SMB2/SMB3 file existence cache workaround { //Not succeeded in opening file yet, try WRITE_THROUGH dummy file write CString tempFileName = pFileName; int replCount = tempFileName.Replace(L".ts.tsbuffer", randomStrGen(12)); if (replCount > 0) { // LogDebug("FileReader::OpenFile(), try to write dummy file to update SMB2 cache - %ws", tempFileName); hFileUnbuff = ::CreateFileW(tempFileName, // The filename (DWORD) (GENERIC_READ | GENERIC_WRITE), // File access (DWORD) (FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE), // Share access NULL, // Security (DWORD) CREATE_ALWAYS, // Open flags (DWORD) (FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE | FILE_FLAG_WRITE_THROUGH), // More flags NULL); // Template if (hFileUnbuff != INVALID_HANDLE_VALUE) { char tempData[16] = {0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF}; DWORD bytesWritten; ::WriteFile(hFileUnbuff, tempData, 16, &bytesWritten, NULL); Sleep(50); ::CloseHandle(hFileUnbuff); //File is deleted on CloseHandle since FILE_FLAG_DELETE_ON_CLOSE was used hFileUnbuff = INVALID_HANDLE_VALUE; // Invalidate the file LogDebug("FileReader::OpenFile(), dummy file WRITE_THROUGH write %d bytes to %ws", bytesWritten, tempFileName); } } } //No luck yet, so try unbuffered open and close (to flush SMB2 cache?), //then go round loop again to open it properly (hopefully....) hFileUnbuff = ::CreateFileW(pFileName, // The filename (DWORD) GENERIC_READ, // File access (DWORD) (FILE_SHARE_READ | FILE_SHARE_WRITE), // Share access NULL, // Security (DWORD) OPEN_EXISTING, // Open flags (DWORD) FILE_FLAG_NO_BUFFERING, // More flags NULL); // Template if (hFileUnbuff != INVALID_HANDLE_VALUE) { ::CloseHandle(hFileUnbuff); hFileUnbuff = INVALID_HANDLE_VALUE; // Invalidate the file } //LogDebug("FileReader::OpenFile() unbuff, %d tries to open %ws", 15-Tmo, pFileName); } Sleep(min((20*(15-Tmo)),250)) ; //wait longer between retries as loop iterations increase } while(--Tmo) ; if (Tmo) { if (Tmo<13) // 1 failed + 1 succeded is quasi-normal, more is a bit suspicious ( disk drive too slow or problem ? ) LogDebug("FileReader::OpenFile(), %d tries to succeed opening %ws.", 15-Tmo, pFileName); } else { HRESULT lastErr = HRESULT_FROM_WIN32(GetLastError()); LogDebug("FileReader::OpenFile(), open file failed. Error 0x%x, %ws, filename = %ws", lastErr, HresultToCString(lastErr), pFileName); return E_FAIL; } //LogDebug("FileReader::OpenFile() handle %i %ws", m_hFile, pFileName ); LARGE_INTEGER li; li.QuadPart = 0; ::SetFilePointer(m_hFile, li.LowPart, &li.HighPart, FILE_BEGIN); return S_OK; } // Open
int main(int argc, char **argv) { QString appBundlePath; if (argc > 1) appBundlePath = QString::fromLocal8Bit(argv[1]); if (argc < 2 || appBundlePath.startsWith("-")) { qDebug() << "Usage: macdeployqt app-bundle [options]"; qDebug() << ""; qDebug() << "Options:"; qDebug() << " -verbose=<0-3> : 0 = no output, 1 = error/warning (default), 2 = normal, 3 = debug"; qDebug() << " -no-plugins : Skip plugin deployment"; qDebug() << " -dmg : Create a .dmg disk image"; qDebug() << " -no-strip : Don't run 'strip' on the binaries"; qDebug() << " -use-debug-libs : Deploy with debug versions of frameworks and plugins (implies -no-strip)"; qDebug() << ""; qDebug() << "macdeployqt takes an application bundle as input and makes it"; qDebug() << "self-contained by copying in the Qt frameworks and plugins that"; qDebug() << "the application uses."; qDebug() << ""; qDebug() << "Plugins related to a framework are copied in with the"; qDebug() << "framework. The accessibilty, image formats, and text codec"; qDebug() << "plugins are always copied, unless \"-no-plugins\" is specified."; qDebug() << ""; qDebug() << "See the \"Deploying an Application on Qt/Mac\" topic in the"; qDebug() << "documentation for more information about deployment on Mac OS X."; return 0; } if (appBundlePath.endsWith("/")) appBundlePath.chop(1); if (QDir().exists(appBundlePath) == false) { qDebug() << "Error: Could not find app bundle" << appBundlePath; return 0; } bool plugins = true; bool dmg = false; bool useDebugLibs = false; extern bool runStripEnabled; for (int i = 2; i < argc; ++i) { QByteArray argument = QByteArray(argv[i]); if (argument == QByteArray("-no-plugins")) { LogDebug() << "Argument found:" << argument; plugins = false; } else if (argument == QByteArray("-dmg")) { LogDebug() << "Argument found:" << argument; dmg = true; } else if (argument == QByteArray("-no-strip")) { LogDebug() << "Argument found:" << argument; runStripEnabled = false; } else if (argument == QByteArray("-use-debug-libs")) { LogDebug() << "Argument found:" << argument; useDebugLibs = true; runStripEnabled = false; } else if (argument.startsWith(QByteArray("-verbose"))) { LogDebug() << "Argument found:" << argument; int index = argument.indexOf("="); bool ok = false; int number = argument.mid(index+1).toInt(&ok); if (!ok) LogError() << "Could not parse verbose level"; else logLevel = number; } else if (argument.startsWith("-")) { LogError() << "Unknown argument" << argument << "\n"; return 0; } } DeploymentInfo deploymentInfo = deployQtFrameworks(appBundlePath, useDebugLibs); if (plugins) { if (deploymentInfo.qtPath.isEmpty()) deploymentInfo.pluginPath = "/Developer/Applications/Qt/plugins"; // Assume binary package. else deploymentInfo.pluginPath = deploymentInfo.qtPath + "/plugins"; LogNormal(); deployPlugins(appBundlePath, deploymentInfo, useDebugLibs); createQtConf(appBundlePath); } if (dmg) { LogNormal(); createDiskImage(appBundlePath); } }
int nfs3_fsstat(nfs_arg_t *arg, struct svc_req *req, nfs_res_t *res) { fsal_dynamicfsinfo_t dynamicinfo; cache_inode_status_t cache_status; cache_entry_t *entry = NULL; int rc = NFS_REQ_OK; if (isDebug(COMPONENT_NFSPROTO)) { char str[LEN_FH_STR]; nfs_FhandleToStr(req->rq_vers, &(arg->arg_fsstat3.fsroot), NULL, str); LogDebug(COMPONENT_NFSPROTO, "REQUEST PROCESSING: Calling nfs3_fsstat handle: %s", str); } /* to avoid setting it on each error case */ res->res_fsstat3.FSSTAT3res_u.resfail.obj_attributes.attributes_follow = FALSE; entry = nfs3_FhandleToCache(&arg->arg_fsstat3.fsroot, &res->res_fsstat3.status, &rc); if (entry == NULL) { /* Status and rc have been set by nfs3_FhandleToCache */ goto out; } /* Get statistics and convert from cache */ cache_status = cache_inode_statfs(entry, &dynamicinfo); if (cache_status == CACHE_INODE_SUCCESS) { LogFullDebug(COMPONENT_NFSPROTO, "nfs_Fsstat --> dynamicinfo.total_bytes=%" PRIu64 " dynamicinfo.free_bytes=%" PRIu64 " dynamicinfo.avail_bytes=%" PRIu64, dynamicinfo.total_bytes, dynamicinfo.free_bytes, dynamicinfo.avail_bytes); LogFullDebug(COMPONENT_NFSPROTO, "nfs_Fsstat --> dynamicinfo.total_files=%" PRIu64 " dynamicinfo.free_files=%" PRIu64 " dynamicinfo.avail_files=%" PRIu64, dynamicinfo.total_files, dynamicinfo.free_files, dynamicinfo.avail_files); nfs_SetPostOpAttr(entry, &(res->res_fsstat3.FSSTAT3res_u.resok. obj_attributes)); res->res_fsstat3.FSSTAT3res_u.resok.tbytes = dynamicinfo.total_bytes; res->res_fsstat3.FSSTAT3res_u.resok.fbytes = dynamicinfo.free_bytes; res->res_fsstat3.FSSTAT3res_u.resok.abytes = dynamicinfo.avail_bytes; res->res_fsstat3.FSSTAT3res_u.resok.tfiles = dynamicinfo.total_files; res->res_fsstat3.FSSTAT3res_u.resok.ffiles = dynamicinfo.free_files; res->res_fsstat3.FSSTAT3res_u.resok.afiles = dynamicinfo.avail_files; /* volatile FS */ res->res_fsstat3.FSSTAT3res_u.resok.invarsec = 0; res->res_fsstat3.status = NFS3_OK; LogFullDebug(COMPONENT_NFSPROTO, "nfs_Fsstat --> tbytes=%llu fbytes=%llu abytes=%llu", res->res_fsstat3.FSSTAT3res_u.resok.tbytes, res->res_fsstat3.FSSTAT3res_u.resok.fbytes, res->res_fsstat3.FSSTAT3res_u.resok.abytes); LogFullDebug(COMPONENT_NFSPROTO, "nfs_Fsstat --> tfiles=%llu fffiles=%llu afiles=%llu", res->res_fsstat3.FSSTAT3res_u.resok.tfiles, res->res_fsstat3.FSSTAT3res_u.resok.ffiles, res->res_fsstat3.FSSTAT3res_u.resok.afiles); rc = NFS_REQ_OK; goto out; } /* At this point we met an error */ if (nfs_RetryableError(cache_status)) { rc = NFS_REQ_DROP; goto out; } res->res_fsstat3.status = nfs3_Errno(cache_status); rc = NFS_REQ_OK; out: /* return references */ if (entry) cache_inode_put(entry); return rc; } /* nfs3_fsstat */
/** * * cache_inode_getattr: Gets the attributes for a cached entry. * * Gets the attributes for a cached entry. The FSAL attributes are kept in a structure when the entry * is added to the cache. * * @param pentry [IN] entry to be managed. * @param pattr [OUT] pointer to the results * @param ht [IN] hash table used for the cache, unused in this call. * @param pclient [INOUT] ressource allocated by the client for the nfs management. * @param pcontext [IN] FSAL credentials * @param pstatus [OUT] returned status. * * @return CACHE_INODE_SUCCESS if operation is a success \n * @return CACHE_INODE_LRU_ERROR if allocation error occured when validating the entry * */ cache_inode_status_t cache_inode_getattr(cache_entry_t * pentry, fsal_attrib_list_t * pattr, hash_table_t * ht, /* Unused, kept for protototype's homogeneity */ cache_inode_client_t * pclient, fsal_op_context_t * pcontext, cache_inode_status_t * pstatus) { cache_inode_status_t status; fsal_handle_t *pfsal_handle = NULL; fsal_status_t fsal_status; /* sanity check */ if(pentry == NULL || pattr == NULL || ht == NULL || pclient == NULL || pcontext == NULL) { *pstatus = CACHE_INODE_INVALID_ARGUMENT; LogDebug(COMPONENT_CACHE_INODE, "cache_inode_getattr: returning CACHE_INODE_INVALID_ARGUMENT because of bad arg"); return *pstatus; } /* Set the return default to CACHE_INODE_SUCCESS */ *pstatus = CACHE_INODE_SUCCESS; /* stats */ pclient->stat.nb_call_total += 1; inc_func_call(pclient, CACHE_INODE_GETATTR); /* Lock the entry */ P_w(&pentry->lock); status = cache_inode_renew_entry(pentry, pattr, ht, pclient, pcontext, pstatus); if(status != CACHE_INODE_SUCCESS) { V_w(&pentry->lock); inc_func_err_retryable(pclient, CACHE_INODE_GETATTR); LogFullDebug(COMPONENT_CACHE_INODE, "cache_inode_getattr: returning %d(%s) from cache_inode_renew_entry", *pstatus, cache_inode_err_str(*pstatus)); return *pstatus; } /* RW Lock goes for writer to reader */ rw_lock_downgrade(&pentry->lock); cache_inode_get_attributes(pentry, pattr); if(FSAL_TEST_MASK(pattr->asked_attributes, FSAL_ATTR_RDATTR_ERR)) { switch (pentry->internal_md.type) { case REGULAR_FILE: pfsal_handle = &pentry->object.file.handle; break; case SYMBOLIC_LINK: assert(pentry->object.symlink); pfsal_handle = &pentry->object.symlink->handle; break; case DIR_BEGINNING: pfsal_handle = &pentry->object.dir_begin.handle; break; case DIR_CONTINUE: /* * lock the related dir_begin (dir begin are garbagge * collected AFTER their related dir_cont) * this means that if a DIR_CONTINUE exists, * its pdir pointer is not endless */ P_r(&pentry->object.dir_cont.pdir_begin->lock); pfsal_handle = &pentry->object.dir_cont.pdir_begin->object.dir_begin.handle; V_r(&pentry->object.dir_cont.pdir_begin->lock); break; case SOCKET_FILE: case FIFO_FILE: case BLOCK_FILE: case CHARACTER_FILE: pfsal_handle = &pentry->object.special_obj.handle; break; case FS_JUNCTION: case UNASSIGNED: case RECYCLED: *pstatus = CACHE_INODE_INVALID_ARGUMENT; LogFullDebug(COMPONENT_CACHE_INODE, "cache_inode_getattr: returning %d(%s) from cache_inode_renew_entry - unexpected md_type", *pstatus, cache_inode_err_str(*pstatus)); return *pstatus; } /* * An error occured when trying to get * the attributes, they have to be renewed */ #ifdef _USE_MFSL fsal_status = FSAL_getattrs_descriptor(&(cache_inode_fd(pentry)->fsal_file), pfsal_handle, pcontext, pattr); #else fsal_status = FSAL_getattrs_descriptor(cache_inode_fd(pentry), pfsal_handle, pcontext, pattr); #endif if(FSAL_IS_ERROR(fsal_status)) { *pstatus = cache_inode_error_convert(fsal_status); V_r(&pentry->lock); if(fsal_status.major == ERR_FSAL_STALE) { cache_inode_status_t kill_status; LogEvent(COMPONENT_CACHE_INODE, "cache_inode_getattr: Stale FSAL File Handle detected for pentry = %p", pentry); cache_inode_kill_entry(pentry, ht, pclient, &kill_status); if(kill_status != CACHE_INODE_SUCCESS) LogCrit(COMPONENT_CACHE_INODE, "cache_inode_getattr: Could not kill entry %p, status = %u", pentry, kill_status); *pstatus = CACHE_INODE_FSAL_ESTALE; } /* stat */ inc_func_err_unrecover(pclient, CACHE_INODE_GETATTR); LogDebug(COMPONENT_CACHE_INODE, "cache_inode_getattr: returning %d(%s) from FSAL_getattrs_descriptor", *pstatus, cache_inode_err_str(*pstatus)); return *pstatus; } /* Set the new attributes */ cache_inode_set_attributes(pentry, pattr); } *pstatus = cache_inode_valid(pentry, CACHE_INODE_OP_GET, pclient); V_r(&pentry->lock); /* stat */ if(*pstatus != CACHE_INODE_SUCCESS) inc_func_err_retryable(pclient, CACHE_INODE_GETATTR); else inc_func_success(pclient, CACHE_INODE_GETATTR); #ifdef _USE_NFS4_ACL if(isDebug(COMPONENT_NFS_V4_ACL)) { LogDebug(COMPONENT_CACHE_INODE, "cache_inode_getattr: pentry = %p, acl = %p", pentry, pattr->acl); if(pattr->acl) { fsal_ace_t *pace; for(pace = pattr->acl->aces; pace < pattr->acl->aces + pattr->acl->naces; pace++) { LogDebug(COMPONENT_CACHE_INODE, "cache_inode_getattr: ace type = 0x%x, flag = 0x%x, perm = 0x%x, special = %d, %s = 0x%x", pace->type, pace->flag, pace->perm, IS_FSAL_ACE_SPECIAL_ID(*pace), GET_FSAL_ACE_WHO_TYPE(*pace), GET_FSAL_ACE_WHO(*pace)); } } } #endif /* _USE_NFS4_ACL */ LogFullDebug(COMPONENT_CACHE_INODE, "cache_inode_getattr: returning %d(%s) from cache_inode_valid", *pstatus, cache_inode_err_str(*pstatus)); return *pstatus; }
void PlaylistEntryBrightness::Dump(void) { LogDebug(VB_PLAYLIST, "Brightness: %d\n", m_brightness); }
fsal_status_t ZFSFSAL_symlink(fsal_handle_t * parent_directory_handle, /* IN */ fsal_name_t * p_linkname, /* IN */ fsal_path_t * p_linkcontent, /* IN */ fsal_op_context_t * p_context, /* IN */ fsal_accessmode_t accessmode, /* IN (ignored) */ fsal_handle_t * link_handle, /* OUT */ fsal_attrib_list_t * link_attributes /* [ IN/OUT ] */ ) { creden_t cred; /* sanity checks. * note : link_attributes is optional. */ if(!parent_directory_handle || !p_context || !link_handle || !p_linkname || !p_linkcontent) Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_symlink); /* Tests if symlinking is allowed by configuration. */ if(!global_fs_info.symlink_support) Return(ERR_FSAL_NOTSUPP, 0, INDEX_FSAL_symlink); /* Hook to prevent creation of anything inside the snapshot */ if(((zfsfsal_handle_t *)parent_directory_handle)->data.i_snap != 0) { LogDebug(COMPONENT_FSAL, "Trying to create a symlink inside a snapshot"); Return(ERR_FSAL_ROFS, 0, INDEX_FSAL_symlink); } cred.uid = p_context->credential.user; cred.gid = p_context->credential.group; TakeTokenFSCall(); inogen_t object; libzfswrap_symlink(((zfsfsal_op_context_t *)p_context)->export_context->p_vfs, &cred, ((zfsfsal_handle_t *)parent_directory_handle)->data.zfs_handle, p_linkname->name, p_linkcontent->path, &object); ReleaseTokenFSCall(); /* >> convert status and return on error << */ /* >> set output handle << */ ((zfsfsal_handle_t *)link_handle)->data.zfs_handle = object; ((zfsfsal_handle_t *)link_handle)->data.type = FSAL_TYPE_LNK; ((zfsfsal_handle_t *)link_handle)->data.i_snap = 0; if(link_attributes) { fsal_status_t status = ZFSFSAL_getattrs(link_handle, p_context, link_attributes); /* On error, we set a flag in the returned attributes */ if(FSAL_IS_ERROR(status)) { FSAL_CLEAR_MASK(link_attributes->asked_attributes); FSAL_SET_MASK(link_attributes->asked_attributes, FSAL_ATTR_RDATTR_ERR); } } /* OK */ Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_symlink); }
void levelInit() { arx_assert(entities.player()); LogDebug("Initializing level ..."); g_requestLevelInit = true; ARX_PARTICLES_FirstInit(); RenderBatcher::getInstance().reset(); progressBarAdvance(2.f); LoadLevelScreen(); if(!pParticleManager) pParticleManager = new ParticleManager(); if(GMOD_RESET) ARX_GLOBALMODS_Reset(); GMOD_RESET = true; STARTDRAG = Vec2s_ZERO; DANAEMouse = Vec2s_ZERO; bookclick = false; if(LOAD_N_ERASE) arxtime.init(); ARX_BOOMS_ClearAllPolyBooms(); ARX_DAMAGES_Reset(); ARX_MISSILES_ClearAll(); spells.clearAll(); ARX_SPELLS_ClearAllSymbolDraw(); ARX_PARTICLES_ClearAll(); if(LOAD_N_ERASE) { CleanScriptLoadedIO(); RestoreInitialIOStatus(); DRAGINTER=NULL; } ARX_SPELLS_ResetRecognition(); eyeball.exist=0; for(size_t i = 0; i < MAX_DYNLIGHTS; i++) { lightHandleGet((LightHandle)i)->exist = 0; } arxtime.update_last_frame_time(); if(LOAD_N_ERASE) { CleanInventory(); ARX_SCRIPT_Timer_ClearAll(); UnlinkAllLinkedObjects(); ARX_SCRIPT_ResetAll(false); } SecondaryInventory=NULL; TSecondaryInventory=NULL; ARX_FOGS_Render(); if(LOAD_N_ERASE) { arxtime.init(); if(!DONT_ERASE_PLAYER) ARX_PLAYER_InitPlayer(); playerInterfaceFaderResetSlid(); player.lifePool.current = player.lifePool.max; player.manaPool.current = player.manaPool.max; if(!DONT_ERASE_PLAYER) { ARX_PLAYER_MakeFreshHero(); } } InitSnapShot(fs::paths.user / "snapshot"); if(FASTmse) { FASTmse = 0; if(LOADEDD) { Vec3f trans = Mscenepos; player.pos = loddpos + trans; } else { player.pos.y += player.baseHeight(); } progressBarAdvance(4.f); LoadLevelScreen(); } #if BUILD_EDIT_LOADSAVE else if(mse) { Mscenepos.x=-mse->cub.xmin-(mse->cub.xmax-mse->cub.xmin)*.5f+((float)ACTIVEBKG->Xsize*(float)ACTIVEBKG->Xdiv)*.5f; Mscenepos.z=-mse->cub.zmin-(mse->cub.zmax-mse->cub.zmin)*.5f+((float)ACTIVEBKG->Zsize*(float)ACTIVEBKG->Zdiv)*.5f; float t1=(float)(long)(mse->point0.x/BKG_SIZX); float t2=(float)(long)(mse->point0.z/BKG_SIZZ); t1=mse->point0.x-t1*BKG_SIZX; t2=mse->point0.z-t2*BKG_SIZZ; Mscenepos.x=(float)((long)(Mscenepos.x/BKG_SIZX))*BKG_SIZX+(float)BKG_SIZX*.5f; Mscenepos.z=(float)((long)(Mscenepos.z/BKG_SIZZ))*BKG_SIZZ+(float)BKG_SIZZ*.5f; mse->pos.x=Mscenepos.x=Mscenepos.x+BKG_SIZX-t1; mse->pos.z=Mscenepos.z=Mscenepos.z+BKG_SIZZ-t2; Mscenepos.y=mse->pos.y=-mse->cub.ymin-100.f-mse->point0.y; if (PLAYER_POSITION_RESET) { player.pos.x = mse->pos.x+mse->point0.x; player.pos.z = mse->pos.z+mse->point0.z; player.pos.y = mse->pos.y+mse->point0.y; } EERIERemovePrecalcLights(); progressBarAdvance(); LoadLevelScreen(); SceneAddMultiScnToBackground(mse); progressBarAdvance(2.f); LoadLevelScreen(); Vec3f trans = mse->pos; ReleaseMultiScene(mse); mse=NULL; if(PLAYER_POSITION_RESET) { if(LOADEDD) { player.pos = loddpos + trans; } else { player.pos.y += player.baseHeight(); } } PLAYER_POSITION_RESET = true; progressBarAdvance(); LoadLevelScreen(); } #endif // BUILD_EDIT_LOADSAVE else { progressBarAdvance(4.f); LoadLevelScreen(); } if(player.torch) { ARX_SOUND_PlaySFX(SND_TORCH_LOOP, NULL, 1.0F, ARX_SOUND_PLAY_LOOPED); } MagicFlareSetCamera(&subj); lastteleport = player.basePosition(); subj.orgTrans.pos = moveto = player.pos; subj.angle = player.angle; RestoreLastLoadedLightning(*ACTIVEBKG); progressBarAdvance(); LoadLevelScreen(); if(LOAD_N_ERASE) SetEditMode(0); progressBarAdvance(); LoadLevelScreen(); LOAD_N_ERASE = true; DONT_ERASE_PLAYER=0; progressBarAdvance(); LoadLevelScreen(); g_requestLevelInit = false; PrepareIOTreatZone(1); CURRENTLEVEL=GetLevelNumByName(LastLoadedScene.string()); if(TIME_INIT) arxtime.init(); arxtime.update_last_frame_time(); progressBarAdvance(); LoadLevelScreen(); if(DONT_WANT_PLAYER_INZONE) { player.inzone = NULL; DONT_WANT_PLAYER_INZONE = 0; } progressBarAdvance(); LoadLevelScreen(); player.desiredangle.setYaw(0.f); player.angle.setYaw(0.f); ARX_PLAYER_RectifyPosition(); entities.player()->_npcdata->vvpos = -99999; SendGameReadyMsg(); PLAYER_MOUSELOOK_ON = false; player.Interface &= ~INTER_NOTE; if(!TIME_INIT) { arxtime.force_time_restore(FORCE_TIME_RESTORE); arxtime.force_frame_time_restore(FORCE_TIME_RESTORE); } else { arxtime.resume(); } EntityHandle t = entities.getById("seat_stool1_0012"); if(ValidIONum(t)) { entities[t]->ioflags |= IO_FORCEDRAW; } if(WILL_RESTORE_PLAYER_POSITION_FLAG) { Entity * io = entities.player(); player.pos = WILL_RESTORE_PLAYER_POSITION; io->pos = player.basePosition(); for(size_t i = 0; i < io->obj->vertexlist.size(); i++) { io->obj->vertexlist3[i].v = io->obj->vertexlist[i].v + io->pos; } WILL_RESTORE_PLAYER_POSITION_FLAG = 0; } ARX_NPC_RestoreCuts(); ResetVVPos(entities.player()); progressBarAdvance(); LoadLevelScreen(); LoadLevelScreen(-2); if ( (!CheckInPoly(player.pos)) && (LastValidPlayerPos.x!=0.f) && (LastValidPlayerPos.y!=0.f) && (LastValidPlayerPos.z!=0.f)) { player.pos = LastValidPlayerPos; } LastValidPlayerPos = player.pos; }
int nfs_ip_name_add(sockaddr_t *ipaddr, char *hostname, size_t size) { struct gsh_buffdesc buffkey; struct gsh_buffdesc buffdata; nfs_ip_name_t *nfs_ip_name = NULL; sockaddr_t *pipaddr = NULL; struct timeval tv0, tv1, dur; int rc; char ipstring[SOCK_NAME_MAX + 1]; nfs_ip_name = gsh_malloc(sizeof(nfs_ip_name_t)); pipaddr = gsh_malloc(sizeof(sockaddr_t)); /* I have to keep an integer as key, I wil use the pointer buffkey->addr * for this, this also means that buffkey->len will be 0 */ memcpy(pipaddr, ipaddr, sizeof(sockaddr_t)); buffkey.addr = pipaddr; buffkey.len = sizeof(sockaddr_t); gettimeofday(&tv0, NULL); rc = getnameinfo((struct sockaddr *)pipaddr, sizeof(sockaddr_t), nfs_ip_name->hostname, sizeof(nfs_ip_name->hostname), NULL, 0, 0); gettimeofday(&tv1, NULL); timersub(&tv1, &tv0, &dur); sprint_sockip(pipaddr, ipstring, sizeof(ipstring)); /* display warning if DNS resolution took more that 1.0s */ if (dur.tv_sec >= 1) { LogEvent(COMPONENT_DISPATCH, "Warning: long DNS query for %s: %u.%06u sec", ipstring, (unsigned int)dur.tv_sec, (unsigned int)dur.tv_usec); } /* Ask for the name to be cached */ if (rc != 0) { strmaxcpy(nfs_ip_name->hostname, ipstring, sizeof(nfs_ip_name->hostname)); LogEvent(COMPONENT_DISPATCH, "Cannot resolve address %s, error %s, using %s as hostname", ipstring, gai_strerror(rc), nfs_ip_name->hostname); } LogDebug(COMPONENT_DISPATCH, "Inserting %s->%s to addr cache", ipstring, nfs_ip_name->hostname); /* I build the data with the request pointer * that should be in state 'IN USE' */ nfs_ip_name->timestamp = time(NULL); buffdata.addr = nfs_ip_name; buffdata.len = sizeof(nfs_ip_name_t); if (HashTable_Set(ht_ip_name, &buffkey, &buffdata) != HASHTABLE_SUCCESS) return IP_NAME_INSERT_MALLOC_ERROR; /* Copy the value for the caller */ strmaxcpy(hostname, nfs_ip_name->hostname, size); return IP_NAME_SUCCESS; } /* nfs_ip_name_add */
static fsal_status_t fsal_check_access_acl(fsal_op_context_t * p_context, /* IN */ fsal_aceperm_t v4mask, /* IN */ fsal_attrib_list_t * p_object_attributes /* IN */ ) { fsal_aceperm_t missing_access; fsal_uid_t uid; fsal_gid_t gid; fsal_acl_t *pacl = NULL; fsal_ace_t *pace = NULL; int ace_number = 0; fsal_boolean_t is_dir = FALSE; fsal_boolean_t is_owner = FALSE; fsal_boolean_t is_group = FALSE; /* unsatisfied flags */ missing_access = v4mask; if(!missing_access) { LogDebug(COMPONENT_FSAL, "fsal_check_access_acl: Nothing was requested"); ReturnCode(ERR_FSAL_NO_ERROR, 0); } /* Get file ownership information. */ uid = p_object_attributes->owner; gid = p_object_attributes->group; pacl = p_object_attributes->acl; is_dir = (p_object_attributes->type == FSAL_TYPE_DIR); LogDebug(COMPONENT_FSAL, "fsal_check_access_acl: file acl=%p, file uid=%d, file gid= %d", pacl,uid, gid); LogDebug(COMPONENT_FSAL, "fsal_check_access_acl: user uid=%d, user gid= %d, v4mask=0x%X", p_context->credential.user, p_context->credential.group, v4mask); is_owner = fsal_check_ace_owner(uid, p_context); is_group = fsal_check_ace_group(gid, p_context); /* Always grant READ_ACL, WRITE_ACL and READ_ATTR, WRITE_ATTR to the file * owner. */ if(is_owner) { missing_access &= ~(FSAL_ACE_PERM_WRITE_ACL | FSAL_ACE_PERM_READ_ACL); missing_access &= ~(FSAL_ACE_PERM_WRITE_ATTR | FSAL_ACE_PERM_READ_ATTR); if(!missing_access) { LogDebug(COMPONENT_FSAL, "fsal_check_access_acl: Met owner privileges"); ReturnCode(ERR_FSAL_NO_ERROR, 0); } } // TODO: Even if user is admin, audit/alarm checks should be done. ace_number = 1; for(pace = pacl->aces; pace < pacl->aces + pacl->naces; pace++) { LogDebug(COMPONENT_FSAL, "fsal_check_access_acl: ace type 0x%X perm 0x%X flag 0x%X who %d", pace->type, pace->perm, pace->flag, GET_FSAL_ACE_WHO(*pace)); /* Process Allow and Deny entries. */ if(IS_FSAL_ACE_ALLOW(*pace) || IS_FSAL_ACE_DENY(*pace)) { LogDebug(COMPONENT_FSAL, "fsal_check_access_acl: allow or deny"); /* Check if this ACE is applicable. */ if(fsal_check_ace_applicable(pace, p_context, is_dir, is_owner, is_group)) { if(IS_FSAL_ACE_ALLOW(*pace)) { LogDebug(COMPONENT_FSAL, "fsal_check_access_acl: allow perm 0x%X remainingPerms 0x%X", pace->perm, missing_access); missing_access &= ~(pace->perm & missing_access); if(!missing_access) { LogDebug(COMPONENT_FSAL, "fsal_check_access_acl: access granted"); fsal_print_access_by_acl(pacl->naces, ace_number, pace, v4mask, ERR_FSAL_NO_ERROR, is_dir, p_context); ReturnCode(ERR_FSAL_NO_ERROR, 0); } } else if(pace->perm & missing_access) { LogDebug(COMPONENT_FSAL, "fsal_check_access_acl: access denied"); fsal_print_access_by_acl(pacl->naces, ace_number, pace, v4mask, ERR_FSAL_ACCESS, is_dir, p_context); ReturnCode(ERR_FSAL_ACCESS, 0); } } } ace_number += 1; } if(missing_access) { LogDebug(COMPONENT_FSAL, "fsal_check_access_acl: access denied"); ReturnCode(ERR_FSAL_ACCESS, 0); } else { LogDebug(COMPONENT_FSAL, "fsal_check_access_acl: access granted"); ReturnCode(ERR_FSAL_NO_ERROR, 0); } ReturnCode(ERR_FSAL_NO_ERROR, 0); }
void ClientGame::OnNotification(Protocol::NotificationPacket& packet) { LogDebug("Notification: %d", packet.notification); m_notificationLog.AddNotification(m_time, packet); }
static fsal_status_t fsal_check_access_no_acl(fsal_op_context_t * p_context, /* IN */ fsal_accessflags_t access_type, /* IN */ struct stat *p_buffstat, /* IN */ fsal_attrib_list_t * p_object_attributes /* IN */ ) { fsal_accessflags_t missing_access; unsigned int is_grp, i; fsal_uid_t uid; fsal_gid_t gid; fsal_accessmode_t mode; /* If the FSAL_F_OK flag is set, returns ERR INVAL */ if(access_type & FSAL_F_OK) ReturnCode(ERR_FSAL_INVAL, 0); /* unsatisfied flags */ missing_access = access_type; if(!missing_access) { LogDebug(COMPONENT_FSAL, "fsal_check_access_no_acl: Nothing was requested"); ReturnCode(ERR_FSAL_NO_ERROR, 0); } if(p_object_attributes) { uid = p_object_attributes->owner; gid = p_object_attributes->group; mode = p_object_attributes->mode; } else { uid = p_buffstat->st_uid; gid = p_buffstat->st_gid; mode = unix2fsal_mode(p_buffstat->st_mode); } LogDebug(COMPONENT_FSAL, "fsal_check_access_no_acl: file Mode=%#o, file uid=%d, file gid= %d", mode,uid, gid); #ifdef _USE_HPSS LogDebug(COMPONENT_FSAL, "fsal_check_access_no_acl: user uid=%d, user gid= %d, access_type=0X%x", p_context->credential.hpss_usercred.Uid, p_context->credential.hpss_usercred.Gid, access_type); #else LogDebug(COMPONENT_FSAL, "fsal_check_access_no_acl: user uid=%d, user gid= %d, access_type=0X%x", p_context->credential.user, p_context->credential.group, access_type); #endif /* If the uid of the file matches the uid of the user, * then the uid mode bits take precedence. */ #ifdef _USE_HPSS if(p_context->credential.hpss_usercred.Uid == uid) #else if(p_context->credential.user == uid) #endif { LogDebug(COMPONENT_FSAL, "fsal_check_access_no_acl: File belongs to user %d", uid); if(mode & FSAL_MODE_RUSR) missing_access &= ~FSAL_R_OK; if(mode & FSAL_MODE_WUSR) missing_access &= ~FSAL_W_OK; if(mode & FSAL_MODE_XUSR) missing_access &= ~FSAL_X_OK; /* handle the creation of a new 500 file correctly */ if((missing_access & FSAL_OWNER_OK) != 0) missing_access = 0; if(missing_access == 0) ReturnCode(ERR_FSAL_NO_ERROR, 0); else { LogDebug(COMPONENT_FSAL, "fsal_check_access_no_acl: Mode=%#o, Access=0X%x, Rights missing: 0X%x", mode, access_type, missing_access); ReturnCode(ERR_FSAL_ACCESS, 0); } } /* missing_access will be nonzero triggering a failure * even though FSAL_OWNER_OK is not even a real posix file * permission */ missing_access &= ~FSAL_OWNER_OK; /* Test if the file belongs to user's group. */ #ifdef _USE_HPSS is_grp = (p_context->credential.hpss_usercred.Gid == gid); if(is_grp) LogDebug(COMPONENT_FSAL, "fsal_check_access_no_acl: File belongs to user's group %d", p_context->credential.hpss_usercred.Gid); /* Test if file belongs to alt user's groups */ if(!is_grp) for(i = 0; i < p_context->credential.hpss_usercred.NumGroups; i++) { is_grp = (p_context->credential.hpss_usercred.AltGroups[i] == gid); if(is_grp) LogDebug(COMPONENT_FSAL, "fsal_check_access_no_acl: File belongs to user's alt group %d", p_context->credential.hpss_usercred.AltGroups[i]); if(is_grp) break; } #else is_grp = (p_context->credential.group == gid); if(is_grp) LogDebug(COMPONENT_FSAL, "fsal_check_access_no_acl: File belongs to user's group %d", p_context->credential.group); /* Test if file belongs to alt user's groups */ if(!is_grp) for(i = 0; i < p_context->credential.nbgroups; i++) { is_grp = (p_context->credential.alt_groups[i] == gid); if(is_grp) LogDebug(COMPONENT_FSAL, "fsal_check_access_no_acl: File belongs to user's alt group %d", p_context->credential.alt_groups[i]); if(is_grp) break; } #endif /* If the gid of the file matches the gid of the user or * one of the alternatve gids of the user, then the uid mode * bits take precedence. */ if(is_grp) { if(mode & FSAL_MODE_RGRP) missing_access &= ~FSAL_R_OK; if(mode & FSAL_MODE_WGRP) missing_access &= ~FSAL_W_OK; if(mode & FSAL_MODE_XGRP) missing_access &= ~FSAL_X_OK; if(missing_access == 0) ReturnCode(ERR_FSAL_NO_ERROR, 0); else ReturnCode(ERR_FSAL_ACCESS, 0); } /* If the user uid is not 0, the uid does not match the file's, and * the user's gids do not match the file's gid, we apply the "other" * mode bits to the user. */ if(mode & FSAL_MODE_ROTH) missing_access &= ~FSAL_R_OK; if(mode & FSAL_MODE_WOTH) missing_access &= ~FSAL_W_OK; if(mode & FSAL_MODE_XOTH) missing_access &= ~FSAL_X_OK; if(missing_access == 0) ReturnCode(ERR_FSAL_NO_ERROR, 0); else { LogDebug(COMPONENT_FSAL, "fsal_check_access_no_acl: Mode=%#o, Access=0X%x, Rights missing: 0X%x", mode, access_type, missing_access); ReturnCode(ERR_FSAL_ACCESS, 0); } }
void CDeMultiplexer::HandleBDEvent(BD_EVENT& pEv) { switch (pEv.event) { case BD_EVENT_ERROR: case BD_EVENT_READ_ERROR: m_bEndOfFile = true; m_filter.NotifyEvent(EC_ERRORABORT, 0, 0); break; case BD_EVENT_ENCRYPTED: m_bEndOfFile = true; m_filter.NotifyEvent(EC_ERRORABORT, STG_E_STATUS_COPY_PROTECTION_FAILURE, 0); break; case BD_EVENT_PLAYLIST_STOP: Flush(true); m_bLibRequestedFlush = true; break; case BD_EVENT_SEEK: Flush(true); break; case BD_EVENT_STILL_TIME: m_bStreamPaused = true; break; case BD_EVENT_STILL: if (pEv.param == 1) m_bStreamPaused = true; break; case BD_EVENT_TITLE: m_bTitleChanged = true; m_nTitle = pEv.param; m_filter.GetTime(&m_rtTitleChangeStarted); break; case BD_EVENT_PLAYLIST: m_nPlaylist = pEv.param; break; case BD_EVENT_AUDIO_STREAM: if (!m_filter.lib.ForceTitleBasedPlayback() && pEv.param < 0xff) { m_iAudioIdx = pEv.param - 1; ParseAudioStreams(m_filter.lib.CurrentClipInfo()); m_bAudioFormatParsed = false; } break; case BD_EVENT_PG_TEXTST_STREAM: break; case BD_EVENT_PLAYITEM: LogDebug("demux: New playitem %d", pEv.param); m_bFlushBuffersOnPause = true; UINT64 clipStart = 0, clipIn = 0, bytePos = 0, duration = 0; int ret = m_filter.lib.GetClipInfo(pEv.param, &clipStart, &clipIn, &bytePos, &duration); if (ret) { REFERENCE_TIME rtOldOffset = m_rtOffset; m_rtOffset = clipStart - clipIn; m_nClip = pEv.param; BLURAY_CLIP_INFO* clip = m_filter.lib.CurrentClipInfo(); if (!clip) { LogDebug("demux: HandleBDEvent - failed to get clip info!"); return; } UINT64 position = 0; m_filter.lib.CurrentPosition(position, (UINT64&)m_rtTitleDuration); m_rtTitleDuration = CONVERT_90KHz_DS(m_rtTitleDuration); //if (!m_bStarting) { REFERENCE_TIME clipOffset = m_rtOffset * -1; FlushPESBuffers(false, false); m_playlistManager->CreateNewPlaylistClip(m_nPlaylist, m_nClip, AudioStreamsAvailable(clip), CONVERT_90KHz_DS(clipIn), CONVERT_90KHz_DS(clipOffset), CONVERT_90KHz_DS(duration), CONVERT_90KHz_DS(position), m_bLibRequestedFlush); if (m_bLibRequestedFlush) { m_playlistManager->ClearClips(); CVideoPin* pVideoPin = m_filter.GetVideoPin(); if (pVideoPin) pVideoPin->SyncClipBoundary(); } m_bLibRequestedFlush = false; } m_bVideoFormatParsed = false; m_bAudioFormatParsed = false; ParseVideoStream(clip); ParseAudioStreams(clip); ParseSubtitleStreams(clip); } } }
void *file_content_gc_thread(void *IndexArg) { char command[2 * MAXPATHLEN]; exportlist_t *pexport = NULL; int is_hw_reached = FALSE; int some_flush_to_do = FALSE; unsigned long nb_blocks_to_manage; char cache_sub_dir[MAXPATHLEN]; cache_content_status_t cache_content_status; FILE *command_stream = NULL; char logfile_arg[MAXPATHLEN]; char *loglevel_arg; SetNameFunction("file_content_gc_thread"); LogEvent(COMPONENT_MAIN, "NFS FILE CONTENT GARBAGE COLLECTION : Starting GC thread"); if(mark_thread_existing(&gccb) == PAUSE_EXIT) { /* Oops, that didn't last long... exit. */ mark_thread_done(&gccb); LogDebug(COMPONENT_DISPATCH, "NFS FILE CONTENT GARBAGE COLLECTION Thread exiting before initialization"); return NULL; } LogDebug(COMPONENT_MAIN, "NFS FILE CONTENT GARBAGE COLLECTION : my pthread id is %p", (caddr_t) pthread_self()); while(1) { /* Sleep until some work is to be done */ sleep(nfs_param.cache_layers_param.dcgcpol.run_interval); if(gccb.tcb_state != STATE_AWAKE) { while(1) { P(gccb.tcb_mutex); if(gccb.tcb_state == STATE_AWAKE) { V(gccb.tcb_mutex); break; } switch(thread_sm_locked(&gccb)) { case THREAD_SM_RECHECK: V(gccb.tcb_mutex); continue; case THREAD_SM_BREAK: V(gccb.tcb_mutex); break; case THREAD_SM_EXIT: V(gccb.tcb_mutex); return NULL; } } } LogEvent(COMPONENT_MAIN, "NFS FILE CONTENT GARBAGE COLLECTION : processing..."); for(pexport = nfs_param.pexportlist; pexport != NULL; pexport = pexport->next) { if(pexport->options & EXPORT_OPTION_USE_DATACACHE) { snprintf(cache_sub_dir, MAXPATHLEN, "%s/export_id=%d", nfs_param.cache_layers_param.cache_content_client_param.cache_dir, 0); if((cache_content_status = cache_content_check_threshold(cache_sub_dir, nfs_param. cache_layers_param. dcgcpol.lwmark_df, nfs_param. cache_layers_param. dcgcpol.hwmark_df, &is_hw_reached, &nb_blocks_to_manage)) == CACHE_CONTENT_SUCCESS) { if(is_hw_reached) { LogEvent(COMPONENT_MAIN, "NFS FILE CONTENT GARBAGE COLLECTION : High Water Mark is reached, %lu blocks to be removed", nb_blocks_to_manage); some_flush_to_do = TRUE; break; } else { LogEvent(COMPONENT_MAIN, "NFS FILE CONTENT GARBAGE COLLECTION : High Water Mark is not reached"); } /* Use signal management */ if(force_flush_by_signal == TRUE) { some_flush_to_do = TRUE; break; } } } } /* for */ if (strncmp(fcc_log_path, "/dev/null", 9) == 0) switch(LogComponents[COMPONENT_CACHE_INODE_GC].comp_log_type) { case FILELOG: strncpy(logfile_arg, LogComponents[COMPONENT_CACHE_INODE_GC].comp_log_file, MAXPATHLEN); break; case SYSLOG: strncpy(logfile_arg, "SYSLOG", MAXPATHLEN); break; case STDERRLOG: strncpy(logfile_arg, "STDERRLOG", MAXPATHLEN); break; case STDOUTLOG: strncpy(logfile_arg, "STDOUTLOG", MAXPATHLEN); break; default: LogCrit(COMPONENT_MAIN, "Could not figure out the proper -L option for emergency cache flush thread."); } else strncpy(logfile_arg, fcc_log_path, MAXPATHLEN); /* config variable */ if(fcc_debug_level != -1) /* config variable */ loglevel_arg = ReturnLevelInt(fcc_debug_level); else loglevel_arg = ReturnLevelInt(ReturnLevelComponent(COMPONENT_CACHE_INODE_GC)); snprintf(command, 2 * MAXPATHLEN, "%s -f %s -N %s -L %s", ganesha_exec_path, config_path, loglevel_arg, logfile_arg); if(some_flush_to_do) strncat(command, " -P 3", 2 * MAXPATHLEN); /* Sync and erase */ else strncat(command, " -S 3", 2 * MAXPATHLEN); /* Sync Only */ if((command_stream = popen(command, "r")) == NULL) LogCrit(COMPONENT_MAIN, "NFS FILE CONTENT GARBAGE COLLECTION : /!\\ Cannot lauch command %s", command); else LogEvent(COMPONENT_MAIN, "NFS FILE CONTENT GARBAGE COLLECTION : I launched command %s", command); pclose(command_stream); } tcb_remove(&gccb); } /* file_content_gc_thread */
int _9p_statfs(struct _9p_request_data *req9p, u32 *plenout, char *preply) { char *cursor = req9p->_9pmsg + _9P_HDR_SIZE + _9P_TYPE_SIZE; u16 *msgtag = NULL; u32 *fid = NULL; struct _9p_fid *pfid = NULL; u32 type = 0x01021997; /* V9FS_MAGIC */ u32 bsize = 1; /* cache_inode_statfs and * FSAL already care for blocksize */ u64 *blocks = NULL; u64 *bfree = NULL; u64 *bavail = NULL; u64 *files = NULL; u64 *ffree = NULL; u64 fsid = 0LL; u32 namelen = MAXNAMLEN; fsal_dynamicfsinfo_t dynamicinfo; cache_inode_status_t cache_status; /* Get data */ _9p_getptr(cursor, msgtag, u16); _9p_getptr(cursor, fid, u32); LogDebug(COMPONENT_9P, "TSTATFS: tag=%u fid=%u", (u32) *msgtag, *fid); if (*fid >= _9P_FID_PER_CONN) return _9p_rerror(req9p, msgtag, ERANGE, plenout, preply); pfid = req9p->pconn->fids[*fid]; if (pfid == NULL) return _9p_rerror(req9p, msgtag, EINVAL, plenout, preply); _9p_init_opctx(pfid, req9p); /* Get the FS's stats */ cache_status = cache_inode_statfs(pfid->pentry, &dynamicinfo); if (cache_status != CACHE_INODE_SUCCESS) return _9p_rerror(req9p, msgtag, _9p_tools_errno(cache_status), plenout, preply); blocks = (u64 *) &dynamicinfo.total_bytes; bfree = (u64 *) &dynamicinfo.free_bytes; bavail = (u64 *) &dynamicinfo.avail_bytes; files = (u64 *) &dynamicinfo.total_files; ffree = (u64 *) &dynamicinfo.free_files; fsid = (u64) pfid->pentry->obj_handle->attrs->rawdev.major; /* Build the reply */ _9p_setinitptr(cursor, preply, _9P_RSTATFS); _9p_setptr(cursor, msgtag, u16); _9p_setvalue(cursor, type, u32); _9p_setvalue(cursor, bsize, u32); _9p_setptr(cursor, blocks, u64); _9p_setptr(cursor, bfree, u64); _9p_setptr(cursor, bavail, u64); _9p_setptr(cursor, files, u64); _9p_setptr(cursor, ffree, u64); _9p_setvalue(cursor, fsid, u64); _9p_setvalue(cursor, namelen, u32); _9p_setendptr(cursor, preply); _9p_checkbound(cursor, preply, plenout); LogDebug(COMPONENT_9P, "RSTATFS: tag=%u fid=%u", (u32) *msgtag, *fid); return 1; }
RocketStorageSceneImporter::RocketStorageSceneImporter(QWidget *parent, RocketPlugin *plugin, const QString &destinationPrefix, const SceneDesc &sceneDesc_, const ImportEntityItemList &entities_, const ImportAssetItemList &assets_) : QDialog(parent, Qt::SplashScreen), plugin_(plugin), destinationPrefix_(destinationPrefix), menu_(0), sceneDesc(sceneDesc_), entities(entities_), assets(assets_) { setAttribute(Qt::WA_DeleteOnClose, true); setWindowModality(Qt::ApplicationModal); setModal(true); ui.setupUi(this); hide(); #ifdef Q_WS_WIN // @bug Scrolling is broken on Mac if you have custom stylesheet to QTableWidgets; QString style("QTableView { border: 1px solid grey; font: 10px \"Arial\"; }"); ui.assets->setStyleSheet(style); ui.entities->setStyleSheet(style); #endif ui.assets->setSortingEnabled(false); ui.entities->setSortingEnabled(false); ui.assets->setVisible(false); ui.entities->setVisible(false); // Rewrite all asset refs to be relative "file.extension" from "local://file.extension" etc. QMutableListIterator<EntityDesc> edIt(sceneDesc.entities); while(edIt.hasNext()) { QMutableListIterator<ComponentDesc> cdIt(edIt.next().components); while(cdIt.hasNext()) { QMutableListIterator<AttributeDesc> adIt(cdIt.next().attributes); while(adIt.hasNext()) { adIt.next(); if ((adIt.value().typeName.compare(cAttributeAssetReferenceTypeName, Qt::CaseInsensitive) == 0) || (adIt.value().typeName.compare(cAttributeAssetReferenceListTypeName, Qt::CaseInsensitive) == 0)) { QString trimmed = adIt.value().value.trimmed(); if (trimmed.isEmpty() || trimmed == "RexSkyBox") continue; QStringList newValues; QStringList valueParts = adIt.value().value.split(";", QString::KeepEmptyParts); for(int i=0; i<valueParts.size(); ++i) { QString &value = valueParts[i]; if (value.trimmed().isEmpty()) newValues << ""; else { // Leave http refs alone if (!value.startsWith("http://") && !value.startsWith("https://")) { QString filename, subasset; AssetAPI::ParseAssetRef(value, 0, 0, 0, 0, 0, 0, &filename, &subasset); newValues << destinationPrefix_ + filename + (!subasset.isEmpty() ? "#" + subasset : ""); } else { LogDebug("Found web ref, leaving alone: " + value); newValues << value; } } } if (!newValues.isEmpty()) { QString newValue = newValues.join(";"); if (adIt.value().value != newValue) { foreach(const RocketStorageImportAssetItem &item, assets) { if (newValue == item.pathRelative) { newValue = item.desc.destinationName; break; } } //LogInfo("[RocketSceneImporter]: Rewriting asset reference from " + adIt.value().value + " to " + newValue); adIt.value().value = newValue; } } } }
/** * Generate predefined persistent channels and &SERVER */ GLOBAL void Channel_InitPredefined( void ) { CHANNEL *new_chan; const struct Conf_Channel *conf_chan; const char *c; size_t i, channel_count = array_length(&Conf_Channels, sizeof(*conf_chan)); conf_chan = array_start(&Conf_Channels); assert(channel_count == 0 || conf_chan != NULL); for (i = 0; i < channel_count; i++, conf_chan++) { if (!conf_chan->name[0]) continue; if (!Channel_IsValidName(conf_chan->name)) { Log(LOG_ERR, "Can't create pre-defined channel: invalid name: \"%s\"", conf_chan->name); continue; } new_chan = Channel_Search(conf_chan->name); if (new_chan) { Log(LOG_INFO, "Can't create pre-defined channel \"%s\": name already in use.", conf_chan->name); Set_KeyFile(new_chan, conf_chan->keyfile); continue; } new_chan = Channel_Create(conf_chan->name); if (!new_chan) { Log(LOG_ERR, "Can't create pre-defined channel \"%s\"!", conf_chan->name); continue; } Log(LOG_INFO, "Created pre-defined channel \"%s\".", conf_chan->name); Channel_ModeAdd(new_chan, 'P'); if (conf_chan->topic[0]) Channel_SetTopic(new_chan, NULL, conf_chan->topic); c = conf_chan->modes; while (*c) Channel_ModeAdd(new_chan, *c++); Channel_SetKey(new_chan, conf_chan->key); Channel_SetMaxUsers(new_chan, conf_chan->maxusers); Set_KeyFile(new_chan, conf_chan->keyfile); } if (channel_count) array_free(&Conf_Channels); /* Make sure the local &SERVER channel exists */ if (!Channel_Search("&SERVER")) { new_chan = Channel_Create("&SERVER"); if (new_chan) { Channel_SetModes(new_chan, "mnPt"); Channel_SetTopic(new_chan, Client_ThisServer(), "Server Messages"); } else Log(LOG_ERR, "Failed to create \"&SERVER\" channel!"); } else LogDebug("Required channel \"&SERVER\" already exists, ok."); } /* Channel_InitPredefined */
/** * @brief Copy file content. * * @param[in] src_entry File to copy from * @param[in] src_offset Offset start from the source file * @param[in] dst_entry Destination file to copy to * @param[in] dst_offset Offset in the dest file * @param[out] count Requested bytes to copy * @param[out] copied Bytes successfully copied * * @return CACHE_INODE_SUCCESS or various errors */ cache_inode_status_t cache_inode_copy(cache_entry_t *src_entry, uint64_t src_offset, cache_entry_t *dst_entry, uint64_t dst_offset, uint64_t count, uint64_t *copied) { fsal_status_t fsal_status = { 0, 0 }; cache_inode_status_t status; /** * To avoid deadlock, we always lock the entry with a smaller address * before the locking the other entry. Note that "content_lock" * protects "cache content" instead of file content. So only reader * lock is needed for either file. */ if ((size_t)src_entry < (size_t)dst_entry) { PTHREAD_RWLOCK_rdlock(&src_entry->content_lock); PTHREAD_RWLOCK_rdlock(&dst_entry->content_lock); } else { PTHREAD_RWLOCK_rdlock(&dst_entry->content_lock); PTHREAD_RWLOCK_rdlock(&src_entry->content_lock); } if (!is_open(src_entry) || !is_open(dst_entry)) { LogEvent(COMPONENT_CACHE_INODE, "Cannot copy between files that are not open"); status = NFS4ERR_OPENMODE; goto out; } if (count == UINT64_MAX) { count = src_entry->obj_handle->attrs->filesize - src_offset; LogDebug(COMPONENT_CACHE_INODE, "0-count has an effective value of %zu", count); } fsal_status = src_entry->obj_handle->obj_ops.copy(src_entry->obj_handle, src_offset, dst_entry->obj_handle, dst_offset, count, copied); if (FSAL_IS_ERROR(fsal_status)) { *copied = 0; status = cache_inode_error_convert(fsal_status); LogEvent(COMPONENT_CACHE_INODE, "File copy failed: major = %d, minor = %d", fsal_status.major, fsal_status.minor); goto out; } /* Update dest file after coping to it. */ PTHREAD_RWLOCK_wrlock(&dst_entry->attr_lock); status = cache_inode_refresh_attrs(dst_entry); PTHREAD_RWLOCK_unlock(&dst_entry->attr_lock); out: if ((size_t)src_entry < (size_t)dst_entry) { PTHREAD_RWLOCK_unlock(&dst_entry->content_lock); PTHREAD_RWLOCK_unlock(&src_entry->content_lock); } else { PTHREAD_RWLOCK_unlock(&src_entry->content_lock); PTHREAD_RWLOCK_unlock(&dst_entry->content_lock); } return status; }
int nfs4_op_setclientid(struct nfs_argop4 *op, compound_data_t *data, struct nfs_resop4 *resp) { SETCLIENTID4args * const arg_SETCLIENTID4 = &op->nfs_argop4_u.opsetclientid; SETCLIENTID4res * const res_SETCLIENTID4 = &resp->nfs_resop4_u.opsetclientid; clientaddr4 * const res_SETCLIENTID4_INUSE = &resp->nfs_resop4_u.opsetclientid.SETCLIENTID4res_u.client_using; char str_verifier[NFS4_VERIFIER_SIZE * 2 + 1]; char str_client[NFS4_OPAQUE_LIMIT * 2 + 1]; char str_client_addr[SOCK_NAME_MAX + 1]; nfs_client_record_t *client_record; nfs_client_id_t *conf; nfs_client_id_t *unconf; clientid4 clientid; verifier4 verifier; sockaddr_t client_addr; int rc; resp->resop = NFS4_OP_SETCLIENTID; if (data->minorversion > 0) { res_SETCLIENTID4->status = NFS4ERR_NOTSUPP; return res_SETCLIENTID4->status; } copy_xprt_addr(&client_addr, data->req->rq_xprt); if (isDebug(COMPONENT_CLIENTID)) { sprint_sockip(&client_addr, str_client_addr, sizeof(str_client_addr)); DisplayOpaqueValue(arg_SETCLIENTID4->client.id.id_val, arg_SETCLIENTID4->client.id.id_len, str_client); sprint_mem(str_verifier, arg_SETCLIENTID4->client.verifier, NFS4_VERIFIER_SIZE); } LogDebug(COMPONENT_CLIENTID, "SETCLIENTID Client addr=%s id=%s verf=%s callback={program=%u r_addr=%s r_netid=%s} ident=%u", str_client_addr, str_client, str_verifier, arg_SETCLIENTID4->callback.cb_program, arg_SETCLIENTID4->callback.cb_location.r_addr, arg_SETCLIENTID4->callback.cb_location.r_netid, arg_SETCLIENTID4->callback_ident); /* Do we already have one or more records for client id (x)? */ client_record = get_client_record(arg_SETCLIENTID4->client.id.id_val, arg_SETCLIENTID4->client.id.id_len, 0, 0); if (client_record == NULL) { /* Some major failure */ LogCrit(COMPONENT_CLIENTID, "SETCLIENTID failed"); res_SETCLIENTID4->status = NFS4ERR_SERVERFAULT; return res_SETCLIENTID4->status; } /* The following checks are based on RFC3530bis draft 16 * * This attempts to implement the logic described in * 15.35.5. IMPLEMENTATION Consider the major bullets as CASE * 1, CASE 2, CASE 3, CASE 4, and CASE 5. */ pthread_mutex_lock(&client_record->cr_mutex); if (isFullDebug(COMPONENT_CLIENTID)) { char str[HASHTABLE_DISPLAY_STRLEN]; display_client_record(client_record, str); LogFullDebug(COMPONENT_CLIENTID, "Client Record %s cr_confirmed_rec=%p " "cr_unconfirmed_rec=%p", str, client_record->cr_confirmed_rec, client_record->cr_unconfirmed_rec); } conf = client_record->cr_confirmed_rec; if (conf != NULL) { /* Need a reference to the confirmed record for below */ inc_client_id_ref(conf); if (!nfs_compare_clientcred(&conf->cid_credential, &data->credential) || !cmp_sockaddr(&conf->cid_client_addr, &client_addr, true)) { /* CASE 1: * * Confirmed record exists and not the same principal */ if (isDebug(COMPONENT_CLIENTID)) { char confirmed_addr[SOCK_NAME_MAX + 1]; sprint_sockip(&conf->cid_client_addr, confirmed_addr, sizeof(confirmed_addr)); LogDebug(COMPONENT_CLIENTID, "Confirmed ClientId %" PRIx64 "->'%s': Principals do not match... confirmed addr=%s Return NFS4ERR_CLID_INUSE", conf->cid_clientid, str_client, confirmed_addr); } res_SETCLIENTID4->status = NFS4ERR_CLID_INUSE; res_SETCLIENTID4_INUSE->r_netid = (char *)netid_nc_table[conf->cid_cb.v40.cb_addr.nc] .netid; res_SETCLIENTID4_INUSE->r_addr = gsh_strdup(conf->cid_cb.v40.cb_client_r_addr); /* Release our reference to the confirmed clientid. */ dec_client_id_ref(conf); goto out; } /* Check if confirmed record is for (v, x, c, l, s) */ if (memcmp (arg_SETCLIENTID4->client.verifier, conf->cid_incoming_verifier, NFS4_VERIFIER_SIZE) == 0) { /* CASE 2: * * A confirmed record exists for this long * form client id and verifier. * * Consider this to be a possible update of * the call-back information. * * Remove any pre-existing unconfirmed record * for (v, x, c). * * Return the same short form client id (c), * but a new setclientid_confirm verifier (t). */ LogFullDebug(COMPONENT_CLIENTID, "Update ClientId %" PRIx64 "->%s", conf->cid_clientid, str_client); clientid = conf->cid_clientid; new_clientid_verifier(verifier); } else { /* Must be CASE 3 or CASE 4 * * Confirmed record is for (u, x, c, l, s). * * These are actually the same, doesn't really * matter if an unconfirmed record exists or * not. Any existing unconfirmed record will * be removed and a new unconfirmed record * added. * * Return a new short form clientid (d) and a * new setclientid_confirm verifier (t). (Note * the spec calls the values e and r for CASE * 4). */ LogFullDebug(COMPONENT_CLIENTID, "Replace ClientId %" PRIx64 "->%s", conf->cid_clientid, str_client); clientid = new_clientid(); new_clientid_verifier(verifier); } /* Release our reference to the confirmed clientid. */ dec_client_id_ref(conf); } else { /* CASE 5: * * * Remove any existing unconfirmed record. * * Return a new short form clientid (d) and a new * setclientid_confirm verifier (t). */ LogFullDebug(COMPONENT_CLIENTID, "New client"); clientid = new_clientid(); new_clientid_verifier(verifier); } /* At this point, no matter what the case was above, we should * remove any pre-existing unconfirmed record. */ unconf = client_record->cr_unconfirmed_rec; if (unconf != NULL) { /* Delete the unconfirmed clientid record. Because we * have the cr_mutex, we have won any race to deal * with this clientid record (whether we raced with a * SETCLIENTID_CONFIRM or the reaper thread (if either * of those operations had won the race, * cr_punconfirmed_id would have been NULL). */ if (isDebug(COMPONENT_CLIENTID)) { char str[HASHTABLE_DISPLAY_STRLEN]; display_client_id_rec(unconf, str); LogDebug(COMPONENT_CLIENTID, "Replacing %s", str); } /* unhash the clientid record */ remove_unconfirmed_client_id(unconf); unconf = NULL; } /* Now we can proceed to build the new unconfirmed record. We * have determined the clientid and setclientid_confirm values * above. */ unconf = create_client_id(clientid, client_record, &client_addr, &data->credential, op_ctx->client, 0); if (unconf == NULL) { /* Error already logged, return */ res_SETCLIENTID4->status = NFS4ERR_RESOURCE; goto out; } if (strmaxcpy(unconf->cid_cb.v40.cb_client_r_addr, arg_SETCLIENTID4->callback.cb_location.r_addr, sizeof(unconf->cid_cb.v40.cb_client_r_addr)) == -1) { LogCrit(COMPONENT_CLIENTID, "Callback r_addr %s too long", arg_SETCLIENTID4->callback.cb_location.r_addr); res_SETCLIENTID4->status = NFS4ERR_INVAL; goto out; } nfs_set_client_location(unconf, &arg_SETCLIENTID4->callback.cb_location); memcpy(unconf->cid_incoming_verifier, arg_SETCLIENTID4->client.verifier, NFS4_VERIFIER_SIZE); memcpy(unconf->cid_verifier, verifier, sizeof(NFS4_write_verifier)); unconf->cid_cb.v40.cb_program = arg_SETCLIENTID4->callback.cb_program; unconf->cid_cb.v40.cb_callback_ident = arg_SETCLIENTID4->callback_ident; rc = nfs_client_id_insert(unconf); if (rc != CLIENT_ID_SUCCESS) { /* Record is already freed, return. */ res_SETCLIENTID4->status = clientid_error_to_nfsstat(rc); goto out; } if (isDebug(COMPONENT_CLIENTID)) { char str[HASHTABLE_DISPLAY_STRLEN]; sprint_mem(str_verifier, verifier, NFS4_VERIFIER_SIZE); display_client_id_rec(unconf, str); LogDebug(COMPONENT_CLIENTID, "SETCLIENTID reply Verifier=%s %s", str_verifier, str); } res_SETCLIENTID4->status = NFS4_OK; res_SETCLIENTID4->SETCLIENTID4res_u.resok4.clientid = clientid; memcpy(res_SETCLIENTID4->SETCLIENTID4res_u.resok4.setclientid_confirm, &verifier, NFS4_VERIFIER_SIZE); out: pthread_mutex_unlock(&client_record->cr_mutex); /* Release our reference to the client record */ dec_client_record_ref(client_record); return res_SETCLIENTID4->status; }
/** * Handle ENDOFMOTD (376) numeric and login remote server. * The peer is either an IRC server (no IRC+ protocol), or we got the * ENDOFMOTD numeric from an IRC+ server. We have to register the new server. */ GLOBAL bool IRC_Num_ENDOFMOTD(CLIENT * Client, UNUSED REQUEST * Req) { int max_hops, i; CLIENT *c; CHANNEL *chan; Client_SetType(Client, CLIENT_SERVER); Log(LOG_NOTICE | LOG_snotice, "Server \"%s\" registered (connection %d, 1 hop - direct link).", Client_ID(Client), Client_Conn(Client)); /* Get highest hop count */ max_hops = 0; c = Client_First(); while (c) { if (Client_Hops(c) > max_hops) max_hops = Client_Hops(c); c = Client_Next(c); } /* Inform the new server about all other servers, and announce the * new server to all the already registered ones. Important: we have * to do this "in order" and can't introduce servers of which the * "toplevel server" isn't known already. */ for (i = 0; i < (max_hops + 1); i++) { for (c = Client_First(); c != NULL; c = Client_Next(c)) { if (Client_Type(c) != CLIENT_SERVER) continue; /* not a server */ if (Client_Hops(c) != i) continue; /* not actual "nesting level" */ if (c == Client || c == Client_ThisServer()) continue; /* that's us or the peer! */ if (!Announce_Server(Client, c)) return DISCONNECTED; } } /* Announce all the users to the new server */ c = Client_First(); while (c) { if (Client_Type(c) == CLIENT_USER || Client_Type(c) == CLIENT_SERVICE) { if (!Client_Announce(Client, Client_ThisServer(), c)) return DISCONNECTED; } c = Client_Next(c); } /* Announce all channels to the new server */ chan = Channel_First(); while (chan) { if (Channel_IsLocal(chan)) { chan = Channel_Next(chan); continue; } #ifdef IRCPLUS /* Send CHANINFO if the peer supports it */ if (Client_HasFlag(Client, 'C')) { if (!Send_CHANINFO(Client, chan)) return DISCONNECTED; } #endif if (!Announce_Channel(Client, chan)) return DISCONNECTED; /* Get next channel ... */ chan = Channel_Next(chan); } #ifdef IRCPLUS if (Client_HasFlag(Client, 'L')) { LogDebug("Synchronizing INVITE- and BAN-lists ..."); if (!Synchronize_Lists(Client)) return DISCONNECTED; } #endif if (!IRC_WriteStrClient(Client, "PING :%s", Client_ID(Client_ThisServer()))) return DISCONNECTED; return CONNECTED; } /* IRC_Num_ENDOFMOTD */
/** * * MFSL_setattrs : posts an asynchronous setattr and sets the cached attributes in return. * * Posts an asynchronous setattr and sets the cached attributes in return. * If the object is not asynchronous, then the content of object attributes will be used to populate it. * * @param filehandle [IN] mfsl object to be operated on. * @param p_context [IN] associated fsal context * @param p_mfsl_context [INOUT] associated mfsl context * @param attrib_set [IN] attributes to be set * @param object_attributes [INOUT] resulting attributes * * @return the same as FSAL_setattrs */ fsal_status_t MFSL_setattrs(mfsl_object_t * filehandle, /* IN */ fsal_op_context_t * p_context, /* IN */ mfsl_context_t * p_mfsl_context, /* IN */ fsal_attrib_list_t * attrib_set, /* IN */ fsal_attrib_list_t * object_attributes /* [ IN/OUT ] */ ) { fsal_status_t fsal_status; mfsl_async_op_desc_t *pasyncopdesc = NULL; mfsl_object_specific_data_t *pasyncdata = NULL; P(p_mfsl_context->lock); GetFromPool(pasyncopdesc, &p_mfsl_context->pool_async_op, mfsl_async_op_desc_t); V(p_mfsl_context->lock); if(pasyncopdesc == NULL) MFSL_return(ERR_FSAL_INVAL, 0); if(gettimeofday(&pasyncopdesc->op_time, NULL) != 0) { /* Could'not get time of day... Stopping, this may need a major failure */ LogMajor(COMPONENT_MFSL, "MFSL_setattrs: cannot get time of day... exiting"); exit(1); } /* Is the object asynchronous ? */ if(!mfsl_async_get_specdata(filehandle, &pasyncdata)) { /* Not yet asynchronous object */ P(p_mfsl_context->lock); GetFromPool(pasyncdata, &p_mfsl_context->pool_spec_data, mfsl_object_specific_data_t); V(p_mfsl_context->lock); /* In this case use object_attributes parameter to initiate asynchronous object */ pasyncdata->async_attr = *object_attributes; } fsal_status = MFSL_setattrs_check_perms(filehandle, pasyncdata, p_context, p_mfsl_context, attrib_set); if(FSAL_IS_ERROR(fsal_status)) return fsal_status; LogDebug(COMPONENT_MFSL, "Creating asyncop %p", pasyncopdesc); pasyncopdesc->op_type = MFSL_ASYNC_OP_SETATTR; pasyncopdesc->op_mobject = filehandle; pasyncopdesc->op_args.setattr.pmobject = filehandle; pasyncopdesc->op_args.setattr.attr = *attrib_set; pasyncopdesc->op_res.setattr.attr = *attrib_set; pasyncopdesc->op_func = MFSL_setattr_async_op; pasyncopdesc->fsal_op_context = *p_context; pasyncopdesc->ptr_mfsl_context = (caddr_t) p_mfsl_context; fsal_status = MFSL_async_post(pasyncopdesc); if(FSAL_IS_ERROR(fsal_status)) return fsal_status; /* Update the associated times for this object */ pasyncdata->async_attr.ctime.seconds = pasyncopdesc->op_time.tv_sec; pasyncdata->async_attr.ctime.nseconds = pasyncopdesc->op_time.tv_usec; /** @todo: there may be a coefficient to be applied here */ filehandle->health = MFSL_ASYNC_ASYNCHRONOUS; /* merge the attributes to the asynchronous attributes */ if((attrib_set->asked_attributes & FSAL_ATTR_SIZE) || (attrib_set->asked_attributes & FSAL_ATTR_SPACEUSED)) { /* Operation on a non data cached file */ pasyncdata->async_attr.filesize = attrib_set->filesize; pasyncdata->async_attr.spaceused = attrib_set->spaceused; } if(attrib_set->asked_attributes & (FSAL_ATTR_MODE | FSAL_ATTR_OWNER | FSAL_ATTR_GROUP)) { if(attrib_set->asked_attributes & FSAL_ATTR_MODE) pasyncdata->async_attr.mode = attrib_set->mode; if(attrib_set->asked_attributes & FSAL_ATTR_OWNER) pasyncdata->async_attr.owner = attrib_set->owner; if(attrib_set->asked_attributes & FSAL_ATTR_GROUP) pasyncdata->async_attr.group = attrib_set->group; } if(attrib_set->asked_attributes & (FSAL_ATTR_ATIME | FSAL_ATTR_MTIME)) { if(attrib_set->asked_attributes & FSAL_ATTR_ATIME) pasyncdata->async_attr.atime = attrib_set->atime; if(attrib_set->asked_attributes & FSAL_ATTR_MTIME) pasyncdata->async_attr.mtime = attrib_set->mtime; } /* Set output attributes */ *object_attributes = pasyncdata->async_attr; if(!mfsl_async_set_specdata(filehandle, pasyncdata)) MFSL_return(ERR_FSAL_SERVERFAULT, 0); MFSL_return(ERR_FSAL_NO_ERROR, 0); } /* MFSL_setattr */
void OgreMeshAsset::HandleLoadError(const QString &loadError) { LogDebug(loadError.toStdString()); }