diff options
author | Roland McGrath <roland@gnu.org> | 1998-09-04 18:30:17 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1998-09-04 18:30:17 +0000 |
commit | 8dcc9c154da590698944e05e153a9f22a9f45e3a (patch) | |
tree | ffcf6ae45b2eb15030e1f60cdf1ec8d4d39c448d | |
parent | 364131321985116d2b924cadb329d0512a2e90f6 (diff) |
1998-09-04 Roland McGrath <roland@baalperazim.frob.com>
* lookup.c (diskfs_lookup_hard): Fix defn with `const'.
(diskfs_direnter_hard): Likewise.
(diskfs_get_directs): Use `const' for local var NAME.
* inode.c (diskfs_set_translator): Fix defn with `const'.
-rw-r--r-- | isofs/inode.c | 78 | ||||
-rw-r--r-- | isofs/lookup.c | 78 |
2 files changed, 78 insertions, 78 deletions
diff --git a/isofs/inode.c b/isofs/inode.c index 29f35233..c2e29e4b 100644 --- a/isofs/inode.c +++ b/isofs/inode.c @@ -1,5 +1,5 @@ -/* - Copyright (C) 1997 Free Software Foundation, Inc. +/* + Copyright (C) 1997, 1998 Free Software Foundation, Inc. Written by Thomas Bushnell, n/BSG. This file is part of the GNU Hurd. @@ -39,7 +39,7 @@ struct node_cache struct dirrect *dr; /* somewhere in disk_image */ off_t file_start; /* UNIQUE start of file */ - + struct node *np; /* if live */ }; @@ -48,9 +48,9 @@ static int node_cache_alloced = 0; struct node_cache *node_cache = 0; /* Forward */ -static error_t read_disknode (struct node *, +static error_t read_disknode (struct node *, struct dirrect *, struct rrip_lookup *); - + /* See if node with file start FILE_START is in the cache. If so, return it, with one additional reference. diskfs_node_refcnt_lock must @@ -86,7 +86,7 @@ cache_inode (struct dirrect *dr, struct node *np) for (i = 0; i < node_cache_size; i++) if (node_cache[i].file_start == np->dn->file_start) break; - + if (i == node_cache_size) { if (node_cache_size >= node_cache_alloced) @@ -100,7 +100,7 @@ cache_inode (struct dirrect *dr, struct node *np) else { node_cache_alloced *= 2; - node_cache = realloc (node_cache, + node_cache = realloc (node_cache, sizeof (struct node_cache) * node_cache_alloced); } @@ -108,7 +108,7 @@ cache_inode (struct dirrect *dr, struct node *np) } node_cache_size++; } - + c = &node_cache[i]; c->dr = dr; c->file_start = np->dn->file_start; @@ -134,7 +134,7 @@ diskfs_cached_lookup (int id, struct node **npp) assert (id < node_cache_size); np = node_cache[id].np; - + if (!np) { struct node_cache *c = &node_cache[id]; @@ -142,7 +142,7 @@ diskfs_cached_lookup (int id, struct node **npp) struct disknode *dn; rrip_lookup (node_cache[id].dr, &rr, 1); - + /* We should never cache the wrong directory entry */ assert (!(rr.valid & VALID_CL)); @@ -154,7 +154,7 @@ diskfs_cached_lookup (int id, struct node **npp) mutex_lock (&np->lock); c->np = np; spin_unlock (&diskfs_node_refcnt_lock); - + err = read_disknode (np, node_cache[id].dr, &rr); if (!err) *npp = np; @@ -164,7 +164,7 @@ diskfs_cached_lookup (int id, struct node **npp) return err; } - + np->references++; spin_unlock (&diskfs_node_refcnt_lock); mutex_lock (&np->lock); @@ -192,7 +192,7 @@ isodate_915 (char *c, struct timespec *ts) tm.tm_isdst = 0; ts->tv_sec = timegm (&tm); ts->tv_nsec = 0; - + /* Only honor TZ offset if it makes sense */ if (-48 <= tz && tz <= 52) ts->tv_sec -= 15 * 60 * tz; /* TZ is in fifteen minute chunks */ @@ -208,7 +208,7 @@ isodate_84261 (char *c, struct timespec *ts) int hsec; signed char tz; - sscanf (c, "%4d%2d%2d%2d%2d%2d%2d", + sscanf (c, "%4d%2d%2d%2d%2d%2d%2d", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &hsec); @@ -217,10 +217,10 @@ isodate_84261 (char *c, struct timespec *ts) ts->tv_nsec = hsec * 10000000; tm.tm_year -= 1900; tm.tm_mon--; - + tm.tm_isdst = 0; ts->tv_sec = timegm (&tm); - + tz = c[16]; /* Only honor TZ offset if it makes sense */ @@ -249,7 +249,7 @@ calculate_file_start (struct dirrect *record, off_t *file_start, err = diskfs_catch_exception (); if (err) return err; - + *file_start = ((isonum_733 (record->extent) + record->ext_attr_len) * (logical_block_size / store->block_size)); @@ -262,14 +262,14 @@ calculate_file_start (struct dirrect *record, off_t *file_start, /* Load the inode with directory entry RECORD and cached Rock-Rodge info RR into NP. The directory entry is at OFFSET in BLOCK. */ error_t -load_inode (struct node **npp, struct dirrect *record, +load_inode (struct node **npp, struct dirrect *record, struct rrip_lookup *rr) { error_t err; off_t file_start; struct disknode *dn; struct node *np; - + err = calculate_file_start (record, &file_start, rr); if (err) return err; @@ -277,12 +277,12 @@ load_inode (struct node **npp, struct dirrect *record, record = rr->realdirent; spin_lock (&diskfs_node_refcnt_lock); - + /* First check the cache */ inode_cache_find (file_start, npp); if (*npp) return 0; - + /* Create a new node */ dn = malloc (sizeof (struct disknode)); dn->fileinfo = 0; @@ -294,7 +294,7 @@ load_inode (struct node **npp, struct dirrect *record, cache_inode (record, np); spin_unlock (&diskfs_node_refcnt_lock); - + err = read_disknode (np, record, rr); *npp = np; return err; @@ -309,13 +309,13 @@ read_disknode (struct node *np, struct dirrect *dr, { error_t err; struct stat *st = &np->dn_stat; - + st->st_fstype = 9660; /* xxx */ st->st_fsid = getpid (); st->st_ino = np->dn->file_start; st->st_gen = 0; st->st_rdev = 0; - + err = diskfs_catch_exception (); if (err) return err; @@ -334,7 +334,7 @@ read_disknode (struct node *np, struct dirrect *dr, { /* If there are no periods, it's a directory. */ if (((rl->valid & VALID_NM) && !index (rl->name, '.')) - || (!(rl->valid & VALID_NM) && !memchr (dr->name, '.', + || (!(rl->valid & VALID_NM) && !memchr (dr->name, '.', dr->namelen))) st->st_mode = S_IFDIR | 0777; else @@ -347,7 +347,7 @@ read_disknode (struct node *np, struct dirrect *dr, if (rl->valid & VALID_MD) st->st_mode = rl->allmode; - + if (rl->valid & VALID_AU) st->st_author = rl->author; else @@ -358,13 +358,13 @@ read_disknode (struct node *np, struct dirrect *dr, if ((rl->valid & VALID_PN) && (S_ISCHR (st->st_mode) || S_ISBLK (st->st_mode))) st->st_rdev = rl->rdev; - else + else st->st_rdev = 0; - + if (dr->ileave) /* XXX ??? */ st->st_size = 0; - + /* Calculate these if we'll need them */ if (!(rl->valid & VALID_TF) || ((rl->tfflags & (TF_CREATION|TF_ACCESS|TF_MODIFY)) @@ -373,10 +373,10 @@ read_disknode (struct node *np, struct dirrect *dr, struct timespec ts; isodate_915 (dr->date, &ts); st->st_ctime = st->st_mtime = st->st_atime = ts.tv_sec; - st->st_ctime_usec = st->st_mtime_usec = st->st_atime_usec + st->st_ctime_usec = st->st_mtime_usec = st->st_atime_usec = ts.tv_nsec * 1000; } - + /* Override what we have better info for */ if (rl->valid & VALID_TF) { @@ -385,20 +385,20 @@ read_disknode (struct node *np, struct dirrect *dr, st->st_ctime = rl->ctime.tv_sec; st->st_ctime_usec = rl->ctime.tv_nsec * 1000; } - + if (rl->tfflags & TF_ACCESS) { st->st_atime = rl->atime.tv_sec; st->st_atime_usec = rl->atime.tv_nsec * 1000; } - + if (rl->tfflags & TF_MODIFY) { st->st_mtime = rl->mtime.tv_sec; st->st_mtime_usec = rl->mtime.tv_nsec * 1000; } } - + st->st_blksize = logical_block_size; st->st_blocks = (st->st_size - 1) / 512 + 1; @@ -406,7 +406,7 @@ read_disknode (struct node *np, struct dirrect *dr, st->st_flags = rl->flags; else st->st_flags = 0; - + if (S_ISLNK (st->st_mode)) { if (rl->valid & VALID_SL) @@ -436,7 +436,7 @@ read_disknode (struct node *np, struct dirrect *dr, } diskfs_end_catch_exception (); - + return 0; } @@ -447,7 +447,7 @@ read_symlink_hook (struct node *np, char *buf) bcopy (np->dn->link_target, buf, np->dn_stat.st_size); return 0; } -error_t (*diskfs_read_symlink_hook) (struct node *, char *) +error_t (*diskfs_read_symlink_hook) (struct node *, char *) = read_symlink_hook; @@ -499,7 +499,8 @@ diskfs_grow (struct node *np, off_t end, struct protid *cred) } error_t -diskfs_set_translator (struct node *np, char *name, u_int namelen, +diskfs_set_translator (struct node *np, + const char *name, u_int namelen, struct protid *cred) { return EROFS; @@ -577,4 +578,3 @@ diskfs_alloc_node (struct node *dp, mode_t mode, struct node **np) { return EROFS; } - diff --git a/isofs/lookup.c b/isofs/lookup.c index faed5d28..f5c216ea 100644 --- a/isofs/lookup.c +++ b/isofs/lookup.c @@ -1,5 +1,5 @@ -/* - Copyright (C) 1997 Free Software Foundation, Inc. +/* + Copyright (C) 1997, 1998 Free Software Foundation, Inc. Written by Thomas Bushnell, n/BSG. This file is part of the GNU Hurd. @@ -32,10 +32,10 @@ isonamematch (char *dirname, size_t dnamelen, char *username, size_t unamelen) /* Special representations for `.' and `..' */ if (dnamelen == 1 && dirname[0] == '\0') return unamelen == 1 && username[0] == '.'; - + if (dnamelen == 1 && dirname[0] == '\1') return unamelen == 2 && username[0] == '.' && username[1] == '.'; - + if (unamelen > dnamelen) return 0; @@ -44,13 +44,13 @@ isonamematch (char *dirname, size_t dnamelen, char *username, size_t unamelen) /* A prefix has matched. Check if it's acceptable. */ if (dnamelen == unamelen) return 1; - + /* User has ommitted the version number */ if (dirname[unamelen] == ';') return 1; - + /* User has ommitted an empty extension */ - if (dirname[unamelen] == '.' + if (dirname[unamelen] == '.' && (dirname[unamelen+1] == '\0' || dirname[unamelen+1] == ';')) return 1; } @@ -61,7 +61,7 @@ isonamematch (char *dirname, size_t dnamelen, char *username, size_t unamelen) /* Implement the diskfs_lookup callback from the diskfs library. See <hurd/diskfs.h> for the interface specification. */ error_t -diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, +diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type, struct node **npp, struct dirstat *ds, struct protid *cred) { error_t err = 0; @@ -71,7 +71,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, void *buf; void *blockaddr; struct rrip_lookup rr; - + if ((type == REMOVE) || (type == RENAME)) assert (npp); @@ -80,7 +80,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, spec_dotdot = type & SPEC_DOTDOT; type &= ~SPEC_DOTDOT; - + namelen = strlen (name); /* This error is constant, but the errors for CREATE and REMOVE depend @@ -89,7 +89,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, return EROFS; buf = disk_image + (dp->dn->file_start << store->log2_block_size); - + for (blockaddr = buf; blockaddr < buf + dp->dn_stat.st_size; blockaddr += logical_sector_size) @@ -102,14 +102,14 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, if (err != ENOENT) return err; } - + if ((!err && type == REMOVE) || (err == ENOENT && type == CREATE)) err = EROFS; - + if (err) return err; - + /* Load the inode */ if (namelen == 2 && name[0] == '.' && name[1] == '.') { @@ -139,7 +139,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, } else err = load_inode (npp, record, &rr); - + release_rrip (&rr); return err; } @@ -148,7 +148,7 @@ diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type, /* Scan one logical sector of directory contents (at address BLKADDR) for NAME of length NAMELEN. Return its address in *RECORD. */ static error_t -dirscanblock (void *blkaddr, char *name, size_t namelen, +dirscanblock (void *blkaddr, char *name, size_t namelen, struct dirrect **record, struct rrip_lookup *rr) { struct dirrect *entry; @@ -163,9 +163,9 @@ dirscanblock (void *blkaddr, char *name, size_t namelen, currentoff += reclen) { entry = (struct dirrect *) currentoff; - + reclen = entry->len; - + /* Validate reclen */ if (reclen == 0 || reclen < sizeof (struct dirrect) @@ -173,11 +173,11 @@ dirscanblock (void *blkaddr, char *name, size_t namelen, break; entry_namelen = entry->namelen; - + /* More validation */ if (reclen < sizeof (struct dirrect) + entry_namelen) break; - + /* Check to see if the name maches the directory entry. */ if (isonamematch (entry->name, entry_namelen, name, namelen)) matchnormal = 1; @@ -186,14 +186,14 @@ dirscanblock (void *blkaddr, char *name, size_t namelen, /* Now scan for RRIP fields */ matchrr = rrip_match_lookup (entry, name, namelen, rr); - + /* Ignore RE entries */ if (rr->valid & VALID_RE) { release_rrip (rr); continue; } - + /* See if the name matches */ if (((rr->valid & VALID_NM) && matchrr) || (!(rr->valid & VALID_NM) && matchnormal)) @@ -236,7 +236,7 @@ diskfs_get_directs (struct node *dp, vm_allocate (mach_task_self (), (vm_address_t *) data, allocsize, 1); ouralloc = 1; } - + err = diskfs_catch_exception (); if (err) { @@ -246,12 +246,12 @@ diskfs_get_directs (struct node *dp, } /* Skip to ENTRY */ - dirbuf = disk_image + (dp->dn->file_start << store->log2_block_size); + dirbuf = disk_image + (dp->dn->file_start << store->log2_block_size); bufp = dirbuf; for (i = 0; i < entry; i ++) { struct rrip_lookup rr; - + ep = (struct dirrect *) bufp; rrip_lookup (ep, &rr, 0); @@ -281,7 +281,7 @@ diskfs_get_directs (struct node *dp, bufp = (void *) (((long) bufp & ~(logical_sector_size - 1)) + logical_sector_size); } - + /* Now copy entries one at a time */ i = 0; datap = *data; @@ -290,7 +290,7 @@ diskfs_get_directs (struct node *dp, && ((void *) bufp - dirbuf < dp->dn_stat.st_size)) { struct rrip_lookup rr; - char *name; + const char *name; size_t namlen, reclen; off_t file_start; @@ -329,31 +329,31 @@ diskfs_get_directs (struct node *dp, reclen = sizeof (struct dirent) + namlen; reclen = (reclen + 3) & ~3; - + /* Expand buffer if necessary */ if (datap - *data + reclen > allocsize) { vm_address_t newdata; - vm_allocate (mach_task_self (), &newdata, + vm_allocate (mach_task_self (), &newdata, (ouralloc ? (allocsize *= 2) : (allocsize = vm_page_size * 2)), 1); bcopy ((void *) *data, (void *)newdata, datap - *data); - + if (ouralloc) - vm_deallocate (mach_task_self (), (vm_address_t) *data, + vm_deallocate (mach_task_self (), (vm_address_t) *data, allocsize / 2); - + datap = (char *) newdata + (datap - *data); *data = (char *) newdata; ouralloc = 1; } - + userp = (struct dirent *) datap; /* Fill in entry */ - + err = calculate_file_start (ep, &file_start, &rr); if (err) { @@ -362,14 +362,14 @@ diskfs_get_directs (struct node *dp, vm_deallocate (mach_task_self (), (vm_address_t) *data, allocsize); return err; } - + userp->d_fileno = file_start; userp->d_type = DT_UNKNOWN; userp->d_reclen = reclen; userp->d_namlen = namlen; bcopy (name, userp->d_name, namlen); userp->d_name[namlen] = '\0'; - + /* And move along */ release_rrip (&rr); datap = datap + reclen; @@ -392,7 +392,7 @@ diskfs_get_directs (struct node *dp, && round_page (datap - *data) < round_page (allocsize)) vm_deallocate (mach_task_self (), round_page (datap), round_page (allocsize) - round_page (datap - *data)); - + /* Return */ *amt = i; *datacnt = datap - *data; @@ -417,7 +417,7 @@ diskfs_drop_dirstat (struct node *dp, struct dirstat *ds) error_t diskfs_direnter_hard(struct node *dp, - char *name, + const char *name, struct node *np, struct dirstat *ds, struct protid *cred) @@ -433,7 +433,7 @@ diskfs_dirremove_hard(struct node *dp, } error_t -diskfs_dirrewrite_hard(struct node *dp, +diskfs_dirrewrite_hard(struct node *dp, struct node *np, struct dirstat *ds) { |