From 36a9bab93af2737a23991d0a754ace7926f4464e Mon Sep 17 00:00:00 2001 From: Paul Stewart Date: Sat, 16 Mar 2002 18:14:24 -0800 Subject: USB Urefs for hid-core/hiddev I've written a patch Vojtech and I discussed for enhancing the hiddev code to optionally provide more detailed output on read(). The old functionality is still supported by default, and in situations where HID usage codes are unique across reports, the old method is still preferable due to its terseness. The new method provides the ability to determine exactly which value has changed, in cases where the HID usage codes are not unique. It also provides a means to optionally receive notification when input reports are received from the device, whether or not any of the values in the report have changed. The details of the changes are as follows: - All current code behaves identically - A new ioctl pair HIDIOCGFLAG/HIDIOCSFLAG gets and clears flags on the hiddev device. - If you set the flag HIDDEV_FLAG_UREF, the read() call switches from reading hiddev_event structures to hiddev_usage_ref structures. The change takes effect immediately, even to already queued events that haven't been read() yet. Here's an example of enabling FLAG_UREF: { int flag = HIDDEV_FLAG_UREF; if (ioctl(fd, HIDIOCSFLAG, &flag) != 0) { perror("ioctl"); exit(1); } } - With the HIDDEV_FLAG_REPORT set (which is only allowed if HIDDEV_FLAG_UREF is also set), there is a special uref that will be read() in addition to the ones corresponding to changes in the device state: when uref.field_index is set to HID_FIELD_INDEX_NONE, this uref is a notification that the report referred to by report_type and report_id has been received from the device. This can be useful in situations when the notification of the arrival of a report is useful even if there is no change in state. --- include/linux/hiddev.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'include/linux') diff --git a/include/linux/hiddev.h b/include/linux/hiddev.h index cffc0323325d..4f57c1174598 100644 --- a/include/linux/hiddev.h +++ b/include/linux/hiddev.h @@ -119,6 +119,7 @@ struct hiddev_usage_ref { __s32 value; }; +#define HID_FIELD_INDEX_NONE 0xffffffff /* * Protocol version. @@ -143,6 +144,15 @@ struct hiddev_usage_ref { #define HIDIOCGUSAGE _IOWR('H', 0x0B, struct hiddev_usage_ref) #define HIDIOCSUSAGE _IOW('H', 0x0C, struct hiddev_usage_ref) #define HIDIOCGUCODE _IOWR('H', 0x0D, struct hiddev_usage_ref) +#define HIDIOCGFLAG _IOR('H', 0x0E, int) +#define HIDIOCSFLAG _IOW('H', 0x0F, int) + +/* + * Flags to be used in HIDIOCSFLAG + */ +#define HIDDEV_FLAG_UREF 0x1 +#define HIDDEV_FLAG_REPORT 0x2 +#define HIDDEV_FLAGS 0x3 /* To traverse the input report descriptor info for a HID device, perform the * following: @@ -179,7 +189,7 @@ struct hiddev_usage_ref { #ifdef CONFIG_USB_HIDDEV int hiddev_connect(struct hid_device *); void hiddev_disconnect(struct hid_device *); -void hiddev_hid_event(struct hid_device *, unsigned int usage, int value); +void hiddev_hid_event(struct hid_device *, struct hiddev_usage_ref *ref); int __init hiddev_init(void); void __exit hiddev_exit(void); #else -- cgit v1.2.3 From 5942e595876eb5c1a98242b38f2b770adc1330d7 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Sun, 17 Mar 2002 04:03:52 -0800 Subject: Make wanpipe build again after struct sock cleanups. From Arnaldo Carvalho de Melo. --- include/linux/if_wanpipe.h | 1 + net/wanrouter/af_wanpipe.c | 55 ++++++++++++++++++++++++++-------------------- 2 files changed, 32 insertions(+), 24 deletions(-) (limited to 'include/linux') diff --git a/include/linux/if_wanpipe.h b/include/linux/if_wanpipe.h index 544d818d9f73..c4cd29a162fe 100644 --- a/include/linux/if_wanpipe.h +++ b/include/linux/if_wanpipe.h @@ -122,6 +122,7 @@ struct wanpipe_opt unsigned poll_cnt; unsigned char force; /* Used to force sock release */ atomic_t packet_sent; + unsigned short num; }; #define wp_sk(__sk) ((struct wanpipe_opt *)(__sk)->protinfo) diff --git a/net/wanrouter/af_wanpipe.c b/net/wanrouter/af_wanpipe.c index 88a4e1356ed3..0a9f62073788 100644 --- a/net/wanrouter/af_wanpipe.c +++ b/net/wanrouter/af_wanpipe.c @@ -19,6 +19,7 @@ * Alan Cox. * X25 socket Author: Jonathan Naylor. * ============================================================================ +* Mar 15, 2002 Arnaldo C. Melo o Use wp_sk()->num, as it isnt anymore in sock * Apr 25, 2000 Nenad Corbic o Added the ability to send zero length packets. * Mar 13, 2000 Nenad Corbic o Added a tx buffer check via ioctl call. * Mar 06, 2000 Nenad Corbic o Fixed the corrupt sock lcn problem. @@ -164,11 +165,11 @@ static void dbg_kfree(void * v, int line) { /* List of all wanpipe sockets. */ -struct sock * wanpipe_sklist = NULL; +struct sock* wanpipe_sklist; static rwlock_t wanpipe_sklist_lock = RW_LOCK_UNLOCKED; atomic_t wanpipe_socks_nr; -static unsigned long wanpipe_tx_critical=0; +static unsigned long wanpipe_tx_critical; #if 0 /* Private wanpipe socket structures. */ @@ -187,9 +188,9 @@ struct wanpipe_opt }; #endif -static int sk_count=0; +static int sk_count; extern struct proto_ops wanpipe_ops; -static unsigned long find_free_critical=0; +static unsigned long find_free_critical; static void wanpipe_unlink_driver (struct sock *); static void wanpipe_link_driver (netdevice_t *,struct sock *sk); @@ -400,9 +401,9 @@ static int wanpipe_listen_rcv (struct sk_buff *skb, struct sock *sk) card->u.x.svc_to_dev_map[(chan->lcn%MAX_X25_LCN)] = dev; newsk->zapped=0; - newsk->num = htons(X25_PROT); + newwp->num = htons(X25_PROT); - if (wanpipe_do_bind(newsk,dev,newsk->num)){ + if (wanpipe_do_bind(newsk, dev, newwp->num)) { wanpipe_kill_sock_irq (newsk); release_device(dev); return -EINVAL; @@ -470,7 +471,7 @@ static struct sock *wanpipe_make_new(struct sock *osk) sk->socket = osk->socket; sk->priority = osk->priority; sk->protocol = osk->protocol; - sk->num = osk->num; + wp_sk(sk)->num = wp_sk(osk)->num; sk->rcvbuf = osk->rcvbuf; sk->sndbuf = osk->sndbuf; sk->debug = osk->debug; @@ -566,9 +567,11 @@ static int wanpipe_sendmsg(struct socket *sock, struct msghdr *msg, int len, if (len < sizeof(x25api_hdr_t)) return -EINVAL; + wp = wp_sk(sk); + if (saddr == NULL) { ifindex = sk->bound_dev_if; - proto = sk->num; + proto = wp->num; addr = NULL; }else{ @@ -648,7 +651,6 @@ static int wanpipe_sendmsg(struct socket *sock, struct msghdr *msg, int len, } skb_queue_tail(&sk->write_queue,skb); - wp = wp_sk(sk); atomic_inc(&wp->packet_sent); if (!(test_and_set_bit(0, &wp->timer))){ @@ -998,7 +1000,8 @@ static int wanpipe_release(struct socket *sock, struct socket *peersock) * Unhook packet receive handler. */ - if (sk->num == htons(X25_PROT) && sk->state != WANSOCK_DISCONNECTED && sk->zapped){ + if (wp->num == htons(X25_PROT) && + sk->state != WANSOCK_DISCONNECTED && sk->zapped) { netdevice_t *dev = dev_get_by_index(sk->bound_dev_if); wanpipe_common_t *chan; if (dev){ @@ -1206,7 +1209,8 @@ static void wanpipe_kill_sock_timer (unsigned long data) write_unlock(&wanpipe_sklist_lock); - if (sk->num == htons(X25_PROT) && sk->state != WANSOCK_DISCONNECTED){ + if (wp_sk(sk)->num == htons(X25_PROT) && + sk->state != WANSOCK_DISCONNECTED){ netdevice_t *dev = dev_get_by_index(sk->bound_dev_if); wanpipe_common_t *chan; if (dev){ @@ -1352,6 +1356,7 @@ static void wanpipe_kill_sock_irq (struct sock *sk) static int wanpipe_do_bind(struct sock *sk, netdevice_t *dev, int protocol) { + wanpipe_opt *wp = wp_sk(sk); wanpipe_common_t *chan=NULL; int err=0; @@ -1360,7 +1365,7 @@ static int wanpipe_do_bind(struct sock *sk, netdevice_t *dev, int protocol) goto bind_unlock_exit; } - sk->num = protocol; + wp->num = protocol; if (protocol == 0){ release_device(dev); @@ -1373,7 +1378,7 @@ static int wanpipe_do_bind(struct sock *sk, netdevice_t *dev, int protocol) chan=dev->priv; sk->state = chan->state; - if (sk->num == htons(X25_PROT) && + if (wp->num == htons(X25_PROT) && sk->state != WANSOCK_DISCONNECTED && sk->state != WANSOCK_CONNECTING){ DBG_PRINTK(KERN_INFO @@ -1388,7 +1393,7 @@ static int wanpipe_do_bind(struct sock *sk, netdevice_t *dev, int protocol) sk->bound_dev_if = dev->ifindex; /* X25 Specific option */ - if (sk->num == htons(X25_PROT)) + if (wp->num == htons(X25_PROT)) wp_sk(sk)->svc = chan->svc; } else { @@ -1421,6 +1426,7 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le { struct wan_sockaddr_ll *sll = (struct wan_sockaddr_ll*)uaddr; struct sock *sk=sock->sk; + wanpipe_opt *wp = wp_sk(sk); netdevice_t *dev = NULL; sdla_t *card=NULL; char name[15]; @@ -1462,7 +1468,7 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le return err; if (sll->sll_protocol) - sk->num = sll->sll_protocol; + wp->num = sll->sll_protocol; sk->state = WANSOCK_BIND_LISTEN; return 0; @@ -1509,7 +1515,7 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le return -EINVAL; } - return wanpipe_do_bind(sk, dev, sll->sll_protocol ? : sk->num); + return wanpipe_do_bind(sk, dev, sll->sll_protocol ? : wp->num); } /*============================================================ @@ -1613,7 +1619,7 @@ static int wanpipe_create(struct socket *sock, int protocol) sk->zapped=0; sk->family = PF_WANPIPE; - sk->num = protocol; + wp_sk(sk)->num = protocol; sk->state = WANSOCK_DISCONNECTED; sk->ack_backlog = 0; sk->bound_dev_if=0; @@ -1774,7 +1780,7 @@ static int wanpipe_getname(struct socket *sock, struct sockaddr *uaddr, sll->sll_family = AF_WANPIPE; sll->sll_ifindex = sk->bound_dev_if; - sll->sll_protocol = sk->num; + sll->sll_protocol = wp_sk(sk)->num; dev = dev_get_by_index(sk->bound_dev_if); if (dev) { sll->sll_hatype = dev->type; @@ -1836,7 +1842,8 @@ static int wanpipe_notifier(struct notifier_block *this, unsigned long msg, void } break; case NETDEV_UP: - if (dev->ifindex == sk->bound_dev_if && sk->num && !sk->zapped) { + if (dev->ifindex == sk->bound_dev_if && + po->num && !sk->zapped) { printk(KERN_INFO "wansock: Registering Device: %s\n", dev->name); wanpipe_link_driver(dev,sk); @@ -2242,7 +2249,7 @@ unsigned int wanpipe_poll(struct file * file, struct socket *sock, poll_table *w * where multiple packets can be pending in the socket * transmit queue */ - if (sk->num == htons(X25_PROT)){ + if (wp_sk(sk)->num == htons(X25_PROT)) { if (atomic_read(&wp_sk(sk)->packet_sent)) return mask; } @@ -2274,7 +2281,7 @@ static int wanpipe_listen(struct socket *sock, int backlog) /* This is x25 specific area if protocol doesn't * match, return error */ - if (sk->num != htons(X25_PROT)) + if (wp_sk(sk)->num != htons(X25_PROT)) return -EINVAL; if (sk->state == WANSOCK_BIND_LISTEN) { @@ -2352,7 +2359,7 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags) /* This is x25 specific area if protocol doesn't * match, return error */ - if (sk->num != htons(X25_PROT)) + if (wp->num != htons(X25_PROT)) return -EINVAL; @@ -2535,7 +2542,7 @@ static int wanpipe_accept(struct socket *sock, struct socket *newsock, int flags if (sk->state != WANSOCK_LISTEN) return -EINVAL; - if (sk->num != htons(X25_PROT)) + if (wp_sk(sk)->num != htons(X25_PROT)) return -EINVAL; add_wait_queue(sk->sleep,&wait); @@ -2628,7 +2635,7 @@ static int wanpipe_connect(struct socket *sock, struct sockaddr *uaddr, int addr netdevice_t *dev; int err; - if (sk->num != htons(X25_PROT)) + if (wp_sk(sk)->num != htons(X25_PROT)) return -EINVAL; if (sk->state == WANSOCK_CONNECTED) -- cgit v1.2.3 From 7d42ccf3d8b273320cd05c850f9b41d79e3dfb96 Mon Sep 17 00:00:00 2001 From: Brian Gerst Date: Sun, 17 Mar 2002 18:38:35 -0800 Subject: [PATCH] struct super_block cleanup - isofs Seperates isofs_sb_info from struct super_block. --- fs/isofs/dir.c | 17 +++--- fs/isofs/inode.c | 157 ++++++++++++++++++++++++++----------------------- fs/isofs/joliet.c | 4 +- fs/isofs/namei.c | 13 ++-- fs/isofs/rock.c | 26 ++++---- include/linux/fs.h | 2 - include/linux/iso_fs.h | 7 ++- 7 files changed, 120 insertions(+), 106 deletions(-) (limited to 'include/linux') diff --git a/fs/isofs/dir.c b/fs/isofs/dir.c index 583ade0421c0..bef27095249e 100644 --- a/fs/isofs/dir.c +++ b/fs/isofs/dir.c @@ -110,14 +110,13 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp, struct buffer_head *bh = NULL; int len; int map; - int high_sierra; int first_de = 1; char *p = NULL; /* Quiet GCC */ struct iso_directory_record *de; + struct isofs_sb_info *sbi = ISOFS_SB(inode->i_sb); offset = filp->f_pos & (bufsize - 1); block = filp->f_pos >> bufbits; - high_sierra = inode->i_sb->u.isofs_sb.s_high_sierra; while (filp->f_pos < inode->i_size) { int de_len; @@ -166,7 +165,7 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp, de = tmpde; } - if (de->flags[-high_sierra] & 0x80) { + if (de->flags[-sbi->s_high_sierra] & 0x80) { first_de = 0; filp->f_pos += de_len; continue; @@ -194,16 +193,16 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp, /* Handle everything else. Do name translation if there is no Rock Ridge NM field. */ - if (inode->i_sb->u.isofs_sb.s_unhide == 'n') { + if (sbi->s_unhide == 'n') { /* Do not report hidden or associated files */ - if (de->flags[-high_sierra] & 5) { + if (de->flags[-sbi->s_high_sierra] & 5) { filp->f_pos += de_len; continue; } } map = 1; - if (inode->i_sb->u.isofs_sb.s_rock) { + if (sbi->s_rock) { len = get_rock_ridge_filename(de, tmpname, inode); if (len != 0) { /* may be -1 */ p = tmpname; @@ -212,16 +211,16 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp, } if (map) { #ifdef CONFIG_JOLIET - if (inode->i_sb->u.isofs_sb.s_joliet_level) { + if (sbi->s_joliet_level) { len = get_joliet_filename(de, tmpname, inode); p = tmpname; } else #endif - if (inode->i_sb->u.isofs_sb.s_mapping == 'a') { + if (sbi->s_mapping == 'a') { len = get_acorn_filename(de, tmpname, inode); p = tmpname; } else - if (inode->i_sb->u.isofs_sb.s_mapping == 'n') { + if (sbi->s_mapping == 'n') { len = isofs_name_translate(de, tmpname, inode); p = tmpname; } else { diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index d1bec1eae0a0..31174ae2bede 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c @@ -60,10 +60,11 @@ static int isofs_dentry_cmp_ms(struct dentry *dentry, struct qstr *a, struct qst static void isofs_put_super(struct super_block *sb) { + struct isofs_sb_info *sbi = ISOFS_SB(sb); #ifdef CONFIG_JOLIET - if (sb->u.isofs_sb.s_nls_iocharset) { - unload_nls(sb->u.isofs_sb.s_nls_iocharset); - sb->u.isofs_sb.s_nls_iocharset = NULL; + if (sbi->s_nls_iocharset) { + unload_nls(sbi->s_nls_iocharset); + sbi->s_nls_iocharset = NULL; } #endif @@ -72,6 +73,8 @@ static void isofs_put_super(struct super_block *sb) check_malloc, check_bread); #endif + kfree(sbi); + sb->u.generic_sbp = NULL; return; } @@ -518,7 +521,6 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) struct iso_supplementary_descriptor *sec = NULL; struct iso_directory_record * rootp; int joliet_level = 0; - int high_sierra; int iso_blknum, block; int orig_zonesize; int table; @@ -526,9 +528,16 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) unsigned long first_data_zone; struct inode * inode; struct iso9660_options opt; + struct isofs_sb_info * sbi; + + sbi = kmalloc(sizeof(struct isofs_sb_info), GFP_KERNEL); + if (!sbi) + return -ENOMEM; + s->u.generic_sbp = sbi; + memset(sbi, 0, sizeof(struct isofs_sb_info)); if (!parse_options((char *) data, &opt)) - goto out_unlock; + goto out_freesbi; #if 0 printk("map = %c\n", opt.map); @@ -554,7 +563,7 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) */ opt.blocksize = sb_min_blocksize(s, opt.blocksize); - s->u.isofs_sb.s_high_sierra = high_sierra = 0; /* default is iso9660 */ + sbi->s_high_sierra = 0; /* default is iso9660 */ vol_desc_start = (opt.sbsector != -1) ? opt.sbsector : isofs_get_last_session(s,opt.session); @@ -614,8 +623,7 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) if (isonum_711 (hdp->type) != ISO_VD_PRIMARY) goto out_freebh; - s->u.isofs_sb.s_high_sierra = 1; - high_sierra = 1; + sbi->s_high_sierra = 1; opt.rock = 'n'; h_pri = (struct hs_primary_descriptor *)vdp; goto root_found; @@ -646,29 +654,29 @@ root_found: pri = (struct iso_primary_descriptor *) sec; } - if(high_sierra){ + if(sbi->s_high_sierra){ rootp = (struct iso_directory_record *) h_pri->root_directory_record; #ifndef IGNORE_WRONG_MULTI_VOLUME_SPECS if (isonum_723 (h_pri->volume_set_size) != 1) goto out_no_support; #endif /* IGNORE_WRONG_MULTI_VOLUME_SPECS */ - s->u.isofs_sb.s_nzones = isonum_733 (h_pri->volume_space_size); - s->u.isofs_sb.s_log_zone_size = isonum_723 (h_pri->logical_block_size); - s->u.isofs_sb.s_max_size = isonum_733(h_pri->volume_space_size); + sbi->s_nzones = isonum_733 (h_pri->volume_space_size); + sbi->s_log_zone_size = isonum_723 (h_pri->logical_block_size); + sbi->s_max_size = isonum_733(h_pri->volume_space_size); } else { rootp = (struct iso_directory_record *) pri->root_directory_record; #ifndef IGNORE_WRONG_MULTI_VOLUME_SPECS if (isonum_723 (pri->volume_set_size) != 1) goto out_no_support; #endif /* IGNORE_WRONG_MULTI_VOLUME_SPECS */ - s->u.isofs_sb.s_nzones = isonum_733 (pri->volume_space_size); - s->u.isofs_sb.s_log_zone_size = isonum_723 (pri->logical_block_size); - s->u.isofs_sb.s_max_size = isonum_733(pri->volume_space_size); + sbi->s_nzones = isonum_733 (pri->volume_space_size); + sbi->s_log_zone_size = isonum_723 (pri->logical_block_size); + sbi->s_max_size = isonum_733(pri->volume_space_size); } - s->u.isofs_sb.s_ninodes = 0; /* No way to figure this out easily */ + sbi->s_ninodes = 0; /* No way to figure this out easily */ - orig_zonesize = s -> u.isofs_sb.s_log_zone_size; + orig_zonesize = sbi->s_log_zone_size; /* * If the zone size is smaller than the hardware sector size, * this is a fatal error. This would occur if the disc drive @@ -680,10 +688,10 @@ root_found: goto out_bad_size; /* RDE: convert log zone size to bit shift */ - switch (s -> u.isofs_sb.s_log_zone_size) - { case 512: s -> u.isofs_sb.s_log_zone_size = 9; break; - case 1024: s -> u.isofs_sb.s_log_zone_size = 10; break; - case 2048: s -> u.isofs_sb.s_log_zone_size = 11; break; + switch (sbi->s_log_zone_size) + { case 512: sbi->s_log_zone_size = 9; break; + case 1024: sbi->s_log_zone_size = 10; break; + case 2048: sbi->s_log_zone_size = 11; break; default: goto out_bad_zone_size; @@ -705,16 +713,16 @@ root_found: first_data_zone = ((isonum_733 (rootp->extent) + isonum_711 (rootp->ext_attr_length)) - << s -> u.isofs_sb.s_log_zone_size); - s->u.isofs_sb.s_firstdatazone = first_data_zone; + << sbi->s_log_zone_size); + sbi->s_firstdatazone = first_data_zone; #ifndef BEQUIET printk(KERN_DEBUG "Max size:%ld Log zone size:%ld\n", - s->u.isofs_sb.s_max_size, - 1UL << s->u.isofs_sb.s_log_zone_size); + sbi->s_max_size, + 1UL << sbi->s_log_zone_size); printk(KERN_DEBUG "First datazone:%ld Root inode number:%ld\n", - s->u.isofs_sb.s_firstdatazone >> s -> u.isofs_sb.s_log_zone_size, - s->u.isofs_sb.s_firstdatazone); - if(high_sierra) + sbi->s_firstdatazone >> sbi->s_log_zone_size, + sbi->s_firstdatazone); + if(sbi->s_high_sierra) printk(KERN_DEBUG "Disc in High Sierra format.\n"); #endif @@ -732,7 +740,7 @@ root_found: pri->root_directory_record; first_data_zone = ((isonum_733 (rootp->extent) + isonum_711 (rootp->ext_attr_length)) - << s -> u.isofs_sb.s_log_zone_size); + << sbi->s_log_zone_size); } /* @@ -761,43 +769,43 @@ root_found: */ sb_set_blocksize(s, orig_zonesize); - s->u.isofs_sb.s_nls_iocharset = NULL; + sbi->s_nls_iocharset = NULL; #ifdef CONFIG_JOLIET if (joliet_level && opt.utf8 == 0) { char * p = opt.iocharset ? opt.iocharset : "iso8859-1"; - s->u.isofs_sb.s_nls_iocharset = load_nls(p); - if (! s->u.isofs_sb.s_nls_iocharset) { + sbi->s_nls_iocharset = load_nls(p); + if (! sbi->s_nls_iocharset) { /* Fail only if explicit charset specified */ if (opt.iocharset) - goto out_unlock; - s->u.isofs_sb.s_nls_iocharset = load_nls_default(); + goto out_freesbi; + sbi->s_nls_iocharset = load_nls_default(); } } #endif s->s_op = &isofs_sops; - s->u.isofs_sb.s_mapping = opt.map; - s->u.isofs_sb.s_rock = (opt.rock == 'y' ? 2 : 0); - s->u.isofs_sb.s_rock_offset = -1; /* initial offset, will guess until SP is found*/ - s->u.isofs_sb.s_cruft = opt.cruft; - s->u.isofs_sb.s_unhide = opt.unhide; - s->u.isofs_sb.s_uid = opt.uid; - s->u.isofs_sb.s_gid = opt.gid; - s->u.isofs_sb.s_utf8 = opt.utf8; - s->u.isofs_sb.s_nocompress = opt.nocompress; + sbi->s_mapping = opt.map; + sbi->s_rock = (opt.rock == 'y' ? 2 : 0); + sbi->s_rock_offset = -1; /* initial offset, will guess until SP is found*/ + sbi->s_cruft = opt.cruft; + sbi->s_unhide = opt.unhide; + sbi->s_uid = opt.uid; + sbi->s_gid = opt.gid; + sbi->s_utf8 = opt.utf8; + sbi->s_nocompress = opt.nocompress; /* * It would be incredibly stupid to allow people to mark every file * on the disk as suid, so we merely allow them to set the default * permissions. */ - s->u.isofs_sb.s_mode = opt.mode & 0777; + sbi->s_mode = opt.mode & 0777; /* * Read the root inode, which _may_ result in changing * the s_rock flag. Once we have the final s_rock value, * we then decide whether to use the Joliet descriptor. */ - inode = iget(s, s->u.isofs_sb.s_firstdatazone); + inode = iget(s, sbi->s_firstdatazone); /* * If this disk has both Rock Ridge and Joliet on it, then we @@ -807,16 +815,16 @@ root_found: * CD with Unicode names. Until someone sees such a beast, it * will not be supported. */ - if (s->u.isofs_sb.s_rock == 1) { + if (sbi->s_rock == 1) { joliet_level = 0; } else if (joliet_level) { - s->u.isofs_sb.s_rock = 0; - if (s->u.isofs_sb.s_firstdatazone != first_data_zone) { - s->u.isofs_sb.s_firstdatazone = first_data_zone; + sbi->s_rock = 0; + if (sbi->s_firstdatazone != first_data_zone) { + sbi->s_firstdatazone = first_data_zone; printk(KERN_DEBUG "ISOFS: changing to secondary root\n"); iput(inode); - inode = iget(s, s->u.isofs_sb.s_firstdatazone); + inode = iget(s, sbi->s_firstdatazone); } } @@ -825,7 +833,7 @@ root_found: if (joliet_level) opt.check = 'r'; else opt.check = 's'; } - s->u.isofs_sb.s_joliet_level = joliet_level; + sbi->s_joliet_level = joliet_level; /* check the root inode */ if (!inode) @@ -855,18 +863,18 @@ out_no_root: out_iput: iput(inode); #ifdef CONFIG_JOLIET - if (s->u.isofs_sb.s_nls_iocharset) - unload_nls(s->u.isofs_sb.s_nls_iocharset); + if (sbi->s_nls_iocharset) + unload_nls(sbi->s_nls_iocharset); #endif - goto out_unlock; + goto out_freesbi; out_no_read: printk(KERN_WARNING "isofs_fill_super: " "bread failed, dev=%s, iso_blknum=%d, block=%d\n", s->s_id, iso_blknum, block); - goto out_unlock; + goto out_freesbi; out_bad_zone_size: printk(KERN_WARNING "Bad logical zone size %ld\n", - s->u.isofs_sb.s_log_zone_size); + sbi->s_log_zone_size); goto out_freebh; out_bad_size: printk(KERN_WARNING "Logical zone size(%d) < hardware blocksize(%u)\n", @@ -883,7 +891,9 @@ out_unknown_format: out_freebh: brelse(bh); -out_unlock: +out_freesbi: + kfree(sbi); + s->u.generic_sbp = NULL; return -EINVAL; } @@ -891,11 +901,11 @@ static int isofs_statfs (struct super_block *sb, struct statfs *buf) { buf->f_type = ISOFS_SUPER_MAGIC; buf->f_bsize = sb->s_blocksize; - buf->f_blocks = (sb->u.isofs_sb.s_nzones - << (sb->u.isofs_sb.s_log_zone_size - sb->s_blocksize_bits)); + buf->f_blocks = (ISOFS_SB(sb)->s_nzones + << (ISOFS_SB(sb)->s_log_zone_size - sb->s_blocksize_bits)); buf->f_bfree = 0; buf->f_bavail = 0; - buf->f_files = sb->u.isofs_sb.s_ninodes; + buf->f_files = ISOFS_SB(sb)->s_ninodes; buf->f_ffree = 0; buf->f_namelen = NAME_MAX; return 0; @@ -1058,7 +1068,7 @@ static int isofs_read_level3_size(struct inode * inode) { unsigned long f_pos = inode->i_ino; unsigned long bufsize = ISOFS_BUFFER_SIZE(inode); - int high_sierra = inode->i_sb->u.isofs_sb.s_high_sierra; + int high_sierra = ISOFS_SB(inode->i_sb)->s_high_sierra; struct buffer_head * bh = NULL; unsigned long block, offset; int i = 0; @@ -1157,9 +1167,10 @@ out_toomany: static void isofs_read_inode(struct inode * inode) { struct super_block *sb = inode->i_sb; + struct isofs_sb_info *sbi = ISOFS_SB(sb); unsigned long bufsize = ISOFS_BUFFER_SIZE(inode); int block = inode->i_ino >> ISOFS_BUFFER_BITS(inode); - int high_sierra = sb->u.isofs_sb.s_high_sierra; + int high_sierra = sbi->s_high_sierra; struct buffer_head * bh = NULL; struct iso_directory_record * de; struct iso_directory_record * tmpde = NULL; @@ -1205,7 +1216,7 @@ static void isofs_read_inode(struct inode * inode) do it the hard way. */ } else { /* Everybody gets to read the file. */ - inode->i_mode = inode->i_sb->u.isofs_sb.s_mode; + inode->i_mode = sbi->s_mode; inode->i_nlink = 1; inode->i_mode |= S_IFREG; /* If there are no periods in the name, @@ -1217,8 +1228,8 @@ static void isofs_read_inode(struct inode * inode) if(i == de->name_len[0] || de->name[i] == ';') inode->i_mode |= S_IXUGO; /* execute permission */ } - inode->i_uid = inode->i_sb->u.isofs_sb.s_uid; - inode->i_gid = inode->i_sb->u.isofs_sb.s_gid; + inode->i_uid = sbi->s_uid; + inode->i_gid = sbi->s_gid; inode->i_blocks = inode->i_blksize = 0; ei->i_format_parm[0] = 0; @@ -1241,10 +1252,10 @@ static void isofs_read_inode(struct inode * inode) * legal. Do not prevent to use DVD's schilling@fokus.gmd.de */ if ((inode->i_size < 0 || inode->i_size > 0x7FFFFFFE) && - inode->i_sb->u.isofs_sb.s_cruft == 'n') { + sbi->s_cruft == 'n') { printk(KERN_WARNING "Warning: defective CD-ROM. " "Enabling \"cruft\" mount option.\n"); - inode->i_sb->u.isofs_sb.s_cruft = 'y'; + sbi->s_cruft = 'y'; } /* @@ -1254,7 +1265,7 @@ static void isofs_read_inode(struct inode * inode) * on the CDROM. */ - if (inode->i_sb->u.isofs_sb.s_cruft == 'y' && + if (sbi->s_cruft == 'y' && inode->i_size & 0xff000000) { inode->i_size &= 0x00ffffff; } @@ -1298,8 +1309,8 @@ static void isofs_read_inode(struct inode * inode) if (!high_sierra) { parse_rock_ridge_inode(de, inode); /* if we want uid/gid set, override the rock ridge setting */ - test_and_set_uid(&inode->i_uid, inode->i_sb->u.isofs_sb.s_uid); - test_and_set_gid(&inode->i_gid, inode->i_sb->u.isofs_sb.s_gid); + test_and_set_uid(&inode->i_uid, sbi->s_uid); + test_and_set_gid(&inode->i_gid, sbi->s_gid); } /* get the volume sequence number */ @@ -1311,17 +1322,17 @@ static void isofs_read_inode(struct inode * inode) * of which is limiting the file size to 16Mb. Thus we silently allow * volume numbers of 0 to go through without complaining. */ - if (inode->i_sb->u.isofs_sb.s_cruft == 'n' && + if (sbi->s_cruft == 'n' && (volume_seq_no != 0) && (volume_seq_no != 1)) { printk(KERN_WARNING "Warning: defective CD-ROM " "(volume sequence number %d). " "Enabling \"cruft\" mount option.\n", volume_seq_no); - inode->i_sb->u.isofs_sb.s_cruft = 'y'; + sbi->s_cruft = 'y'; } /* Install the inode operations vector */ #ifndef IGNORE_WRONG_MULTI_VOLUME_SPECS - if (inode->i_sb->u.isofs_sb.s_cruft != 'y' && + if (sbi->s_cruft != 'y' && (volume_seq_no != 0) && (volume_seq_no != 1)) { printk(KERN_WARNING "Multi-volume CD somehow got mounted.\n"); } else diff --git a/fs/isofs/joliet.c b/fs/isofs/joliet.c index 15d2370bda3f..86c50e22fc87 100644 --- a/fs/isofs/joliet.c +++ b/fs/isofs/joliet.c @@ -77,8 +77,8 @@ get_joliet_filename(struct iso_directory_record * de, unsigned char *outname, st struct nls_table *nls; unsigned char len = 0; - utf8 = inode->i_sb->u.isofs_sb.s_utf8; - nls = inode->i_sb->u.isofs_sb.s_nls_iocharset; + utf8 = ISOFS_SB(inode->i_sb)->s_utf8; + nls = ISOFS_SB(inode->i_sb)->s_nls_iocharset; if (utf8) { len = wcsntombs_be(outname, de->name, diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c index 485bb7023fe2..cbdf44b0164e 100644 --- a/fs/isofs/namei.c +++ b/fs/isofs/namei.c @@ -65,6 +65,7 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry, unsigned char bufbits = ISOFS_BUFFER_BITS(dir); unsigned int block, f_pos, offset; struct buffer_head * bh = NULL; + struct isofs_sb_info *sbi = ISOFS_SB(dir->i_sb); if (!ISOFS_I(dir)->i_first_extent) return 0; @@ -120,19 +121,19 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry, dlen = de->name_len[0]; dpnt = de->name; - if (dir->i_sb->u.isofs_sb.s_rock && + if (sbi->s_rock && ((i = get_rock_ridge_filename(de, tmpname, dir)))) { dlen = i; /* possibly -1 */ dpnt = tmpname; #ifdef CONFIG_JOLIET - } else if (dir->i_sb->u.isofs_sb.s_joliet_level) { + } else if (sbi->s_joliet_level) { dlen = get_joliet_filename(de, tmpname, dir); dpnt = tmpname; #endif - } else if (dir->i_sb->u.isofs_sb.s_mapping == 'a') { + } else if (sbi->s_mapping == 'a') { dlen = get_acorn_filename(de, tmpname, dir); dpnt = tmpname; - } else if (dir->i_sb->u.isofs_sb.s_mapping == 'n') { + } else if (sbi->s_mapping == 'n') { dlen = isofs_name_translate(de, tmpname, dir); dpnt = tmpname; } @@ -142,8 +143,8 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry, */ match = 0; if (dlen > 0 && - (!(de->flags[-dir->i_sb->u.isofs_sb.s_high_sierra] & 5) - || dir->i_sb->u.isofs_sb.s_unhide == 'y')) + (!(de->flags[-sbi->s_high_sierra] & 5) + || sbi->s_unhide == 'y')) { match = (isofs_cmp(dentry,dpnt,dlen) == 0); } diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c index 5065d2fdccc6..17b2bb5e6908 100644 --- a/fs/isofs/rock.c +++ b/fs/isofs/rock.c @@ -32,7 +32,7 @@ #define CHECK_SP(FAIL) \ if(rr->u.SP.magic[0] != 0xbe) FAIL; \ if(rr->u.SP.magic[1] != 0xef) FAIL; \ - inode->i_sb->u.isofs_sb.s_rock_offset=rr->u.SP.skip; + ISOFS_SB(inode->i_sb)->s_rock_offset=rr->u.SP.skip; /* We define a series of macros because each function must do exactly the same thing in certain places. We use the macros to ensure that everything is done correctly */ @@ -51,10 +51,10 @@ if(LEN & 1) LEN++; \ CHR = ((unsigned char *) DE) + LEN; \ LEN = *((unsigned char *) DE) - LEN; \ - if (inode->i_sb->u.isofs_sb.s_rock_offset!=-1) \ + if (ISOFS_SB(inode->i_sb)->s_rock_offset!=-1) \ { \ - LEN-=inode->i_sb->u.isofs_sb.s_rock_offset; \ - CHR+=inode->i_sb->u.isofs_sb.s_rock_offset; \ + LEN-=ISOFS_SB(inode->i_sb)->s_rock_offset; \ + CHR+=ISOFS_SB(inode->i_sb)->s_rock_offset; \ if (LEN<0) LEN=0; \ } \ } @@ -102,7 +102,7 @@ int find_rock_ridge_relocation(struct iso_directory_record * de, /* Return value if we do not find appropriate record. */ retval = isonum_733 (de->extent); - if (!inode->i_sb->u.isofs_sb.s_rock) return retval; + if (!ISOFS_SB(inode->i_sb)->s_rock) return retval; SETUP_ROCK_RIDGE(de, chr, len); repeat: @@ -162,7 +162,7 @@ int get_rock_ridge_filename(struct iso_directory_record * de, CONTINUE_DECLS; int retnamlen = 0, truncate=0; - if (!inode->i_sb->u.isofs_sb.s_rock) return 0; + if (!ISOFS_SB(inode->i_sb)->s_rock) return 0; *retname = 0; SETUP_ROCK_RIDGE(de, chr, len); @@ -234,7 +234,7 @@ int parse_rock_ridge_inode_internal(struct iso_directory_record * de, int symlink_len = 0; CONTINUE_DECLS; - if (!inode->i_sb->u.isofs_sb.s_rock) return 0; + if (!ISOFS_SB(inode->i_sb)->s_rock) return 0; SETUP_ROCK_RIDGE(de, chr, len); if (regard_xa) @@ -272,7 +272,7 @@ int parse_rock_ridge_inode_internal(struct iso_directory_record * de, CHECK_CE; break; case SIG('E','R'): - inode->i_sb->u.isofs_sb.s_rock = 1; + ISOFS_SB(inode->i_sb)->s_rock = 1; printk(KERN_DEBUG "ISO 9660 Extensions: "); { int p; for(p=0;pu.ER.len_id;p++) printk("%c",rr->u.ER.data[p]); @@ -368,7 +368,7 @@ int parse_rock_ridge_inode_internal(struct iso_directory_record * de, ISOFS_I(inode)->i_first_extent = isonum_733(rr->u.CL.location); reloc = iget(inode->i_sb, (ISOFS_I(inode)->i_first_extent << - inode -> i_sb -> u.isofs_sb.s_log_zone_size)); + ISOFS_SB(inode->i_sb)->s_log_zone_size)); if (!reloc) goto out; inode->i_mode = reloc->i_mode; @@ -385,7 +385,7 @@ int parse_rock_ridge_inode_internal(struct iso_directory_record * de, break; #ifdef CONFIG_ZISOFS case SIG('Z','F'): - if ( !inode->i_sb->u.isofs_sb.s_nocompress ) { + if ( !ISOFS_SB(inode->i_sb)->s_nocompress ) { int algo; algo = isonum_721(rr->u.ZF.algorithm); if ( algo == SIG('p','z') ) { @@ -478,8 +478,8 @@ int parse_rock_ridge_inode(struct iso_directory_record * de, int result=parse_rock_ridge_inode_internal(de,inode,0); /* if rockridge flag was reset and we didn't look for attributes * behind eventual XA attributes, have a look there */ - if ((inode->i_sb->u.isofs_sb.s_rock_offset==-1) - &&(inode->i_sb->u.isofs_sb.s_rock==2)) + if ((ISOFS_SB(inode->i_sb)->s_rock_offset==-1) + &&(ISOFS_SB(inode->i_sb)->s_rock==2)) { result=parse_rock_ridge_inode_internal(de,inode,14); }; @@ -506,7 +506,7 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page) unsigned char *chr; struct rock_ridge *rr; - if (!inode->i_sb->u.isofs_sb.s_rock) + if (!ISOFS_SB(inode->i_sb)->s_rock) panic ("Cannot have symlink with high sierra variant of iso filesystem\n"); block = inode->i_ino >> bufbits; diff --git a/include/linux/fs.h b/include/linux/fs.h index f9f89afcb51e..f303f619b559 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -648,7 +648,6 @@ struct quota_mount_options #include #include #include -#include #include #include #include @@ -697,7 +696,6 @@ struct super_block { struct ext3_sb_info ext3_sb; struct hpfs_sb_info hpfs_sb; struct ntfs_sb_info ntfs_sb; - struct isofs_sb_info isofs_sb; struct sysv_sb_info sysv_sb; struct affs_sb_info affs_sb; struct ufs_sb_info ufs_sb; diff --git a/include/linux/iso_fs.h b/include/linux/iso_fs.h index b235c3ea9f23..3520e22a2af8 100644 --- a/include/linux/iso_fs.h +++ b/include/linux/iso_fs.h @@ -160,7 +160,6 @@ struct iso_directory_record { #define ISOFS_BUFFER_SIZE(INODE) ((INODE)->i_sb->s_blocksize) #define ISOFS_BUFFER_BITS(INODE) ((INODE)->i_sb->s_blocksize_bits) -#define ISOFS_ZONE_BITS(INODE) ((INODE)->i_sb->u.isofs_sb.s_log_zone_size) #define ISOFS_SUPER_MAGIC 0x9660 @@ -171,6 +170,12 @@ struct iso_directory_record { #include #include #include +#include + +static inline struct isofs_sb_info *ISOFS_SB(struct super_block *sb) +{ + return sb->u.generic_sbp; +} static inline struct iso_inode_info *ISOFS_I(struct inode *inode) { -- cgit v1.2.3 From 2703321515d8d73771236f78f8fb721103a1494f Mon Sep 17 00:00:00 2001 From: Brian Gerst Date: Sun, 17 Mar 2002 18:38:40 -0800 Subject: [PATCH] struct super_block cleanup - udf Seperates udf_sb_info from struct super_block. --- fs/udf/super.c | 9 +++++++++ fs/udf/udf_sb.h | 6 +++++- fs/udf/udfdecl.h | 4 ++-- include/linux/fs.h | 2 -- 4 files changed, 16 insertions(+), 5 deletions(-) (limited to 'include/linux') diff --git a/fs/udf/super.c b/fs/udf/super.c index 0e668a01a592..2edd4015fb61 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1413,12 +1413,17 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) struct inode *inode=NULL; struct udf_options uopt; lb_addr rootdir, fileset; + struct udf_sb_info *sbi; uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT); uopt.uid = -1; uopt.gid = -1; uopt.umask = 0; + sbi = kmalloc(sizeof(struct udf_sb_info), GFP_KERNEL); + if (!sbi) + return -ENOMEM; + sb->u.generic_sbp = sbi; memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info)); #if UDFFS_RW != 1 @@ -1607,6 +1612,8 @@ error_out: udf_close_lvid(sb); udf_release_data(UDF_SB_LVIDBH(sb)); UDF_SB_FREE(sb); + kfree(sbi); + sb->u.generic_sbp = NULL; return -EINVAL; } @@ -1697,6 +1704,8 @@ udf_put_super(struct super_block *sb) udf_close_lvid(sb); udf_release_data(UDF_SB_LVIDBH(sb)); UDF_SB_FREE(sb); + kfree(sb->u.generic_sbp); + sb->u.generic_sbp = NULL; } /* diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h index 0dde99415c97..2b264e1cf49a 100644 --- a/fs/udf/udf_sb.h +++ b/fs/udf/udf_sb.h @@ -30,6 +30,11 @@ #define UDF_PART_FLAG_REWRITABLE 0x0040 #define UDF_PART_FLAG_OVERWRITABLE 0x0080 +static inline struct udf_sb_info *UDF_SB(struct super_block *sb) +{ + return sb->u.generic_sbp; +} + #define UDF_SB_FREE(X)\ {\ if (UDF_SB(X))\ @@ -39,7 +44,6 @@ UDF_SB_PARTMAPS(X) = NULL;\ }\ } -#define UDF_SB(X) (&((X)->u.udf_sb)) #define UDF_SB_ALLOC_PARTMAPS(X,Y)\ {\ diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index 836aef50cded..1b4d5a5d1401 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h @@ -8,6 +8,8 @@ #include #include #include +#include +#include #ifndef LINUX_VERSION_CODE #include @@ -15,8 +17,6 @@ #if !defined(CONFIG_UDF_FS) && !defined(CONFIG_UDF_FS_MODULE) #define CONFIG_UDF_FS_MODULE -#include -#include #endif #include "udfend.h" diff --git a/include/linux/fs.h b/include/linux/fs.h index f303f619b559..c8651e089379 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -656,7 +656,6 @@ struct quota_mount_options #include #include #include -#include #include extern struct list_head super_blocks; @@ -705,7 +704,6 @@ struct super_block { struct adfs_sb_info adfs_sb; struct reiserfs_sb_info reiserfs_sb; struct bfs_sb_info bfs_sb; - struct udf_sb_info udf_sb; struct jffs2_sb_info jffs2_sb; void *generic_sbp; } u; -- cgit v1.2.3