~ubuntu-branches/ubuntu/trusty/cctools/trusty-proposed

« back to all changes in this revision

Viewing changes to chirp/src/chirp_alloc.c

  • Committer: Package Import Robot
  • Author(s): Michael Hanke
  • Date: 2011-10-26 11:51:10 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20111026115110-5pc2qxp03chldcdi
Tags: 3.4.0-1
* New upstream release.
* Improve DEP5 compliance of debian/copyright.
* Added patch to make "starch" use python instead of python2 as interpreter.
* Tighten build-dependencies (added swig and m4).
* Enable MPI-support for work-queue.
* Move to dh_python2.
* Split Python-bindings for workqueue into a dedicated package and build
  them for all supported Python versions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
153
153
 
154
154
        while(1) {
155
155
                sprintf(statename, "%s/.__alloc", dirname);
156
 
                if(cfs->file_size(statename) >= 0) {
 
156
                if(cfs_file_size(statename) >= 0) {
157
157
                        return xstrdup(dirname);
158
158
                }
159
159
                s = strrchr(dirname, '/');
231
231
static void recover(const char *path)
232
232
{
233
233
        char newpath[CHIRP_PATH_MAX];
234
 
        struct chirp_stat info;
235
234
        struct alloc_state *a, *b;
236
 
        int result;
237
 
        void *dir;
238
 
        char *d;
 
235
        struct chirp_dir *dir;
 
236
        struct chirp_dirent *d;
239
237
 
240
238
        a = alloc_state_cache_exact(path);
241
239
        if(!a)
246
244
                fatal("couldn't open %s: %s\n", path, strerror(errno));
247
245
 
248
246
        while((d = cfs->readdir(dir))) {
249
 
                if(!strcmp(d, "."))
250
 
                        continue;
251
 
                if(!strcmp(d, ".."))
252
 
                        continue;
253
 
                if(!strncmp(d, ".__", 3))
254
 
                        continue;
255
 
 
256
 
                sprintf(newpath, "%s/%s", path, d);
257
 
 
258
 
                result = cfs->lstat(newpath, &info);
259
 
                if(result != 0)
260
 
                        fatal("couldn't stat %s: %s\n", path, strerror(errno));
261
 
 
262
 
                if(S_ISDIR(info.cst_mode)) {
 
247
                if(!strcmp(d->name, "."))
 
248
                        continue;
 
249
                if(!strcmp(d->name, ".."))
 
250
                        continue;
 
251
                if(!strncmp(d->name, ".__", 3))
 
252
                        continue;
 
253
 
 
254
                sprintf(newpath, "%s/%s", path, d->name);
 
255
 
 
256
                if(S_ISDIR(d->info.cst_mode)) {
263
257
                        recover(newpath);
264
258
                        b = alloc_state_cache_exact(newpath);
265
259
                        if(a != b)
266
260
                                alloc_state_update(a, b->size);
267
 
                } else if(S_ISREG(info.cst_mode)) {
268
 
                        alloc_state_update(a, space_consumed(info.cst_size));
 
261
                } else if(S_ISREG(d->info.cst_mode)) {
 
262
                        alloc_state_update(a, space_consumed(d->info.cst_size));
269
263
                } else {
270
264
                        debug(D_ALLOC, "warning: unknown file type: %s\n", newpath);
271
265
                }
371
365
 
372
366
        a = alloc_state_cache(path);
373
367
        if(a) {
374
 
                INT64_T filesize = cfs->file_size(path);
 
368
                INT64_T filesize = cfs_file_size(path);
375
369
                if(filesize < 0)
376
370
                        filesize = 0;
377
371
 
422
416
 
423
417
        a = alloc_state_cache(itable_lookup(fd_table, fd));
424
418
        if(a) {
425
 
                INT64_T filesize = cfs->fd_size(fd);
 
419
                INT64_T filesize = cfs_fd_size(fd);
426
420
                if(filesize >= 0) {
427
421
                        INT64_T newfilesize = MAX(length + offset, filesize);
428
422
                        INT64_T alloc_change = space_consumed(newfilesize) - space_consumed(filesize);
508
502
 
509
503
        a = alloc_state_cache(itable_lookup(fd_table, fd));
510
504
        if(a) {
511
 
                INT64_T filesize = cfs->fd_size(fd);
 
505
                INT64_T filesize = cfs_fd_size(fd);
512
506
                if(filesize >= 0) {
513
507
                        INT64_T alloc_change = space_consumed(length) - space_consumed(filesize);
514
508
                        if(a->avail >= alloc_change) {
533
527
        return cfs->fsync(fd);
534
528
}
535
529
 
536
 
void *chirp_alloc_opendir(const char *path)
 
530
struct chirp_dir * chirp_alloc_opendir( const char *path )
537
531
{
538
532
        return cfs->opendir(path);
539
533
}
540
534
 
541
 
char *chirp_alloc_readdir(void *dir)
 
535
struct chirp_dirent * chirp_alloc_readdir( struct chirp_dir *dir )
542
536
{
543
537
        return cfs->readdir(dir);
544
538
}
545
539
 
546
 
void chirp_alloc_closedir(void *dir)
 
540
void chirp_alloc_closedir( struct chirp_dir *dir )
547
541
{
548
542
        return cfs->closedir(dir);
549
543
}
671
665
 
672
666
        a = alloc_state_cache(path);
673
667
        if(a) {
674
 
                INT64_T filesize = cfs->file_size(path);
 
668
                INT64_T filesize = cfs_file_size(path);
675
669
                if(filesize >= 0) {
676
670
                        result = cfs->unlink(path);
677
671
                        if(result == 0)
700
694
                        if(a == b) {
701
695
                                result = rename(oldpath, newpath);
702
696
                        } else {
703
 
                                INT64_T filesize = cfs->file_size(oldpath);
 
697
                                INT64_T filesize = cfs_file_size(oldpath);
704
698
                                if(filesize >= 0) {
705
699
                                        if(b->avail >= filesize) {
706
700
                                                result = cfs->rename(oldpath, newpath);
751
745
 
752
746
INT64_T chirp_alloc_rmall(const char *path)
753
747
{
754
 
        int result;
 
748
        if(!alloc_enabled) return cfs->rmall(path);
755
749
 
756
 
        result = chirp_alloc_unlink(path);
 
750
        int result = chirp_alloc_unlink(path);
757
751
        if(result == 0) {
758
752
                return 0;
759
753
        } else if(errno != EISDIR) {
760
754
                return -1;
761
755
        } else {
762
 
                void *dir;
763
 
                char *d;
 
756
                struct chirp_dir *dir;
 
757
                struct chirp_dirent *d;
764
758
                char subpath[CHIRP_PATH_MAX];
765
759
 
766
760
                dir = chirp_alloc_opendir(path);
770
764
                result = 0;
771
765
 
772
766
                while((d = chirp_alloc_readdir(dir))) {
773
 
                        if(!strcmp(d, "."))
774
 
                                continue;
775
 
                        if(!strcmp(d, ".."))
776
 
                                continue;
777
 
                        if(!strncmp(d, ".__     ", 3))
778
 
                                continue;
779
 
                        sprintf(subpath, "%s/%s", path, d);
 
767
                        if(!strcmp(d->name, "."))
 
768
                                continue;
 
769
                        if(!strcmp(d->name, ".."))
 
770
                                continue;
 
771
                        if(!strncmp(d->name, ".__       ", 3))
 
772
                                continue;
 
773
                        sprintf(subpath, "%s/%s", path, d->name);
780
774
                        result = chirp_alloc_rmall(subpath);
781
775
                        if(result != 0)
782
776
                                break;
856
850
        return result;
857
851
}
858
852
 
859
 
INT64_T chirp_alloc_mkfifo(const char *path)
860
 
{
861
 
        return cfs->mkfifo(path);
862
 
}
863
 
 
864
853
INT64_T chirp_alloc_access(const char *path, INT64_T mode)
865
854
{
866
855
        return cfs->access(path, mode);
891
880
 
892
881
        a = alloc_state_cache(path);
893
882
        if(a) {
894
 
                INT64_T filesize = cfs->file_size(path);
 
883
                INT64_T filesize = cfs_file_size(path);
895
884
                if(filesize >= 0) {
896
885
                        INT64_T alloc_change = space_consumed(newsize) - space_consumed(filesize);
897
886
                        if(a->avail >= alloc_change) {
921
910
        return cfs->md5(path, digest);
922
911
}
923
912
 
 
913
INT64_T chirp_alloc_setrep(const char *path, int nreps)
 
914
{
 
915
        return cfs->setrep(path,nreps);
 
916
}
 
917
 
924
918
INT64_T chirp_alloc_lsalloc(const char *path, char *alloc_path, INT64_T * total, INT64_T * inuse)
925
919
{
926
920
        char *name;
982
976
 
983
977
        return result;
984
978
}
985
 
 
986
 
INT64_T chirp_alloc_file_size(const char *path)
987
 
{
988
 
        return cfs->file_size(path);
989
 
}
990
 
 
991
 
INT64_T chirp_alloc_fd_size(int fd)
992
 
{
993
 
        return cfs->fd_size(fd);
994
 
}