// =-=-=-=-=-=-=- // local function which makes the call to truncate via the resource plugin int _rsFileTruncate( rsComm_t* _comm, fileOpenInp_t* _trunc_inp ) { // =-=-=-=-=-=-=- // make the call to rename via the resource plugin irods::file_object_ptr file_obj( new irods::file_object( _comm, _trunc_inp->objPath, _trunc_inp->fileName, _trunc_inp->resc_hier_, 0, 0, 0 ) ); file_obj->size( _trunc_inp->dataSize ); // =-=-=-=-=-=-=- // pass condInput file_obj->cond_input( _trunc_inp->condInput ); irods::error trunc_err = fileTruncate( _comm, file_obj ); // =-=-=-=-=-=-=- // report errors if any if ( !trunc_err.ok() ) { std::stringstream msg; msg << "fileTruncate for ["; msg << _trunc_inp->fileName; msg << "]"; msg << trunc_err.code(); irods::error err = PASSMSG( msg.str(), trunc_err ); irods::log( err ); } return trunc_err.code(); } // _rsFileTruncate
static int usersFileWrite(Ubox* box) { Fs *fs; User *u; int i, r; Fsys *fsys; char *p, *q, *s; File *dir, *file; if((fsys = fsysGet("main")) == nil) return 0; fsysFsRlock(fsys); fs = fsysGetFs(fsys); /* * BUG: * the owner/group/permissions need to be thought out. */ r = 0; if((dir = fileOpen(fs, "/active")) == nil) goto tidy0; if((file = fileWalk(dir, uidadm)) == nil) file = fileCreate(dir, uidadm, ModeDir|0775, uidadm); fileDecRef(dir); if(file == nil) goto tidy; dir = file; if((file = fileWalk(dir, "users")) == nil) file = fileCreate(dir, "users", 0664, uidadm); fileDecRef(dir); if(file == nil) goto tidy; if(!fileTruncate(file, uidadm)) goto tidy; p = s = vtMemAlloc(box->len+1); q = p + box->len+1; for(u = box->head; u != nil; u = u->next){ p += snprint(p, q-p, "%s:%s:", u->uid, u->uname); if(u->leader != nil) p+= snprint(p, q-p, u->leader); p += snprint(p, q-p, ":"); if(u->ngroup){ p += snprint(p, q-p, u->group[0]); for(i = 1; i < u->ngroup; i++) p += snprint(p, q-p, ",%s", u->group[i]); } p += snprint(p, q-p, "\n"); } r = fileWrite(file, s, box->len, 0, uidadm); vtMemFree(s); tidy: if(file != nil) fileDecRef(file); tidy0: fsysFsRUnlock(fsys); fsysPut(fsys); return r; }