2090 return __sk_head(&unix_socket_table[*i]);
2091 }
2092 return NULL;
2093}
2094
2095struct unix_iter_state {
2096 struct seq_net_private p;
2097 int i;
2098};
2099static struct sock *unix_seq_idx(struct seq_file *seq, loff_t pos)
2100{
2101 struct unix_iter_state *iter = seq->private;
2102 loff_t off = 0;
2103 struct sock *s;
2104
2105 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
2106 if (sock_net(s) != seq_file_net(seq))
2107 continue;
2108 if (off == pos)
2109 return s;
2110 ++off;
2111 }
2112 return NULL;
2113}
2114
2115
2116static void *unix_seq_start(struct seq_file *seq, loff_t *pos)
2117 __acquires(unix_table_lock)
2118{
2119 spin_lock(&unix_table_lock);
2120 return *pos ? unix_seq_idx(seq, *pos - 1) : SEQ_START_TOKEN;
2121}
2122
2123static void *unix_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2124{
2125 struct unix_iter_state *iter = seq->private;
2126 struct sock *sk = v;
2127 ++*pos;
2128
2129 if (v == SEQ_START_TOKEN)
2130 sk = first_unix_socket(&iter->i);